Skip to content

Commit 53e9d30

Browse files
committed
feat(Tag): special theme
1 parent 32b4b29 commit 53e9d30

File tree

8 files changed

+64
-8
lines changed

8 files changed

+64
-8
lines changed

.changeset/green-geckos-wave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Change `note-text` to improve contrast.

.changeset/rare-baboons-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Add `special` theme for components that use them.

.changeset/slimy-camels-flash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cube-dev/ui-kit': patch
3+
---
4+
5+
Allow to set mods for Tag component.

src/components/content/Tag/Tag.stories.tsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,55 @@ export default {
4545
},
4646
};
4747

48-
const Template: StoryFn<CubeTagProps> = ({ label, ...props }) => (
49-
<Tag {...props} onClose={() => console.log('close')}>
50-
{label}
51-
</Tag>
48+
const Template: StoryFn<CubeTagProps> = ({ ...props }) => (
49+
<Tag {...props} onClose={() => console.log('! onClose')} />
5250
);
5351

5452
export const Default = Template.bind({});
5553
Default.args = {
56-
label: 'Tag name or content',
54+
children: 'Tag name or content',
55+
};
56+
57+
export const Danger = Template.bind({});
58+
Danger.args = {
59+
children: 'Tag name or content',
60+
theme: 'danger',
61+
};
62+
63+
export const Success = Template.bind({});
64+
Success.args = {
65+
children: 'Tag name or content',
66+
theme: 'success',
67+
};
68+
69+
export const Note = Template.bind({});
70+
Note.args = {
71+
children: 'Tag name or content',
72+
theme: 'note',
73+
};
74+
75+
export const Disabled = Template.bind({});
76+
Disabled.args = {
77+
children: 'Tag name or content',
78+
theme: 'disabled',
79+
};
80+
81+
export const Special = Template.bind({});
82+
Special.args = {
83+
children: 'Tag name or content',
84+
theme: 'special',
5785
};
5886

5987
export const WithIcon = Template.bind({});
6088
WithIcon.args = {
89+
children: 'Tag name or content',
6190
icon: <DollarCircleOutlined />,
6291
label: 'Tag name or content',
6392
};
6493

6594
export const Closable = Template.bind({});
6695
Closable.args = {
96+
children: 'Tag name or content',
6797
label: 'Tag name or content',
6898
isClosable: true,
6999
};

src/components/content/Tag/Tag.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ const CloseAction = tasty(Action, {
8989
});
9090

9191
export interface CubeTagProps extends BaseProps, ContainerStyleProps {
92+
/* @deprecated Use theme instead */
9293
type?: keyof typeof THEMES | string;
94+
theme?: keyof typeof THEMES | string;
9395
isClosable?: boolean;
9496
onClose?: () => void;
9597
closeButtonStyles?: Styles;
@@ -99,11 +101,13 @@ export interface CubeTagProps extends BaseProps, ContainerStyleProps {
99101
function Tag(allProps: CubeTagProps, ref) {
100102
let {
101103
type,
104+
theme,
102105
icon,
103106
isClosable,
104107
onClose,
105108
closeButtonStyles,
106109
children,
110+
mods,
107111
...props
108112
} = allProps;
109113

@@ -114,8 +118,8 @@ function Tag(allProps: CubeTagProps, ref) {
114118
{...filterBaseProps(props, { eventProps: true })}
115119
ref={ref}
116120
styles={styles}
117-
data-type={type}
118-
mods={{ closable: isClosable }}
121+
data-type={theme ?? type}
122+
mods={{ ...mods, closable: isClosable }}
119123
>
120124
{icon ? <div data-element="TagIcon">{icon}</div> : null}
121125
<div data-element="Content">{children}</div>

src/components/layout/Panel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ function Panel(props: CubePanelProps, ref: ForwardedRef<HTMLDivElement>) {
123123
STYLES.forEach((style) => {
124124
if (props[style]) {
125125
innerStyles = { ...innerStyles, [style]: props[style] };
126+
127+
delete otherProps[style];
126128
}
127129
});
128130

src/data/themes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export default {
2+
special: {
3+
fill: '#purple',
4+
color: '#white',
5+
border: '#purple',
6+
},
27
success: {
38
fill: '#success-bg',
49
color: '#success-text',

src/tokens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const colors = {
2424
success: '49 195 124',
2525
'success-text': '48 166 102',
2626
note: '251 188 5',
27+
'note-text': '169 125 0',
2728
warning: '224 86 43',
2829
};
2930

@@ -55,7 +56,6 @@ const TOKENS = {
5556
'minor-color': color('dark', 0.65),
5657
'success-bg-color': 'rgb(41 190 110 / .1)',
5758
'note-bg-color': color('note', 0.1),
58-
'note-text-color': color('note', 1),
5959
'danger-bg-color': color('danger', 0.05),
6060
'danger-bg-hover-color': color('danger', 0.1),
6161
'primary-1': color('purple', 0.9),

0 commit comments

Comments
 (0)