Skip to content

Commit 0bb5c90

Browse files
feat(fuselage): Featured Tag variant (#922)
* new: featured tag variant * review * fix: tweaks Co-authored-by: juliajforesti <juliajforesti@gmail.com>
1 parent 47a63d4 commit 0bb5c90

File tree

4 files changed

+91
-24
lines changed

4 files changed

+91
-24
lines changed

packages/fuselage/src/components/Tag/Tag.stories.tsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ Secondary.args = {
5050
variant: 'secondary',
5151
};
5252

53-
export const WithIcon = Template.bind({});
54-
WithIcon.args = {
55-
children: (
56-
<>
57-
<Icon size='x12' mie='x4' name='team-lock' /> Team
58-
</>
59-
),
60-
};
61-
6253
export const _Danger = Template.bind({});
6354
_Danger.args = {
6455
variant: 'danger',
@@ -73,6 +64,16 @@ Warning.args = {
7364
variant: 'warning',
7465
};
7566

67+
export const Featured = Template.bind({});
68+
Featured.args = {
69+
variant: 'featured',
70+
};
71+
72+
export const WithIcon = Template.bind({});
73+
WithIcon.args = {
74+
icon: <Icon size='x12' mie='x2' name='team-lock' />,
75+
};
76+
7677
export const Disabled = Template.bind({});
7778
Disabled.args = {
7879
disabled: true,

packages/fuselage/src/components/Tag/Tag.styles.scss

+46-12
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ $tag-colors-default-hover-color: theme(
1212
);
1313
$tag-colors-default-background-color: theme(
1414
'tag-colors-default-background-color',
15-
colors.surface(neutral)
15+
colors.tag(default)
1616
);
1717
$tag-colors-default-hover-background-color: theme(
1818
'tag-colors-default-hover-background-color',
19-
colors.button(secondary-hover)
19+
colors.tag(default-hover)
2020
);
2121

2222
$tag-colors-primary-color: theme(
@@ -25,11 +25,11 @@ $tag-colors-primary-color: theme(
2525
);
2626
$tag-colors-primary-background-color: theme(
2727
'tag-colors-primary-background-color',
28-
colors.button(primary-default)
28+
colors.tag(primary)
2929
);
3030
$tag-colors-primary-hover-background-color: theme(
3131
'tag-colors-primary-hover-background-color',
32-
colors.button(primary-hover)
32+
colors.tag(primary-hover)
3333
);
3434

3535
$tag-colors-secondary-color: theme(
@@ -38,11 +38,11 @@ $tag-colors-secondary-color: theme(
3838
);
3939
$tag-colors-secondary-background-color: theme(
4040
'tag-colors-secondary-background-color',
41-
colors.button(secondary-default)
41+
colors.tag(secondary)
4242
);
4343
$tag-colors-secondary-hover-background-color: theme(
4444
'tag-colors-secondary-hover-background-color',
45-
colors.button(secondary-hover)
45+
colors.tag(secondary-hover)
4646
);
4747

4848
$tag-colors-danger-color: theme(
@@ -51,11 +51,11 @@ $tag-colors-danger-color: theme(
5151
);
5252
$tag-colors-danger-background-color: theme(
5353
'tag-colors-danger-background-color',
54-
colors.button(danger-default)
54+
colors.tag(danger)
5555
);
5656
$tag-colors-danger-hover-background-color: theme(
5757
'tag-colors-danger-hover-background-color',
58-
colors.button(danger-hover)
58+
colors.tag(danger-hover)
5959
);
6060

6161
$tag-colors-secondary-danger-color: theme(
@@ -64,11 +64,11 @@ $tag-colors-secondary-danger-color: theme(
6464
);
6565
$tag-colors-secondary-danger-background-color: theme(
6666
'tag-colors-secondary-danger-background-color',
67-
colors.button(secondary-danger-default)
67+
colors.tag(secondary)
6868
);
6969
$tag-colors-secondary-danger-hover-background-color: theme(
7070
'tag-colors-secondary-danger-hover-background-color',
71-
colors.button(secondary-danger-hover)
71+
colors.tag(secondary-hover)
7272
);
7373

7474
$tag-colors-warning-color: theme(
@@ -77,11 +77,24 @@ $tag-colors-warning-color: theme(
7777
);
7878
$tag-colors-warning-background-color: theme(
7979
'tag-colors-warning-background-color',
80-
colors.button(warning-default)
80+
colors.tag(warning)
8181
);
8282
$tag-colors-warning-hover-background-color: theme(
8383
'tag-colors-warning-hover-background-color',
84-
colors.button(warning-hover)
84+
colors.tag(warning-hover)
85+
);
86+
87+
$tag-colors-featured-color: theme(
88+
'tag-colors-featured-color',
89+
colors.button(on-primary)
90+
);
91+
$tag-colors-featured-background-color: theme(
92+
'tag-colors-featured-background-color',
93+
colors.tag(featured)
94+
);
95+
$tag-colors-featured-hover-background-color: theme(
96+
'tag-colors-featured-hover-background-color',
97+
colors.tag(featured-hover)
8598
);
8699

87100
$tag-colors-disabled-color: theme(
@@ -116,6 +129,15 @@ $tag-colors-disabled-background-color: theme(
116129

117130
@include typography.use-font-scale(micro);
118131

132+
&__inner {
133+
overflow: hidden;
134+
135+
min-width: 0;
136+
137+
white-space: nowrap;
138+
text-overflow: ellipsis;
139+
}
140+
119141
&--primary {
120142
color: $tag-colors-primary-color;
121143
background-color: $tag-colors-primary-background-color;
@@ -176,6 +198,18 @@ $tag-colors-disabled-background-color: theme(
176198
}
177199
}
178200

201+
&--featured {
202+
color: $tag-colors-featured-color;
203+
background-color: $tag-colors-featured-background-color;
204+
205+
&.rcx-tag--clickable {
206+
&:hover {
207+
color: $tag-colors-featured-color;
208+
background-color: $tag-colors-featured-hover-background-color;
209+
}
210+
}
211+
}
212+
179213
&--disabled {
180214
cursor: not-allowed;
181215

packages/fuselage/src/components/Tag/Tag.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
import type { AllHTMLAttributes } from 'react';
1+
import type { AllHTMLAttributes, ReactNode } from 'react';
22
import React from 'react';
33

44
import { prependClassName } from '../../helpers/prependClassName';
55

66
type TagProps = {
77
medium?: boolean;
88
large?: boolean;
9-
variant?: 'primary' | 'secondary' | 'danger' | 'warning' | 'secondary-danger';
9+
variant?:
10+
| 'primary'
11+
| 'secondary'
12+
| 'danger'
13+
| 'warning'
14+
| 'secondary-danger'
15+
| 'featured';
1016
disabled?: boolean;
17+
icon?: ReactNode;
1118
} & AllHTMLAttributes<HTMLSpanElement>;
1219

1320
export const Tag = ({
@@ -17,6 +24,8 @@ export const Tag = ({
1724
disabled,
1825
onClick,
1926
variant,
27+
children,
28+
icon,
2029
...props
2130
}: TagProps) => {
2231
const modifiers = [
@@ -35,6 +44,9 @@ export const Tag = ({
3544
className={prependClassName(className as string, `rcx-tag ${modifiers}`)}
3645
onClick={onClick}
3746
{...props}
38-
/>
47+
>
48+
{icon}
49+
<span className='rcx-tag__inner'>{children}</span>
50+
</span>
3951
);
4052
};

packages/fuselage/src/styles/colors.scss

+20
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,23 @@ $-elevation-level: (
312312
@function elevation($level) {
313313
@return map.get($-elevation-level, $level);
314314
}
315+
316+
$-tag-backgrounds: (
317+
default: neutral(400),
318+
default-hover: neutral(500),
319+
primary: primary(500),
320+
primary-hover: primary(600),
321+
secondary: neutral(400),
322+
secondary-hover: neutral(500),
323+
danger: danger(500),
324+
danger-hover: danger(600),
325+
warning: warning(400),
326+
warning-hover: warning(500),
327+
featured: service-2(700),
328+
featured-hover: service-2(800),
329+
);
330+
331+
@function tag($type) {
332+
$color: map.get($-tag-backgrounds, $type);
333+
@return var(--rcx-color-tag-background-#{$type}, $color);
334+
}

0 commit comments

Comments
 (0)