Skip to content

Commit 37c9df5

Browse files
author
Rasid Redzic
committed
feat(accordion): migrate to semantic colors
1 parent fb6b7e1 commit 37c9df5

File tree

9 files changed

+45
-30
lines changed

9 files changed

+45
-30
lines changed

src/components/Accordion/Accordion.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React, { PropsWithChildren } from 'react';
22
import styled from 'styled-components';
3-
4-
import { SemanticColors } from '../../essentials';
53
import { Box } from '../Box/Box';
64
import { Compact } from './components/Compact';
75
import { DefaultPanel } from './components/Default';
86
import { AccordionProps } from './types';
7+
import { getSemanticValue } from '../../utils/cssVariables';
98

109
const HorizontalDivider = styled(Box)`
1110
border: 0;
12-
border-top: solid 0.0625rem ${SemanticColors.border.primary};
11+
border-top: solid 0.0625rem ${getSemanticValue('border-primary-default')};
1312
`;
1413

1514
const HorizontalDividerTop = HorizontalDivider;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components';
22
import { ChevronDownIcon } from '../../../icons';
3-
import { SemanticColors } from '../../../essentials';
3+
import { getSemanticValue } from '../../../utils/cssVariables';
44

55
export const ChevronDown = styled(ChevronDownIcon)`
6-
color: ${props => (props.color ? props.color : SemanticColors.icon.primary)};
6+
color: ${props => (props.color ? props.color : getSemanticValue('overrides-accordion-icon-primary-default'))};
77
`;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import styled from 'styled-components';
22
import { ChevronUpIcon } from '../../../icons';
3-
import { SemanticColors } from '../../../essentials';
3+
import { getSemanticValue } from '../../../utils/cssVariables';
44

55
export const ChevronUp = styled(ChevronUpIcon)`
6-
color: ${props => (props.color ? props.color : SemanticColors.icon.primary)};
6+
color: ${props => (props.color ? props.color : getSemanticValue('overrides-accordion-icon-primary-default'))};
77
`;

src/components/Accordion/components/Compact.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import React, { useState, ReactElement } from 'react';
1+
import React, { ReactElement, useState } from 'react';
22
import styled from 'styled-components';
3-
4-
import { SemanticColors } from '../../../essentials';
53
import { Box } from '../../Box/Box';
64
import { Headline } from '../../Headline/Headline';
75
import { Header } from './Header';
86
import { ChevronUp } from './ChevronUp';
97
import { ChevronDown } from './ChevronDown';
108
import { Description } from './Description';
119
import { AccordionProps } from '../types';
10+
import { getSemanticValue } from '../../../utils/cssVariables';
1211

1312
type Props = Pick<
1413
AccordionProps,
@@ -19,15 +18,15 @@ const StyleHeadline = styled(Headline)``;
1918

2019
const PanelHeader = styled(Header)`
2120
&:hover ${StyleHeadline} {
22-
color: ${SemanticColors.text.linkHover};
21+
color: ${getSemanticValue('text-linkHover')};
2322
}
2423
2524
&:hover ${ChevronDown} {
26-
color: ${SemanticColors.text.linkHover};
25+
color: ${getSemanticValue('text-linkHover')};
2726
}
2827
2928
&:hover ${ChevronUp} {
30-
color: ${SemanticColors.text.linkHover};
29+
color: ${getSemanticValue('text-linkHover')};
3130
}
3231
`;
3332

src/components/Accordion/components/Default.tsx

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import React, { useState, PropsWithChildren, ReactElement } from 'react';
1+
import React, { PropsWithChildren, ReactElement, useState } from 'react';
22
import styled from 'styled-components';
3-
4-
import { SemanticColors } from '../../../essentials';
53
import { Text } from '../../Text/Text';
64
import { Box } from '../../Box/Box';
75
import { Headline } from '../../Headline/Headline';
@@ -10,49 +8,54 @@ import { ChevronUp } from './ChevronUp';
108
import { ChevronDown } from './ChevronDown';
119
import { Description } from './Description';
1210
import { AccordionProps } from '../types';
11+
import { getSemanticValue } from '../../../utils/cssVariables';
1312

1413
const ButtonLabel = styled(Text).attrs({ as: 'p' })`
15-
color: ${SemanticColors.text.link};
14+
color: ${getSemanticValue('text-link')};
1615
`;
1716

1817
const PanelHeader = styled(Header)`
1918
&:hover {
20-
background-color: ${SemanticColors.background.info};
19+
background-color: ${getSemanticValue('background-info-default')};
2120
}
2221
2322
&:hover ${ButtonLabel} {
24-
color: ${SemanticColors.text.linkHover};
23+
color: ${getSemanticValue('text-linkHover')};
2524
}
2625
2726
&:hover ${ChevronDown} {
28-
color: ${SemanticColors.text.linkHover};
27+
color: ${getSemanticValue('text-linkHover')};
2928
}
3029
`;
3130

3231
const CardHeader = styled(Header).attrs({ p: '3' })`
33-
background-color: ${SemanticColors.background.secondary};
32+
background-color: ${getSemanticValue('background-secondary-default')};
3433
border-radius: 0.3125rem 0.3125rem 0 0;
3534
3635
&:hover {
37-
background-color: ${SemanticColors.background.info};
36+
background-color: ${getSemanticValue('background-info-default')};
3837
}
3938
4039
&:hover ${ButtonLabel} {
41-
color: ${SemanticColors.text.linkHover};
40+
color: ${getSemanticValue('text-linkHover')};
4241
}
4342
4443
&:hover ${ChevronUp} {
45-
color: ${SemanticColors.text.linkHover};
44+
color: ${getSemanticValue('text-linkHover')};
4645
}
4746
`;
4847

4948
const PanelBody = styled(Box).attrs({ my: '3' })`
50-
border: solid 0.0625rem ${SemanticColors.border.primary};
49+
border: solid 0.0625rem ${getSemanticValue('border-primary-default')};
5150
border-radius: 0.3125rem;
5251
`;
5352

5453
const PanelIcon = ({ isOpen }: { isOpen: boolean }) =>
55-
isOpen ? <ChevronUp color={SemanticColors.icon.action} /> : <ChevronDown color={SemanticColors.icon.action} />;
54+
isOpen ? (
55+
<ChevronUp color={getSemanticValue('icon-action-default')} />
56+
) : (
57+
<ChevronDown color={getSemanticValue('icon-action-default')} />
58+
);
5659

5760
export const DefaultPanel = ({
5861
heading,

src/components/Accordion/components/Header.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import styled from 'styled-components';
2-
3-
import { SemanticColors } from '../../../essentials';
42
import { Box } from '../../Box/Box';
3+
import { getSemanticValue } from '../../../utils/cssVariables';
54

6-
export const Header = styled(Box).attrs({ p: '2', color: SemanticColors.text.primary })`
5+
export const Header = styled(Box).attrs({ p: '2', color: getSemanticValue('text-primary') })`
76
display: flex;
87
flex-direction: row;
98
justify-content: space-between;

src/essentials/Colors/Colors.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,14 @@ export const SemanticColors = {
189189
emphasized: Colors.blue.primary[550]
190190
},
191191
info: {
192-
emphasized: Colors.blue.secondary[900],
192+
emphasized: Colors.blue.secondary[900]
193+
}
194+
}
195+
},
196+
accordion: {
197+
icon: {
198+
primary: {
199+
default: Colors.blue.secondary[900]
193200
}
194201
}
195202
}

src/essentials/Colors/RedesignedColors.ts

+7
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,13 @@ export const SemanticColors = {
190190
emphasized: Colors.blue.primary[900]
191191
}
192192
}
193+
},
194+
accordion: {
195+
icon: {
196+
primary: {
197+
default: Colors.blue.secondary[900]
198+
}
199+
}
193200
}
194201
}
195202
} satisfies SemanticColorsSchema;

src/essentials/Colors/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface SemanticColorsSchema {
2727
},
2828
overrides: {
2929
label: Object.Partial<SemanticColorsSchema, 'deep'>,
30+
accordion: Object.Partial<SemanticColorsSchema, 'deep'>,
3031
},
3132
background: {
3233
primary: {

0 commit comments

Comments
 (0)