Skip to content

Commit f81322e

Browse files
committed
feat(toggle): migrate to semantic colors
1 parent 5b2e16c commit f81322e

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

src/components/Toggle/Slide.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import styled from 'styled-components';
2-
import { SemanticColors } from '../../essentials';
2+
import { getSemanticValue } from '../../utils/cssVariables';
33

44
const determineBackground = (props: SlideProps) => {
55
if (props.disabled) {
6-
return SemanticColors.background.secondary;
6+
return getSemanticValue('background-secondary-default');
77
}
88

99
if (props.error) {
10-
return SemanticColors.background.dangerEmphasized;
10+
return getSemanticValue('background-danger-emphasized');
1111
}
1212

13-
return SemanticColors.background.infoEmphasized;
13+
return getSemanticValue('background-highlight');
1414
};
1515

1616
interface SlideProps {
1717
disabled?: boolean;
1818
error?: boolean;
1919
}
2020

21-
// TODO use SemanticColors.forms once https://github.com/freenowtech/wave/issues/286 is done
2221
const Slide = styled.div<SlideProps>`
2322
width: 2.25rem;
2423
height: 1rem;
2524
2625
cursor: ${props => (props.disabled ? 'not-allowed' : 'pointer')};
27-
background: ${props => (props.disabled ? SemanticColors.background.secondary : SemanticColors.border.primary)};
26+
background: ${props =>
27+
getSemanticValue(props.disabled ? 'background-tertiary-disabled' : 'background-tertiary-default')};
2828
display: inline-block;
2929
border-radius: 0.5rem;
3030
position: relative;
@@ -38,7 +38,7 @@ const Slide = styled.div<SlideProps>`
3838
width: 1.25rem;
3939
height: 1.25rem;
4040
background: ${props =>
41-
props.disabled ? SemanticColors.background.secondary : SemanticColors.background.primary};
41+
getSemanticValue(props.disabled ? 'background-tertiary-disabled' : 'background-primary-default')};
4242
border-radius: 50%;
4343
box-shadow: 0 0 0.0625rem 0 rgba(0, 0, 0, 0.05), 0 0.0625rem 0.1875rem 0 rgba(0, 0, 0, 0.4);
4444
transform: translateX(0);

src/components/Toggle/docs/Toggle.stories.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@ export const WithLabel: Story = {
3939
label: 'Turn on the light'
4040
}
4141
};
42+
43+
export const Disabled: Story = {
44+
args: {
45+
disabled: true
46+
}
47+
}

src/essentials/Colors/Colors.ts

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export const SemanticColors = {
8787
default: Colors.blue.primary[50],
8888
emphasized: Colors.blue.primary[550],
8989
},
90+
tertiary: {
91+
default:Colors.blue.primary[200],
92+
disabled: Colors.blue.primary[50],
93+
},
9094
danger: {
9195
default: Colors.orange[50],
9296
emphasized: Colors.orange[900],
@@ -105,6 +109,7 @@ export const SemanticColors = {
105109
default: Colors.yellow[50],
106110
emphasized: Colors.yellow[900],
107111
},
112+
highlight: Colors.blue.secondary[900],
108113
transparent: Colors.transparent,
109114
},
110115
icon: {

src/essentials/Colors/RedesignedColors.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export const SemanticColors = {
8585
default: Colors.blue.primary[50],
8686
emphasized: Colors.blue.primary[550],
8787
},
88+
tertiary: {
89+
default:Colors.blue.primary[200],
90+
disabled: Colors.blue.primary[50],
91+
},
8892
danger: {
8993
default: Colors.orange[50],
9094
emphasized: Colors.orange[900],
@@ -103,6 +107,7 @@ export const SemanticColors = {
103107
default: Colors.yellow[50],
104108
emphasized: Colors.yellow[900],
105109
},
110+
highlight: Colors.red[900],
106111
transparent: Colors.transparent,
107112
},
108113
icon: {
@@ -167,7 +172,7 @@ export const SemanticColors = {
167172
},
168173
danger: {
169174
default: Colors.orange[350],
170-
emphasized: Colors.orange[900],
175+
emphasized: Colors.red[900],
171176
disabled: Colors.orange[350],
172177
},
173178
transparent: Colors.transparent,

src/essentials/Colors/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export interface SemanticColorsSchema {
3737
default: Color,
3838
emphasized: Color,
3939
},
40+
tertiary: {
41+
default:Color,
42+
disabled: Color,
43+
},
4044
danger: {
4145
default: Color,
4246
emphasized: Color,
@@ -55,6 +59,7 @@ export interface SemanticColorsSchema {
5559
default: Color,
5660
emphasized: Color,
5761
},
62+
highlight: Color,
5863
transparent: 'transparent',
5964
},
6065
icon: {

0 commit comments

Comments
 (0)