Skip to content

Commit 76bcdd2

Browse files
author
Martí Malek
committed
feat(tag): use css variables in variants
1 parent b011ab0 commit 76bcdd2

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/components/Tag/Tag.spec.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render, fireEvent, screen } from '@testing-library/react';
22
import * as React from 'react';
33
import { Tag } from './Tag';
4-
import { SemanticColors } from '../../essentials';
4+
import { getSemanticValue } from '../../utils/cssVariables';
55

66
describe('Tag', () => {
77
it('renders and can be dismissed', () => {
@@ -28,28 +28,28 @@ describe('Tag', () => {
2828
const { container } = render(<Tag variant="disabled">Lorem</Tag>);
2929

3030
expect(container.firstChild).toHaveStyle(`
31-
border-color: ${SemanticColors.border.primary};
31+
border-color: ${getSemanticValue('border-disabled')};
3232
`);
3333
expect(screen.getByText('Lorem')).toHaveStyle(`
34-
color: ${SemanticColors.text.disabled};
34+
color: ${getSemanticValue('foreground-disabled')};
3535
`);
3636
expect(screen.getByTestId('dismiss-icon')).toHaveStyle(`
37-
color: ${SemanticColors.icon.disabled};
37+
color: ${getSemanticValue('foreground-disabled')};
3838
`);
3939
});
4040

4141
it('renders error variant', () => {
4242
const { container } = render(<Tag variant="error">Lorem</Tag>);
4343

4444
expect(container.firstChild).toHaveStyle(`
45-
background-color: ${SemanticColors.background.danger};
46-
border-color: ${SemanticColors.border.dangerEmphasized};
45+
background-color: ${getSemanticValue('background-surface-danger-default')};
46+
border-color: ${getSemanticValue('border-danger-default')};
4747
`);
4848
expect(screen.getByText('Lorem')).toHaveStyle(`
49-
color: ${SemanticColors.text.dangerInverted};
49+
color: ${getSemanticValue('foreground-danger-default')};
5050
`);
5151
expect(screen.getByTestId('dismiss-icon')).toHaveStyle(`
52-
color: ${SemanticColors.icon.danger};
52+
color: ${getSemanticValue('foreground-danger-default')};
5353
`);
5454
});
5555
});

src/components/Tag/Tag.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ const tagVariant = variant({
5050
borderColor: getSemanticValue('border-info-default'),
5151

5252
[`> ${TagText}`]: {
53-
color: get('semanticColors.text.link')
53+
color: getSemanticValue('foreground-info-default')
5454
},
5555

5656
[`> ${DismissIcon}`]: {
57-
color: get('semanticColors.icon.action')
57+
color: getSemanticValue('foreground-info-default')
5858
},
5959

6060
'&:hover': {
6161
backgroundColor: getSemanticValue('background-element-info-emphasized'),
62-
borderColor: get('semanticColors.border.infoEmphasized'),
62+
borderColor: getSemanticValue('border-info-default'),
6363

6464
[`> ${TagText}`]: {
6565
color: getSemanticValue('foreground-on-background-info')
@@ -71,38 +71,38 @@ const tagVariant = variant({
7171
}
7272
},
7373
disabled: {
74-
borderColor: get('semanticColors.border.primary'),
74+
borderColor: getSemanticValue('border-disabled'),
7575

7676
[`> ${TagText}`]: {
77-
color: get('semanticColors.text.disabled')
77+
color: getSemanticValue('foreground-disabled')
7878
},
7979

8080
[`> ${DismissIcon}`]: {
81-
color: get('semanticColors.icon.disabled')
81+
color: getSemanticValue('foreground-disabled')
8282
}
8383
},
8484
error: {
85-
backgroundColor: get('semanticColors.background.danger'),
86-
borderColor: get('semanticColors.border.dangerEmphasized'),
85+
backgroundColor: getSemanticValue('background-surface-danger-default'),
86+
borderColor: getSemanticValue('border-danger-default'),
8787

8888
[`> ${TagText}`]: {
89-
color: get('semanticColors.text.dangerInverted')
89+
color: getSemanticValue('foreground-danger-default')
9090
},
9191

9292
[`> ${DismissIcon}`]: {
93-
color: get('semanticColors.icon.danger')
93+
color: getSemanticValue('foreground-danger-default')
9494
},
9595

9696
'&:hover': {
97-
backgroundColor: get('semanticColors.background.dangerEmphasized'),
98-
borderColor: get('semanticColors.border.dangerEmphasized'),
97+
backgroundColor: getSemanticValue('background-surface-danger-emphasized'),
98+
borderColor: getSemanticValue('border-danger-default'),
9999

100100
[`> ${TagText}`]: {
101-
color: get('semanticColors.text.primaryInverted')
101+
color: getSemanticValue('foreground-on-background-danger')
102102
},
103103

104104
[`> ${DismissIcon}`]: {
105-
color: get('semanticColors.icon.primaryInverted')
105+
color: getSemanticValue('foreground-on-background-danger')
106106
}
107107
}
108108
}
@@ -144,4 +144,4 @@ const Tag: FC<PropsWithChildren<TagProps>> = ({
144144
</TagWrapper>
145145
);
146146

147-
export { Tag, TagProps };
147+
export { Tag, TagProps };

0 commit comments

Comments
 (0)