Skip to content

Commit bb323c0

Browse files
tassoevanggazzo
authored andcommitted
feat: Design tokens (#55)
* Add typography tokens * Add spacing tokens * Add text color tokens * Add borders and transitions tokens * Revert text color tokens * Unify theme module * Drop tokens- and theme-related stories
1 parent 5bf6d0f commit bb323c0

26 files changed

+150
-354
lines changed

packages/fuselage/.storybook/jest-results.json

+1-1
Large diffs are not rendered by default.

packages/fuselage/src/components/Button/theme.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { createTheme } from '../../helpers/createTheme';
2-
import dimensions from '../../theme/dimensions';
3-
import typography from '../../theme/typography';
2+
import theme from '../../styles/theme';
43
import colors from '../../tokens/colors';
54

65
export default createTheme('rcx-button', {
7-
borderWidth: dimensions.borderWidth,
8-
borderRadius: dimensions.borderRadius,
9-
fontFamily: typography.baseFont,
6+
borderWidth: theme.borders.default.width,
7+
borderRadius: theme.borders.default.radius,
8+
fontFamily: theme.typography.p1.fontFamily,
109
fontWeight: 500,
1110
height: '2.5rem',
1211
paddingVertical: '0.5rem',

packages/fuselage/src/components/CheckBox/theme.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { createTheme } from '../../helpers/createTheme';
2-
import dimensions from '../../theme/dimensions';
2+
import theme from '../../styles/theme';
33
import colors from '../../tokens/colors';
4-
import typography from '../../theme/typography';
54

65
export default createTheme('rcx-check-box', {
7-
size: dimensions.inputLineHeight,
8-
borderWidth: dimensions.borderWidth,
9-
borderRadius: dimensions.borderRadius,
6+
size: theme.typography.p1.lineHeight,
7+
borderWidth: theme.borders.default.width,
8+
borderRadius: theme.borders.default.radius,
109
labelColor: colors.dark800,
11-
labelFontFamily: typography.baseFont,
10+
labelFontFamily: theme.typography.p1.fontFamily,
1211
labelFontSize: '0.875rem',
1312
labelFontWeight: '400',
14-
labelLineHeight: dimensions.inputLineHeight,
13+
labelLineHeight: theme.typography.p1.lineHeight,
1514
color: colors.white,
1615
borderColor: colors.dark400,
1716
hoverBorderColor: colors.dark500,
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { createTheme } from '../../helpers/createTheme';
22
import colors from '../../tokens/colors';
3-
import typography from '../../theme/typography';
3+
import theme from '../../styles/theme';
44

55

66
export default createTheme('rcx-field', {
77
labelMargin: '0 0 0.5rem 0',
88
labelColor: colors.dark800,
9-
labelFontFamily: typography.baseFont,
9+
labelFontFamily: theme.typography.p1.fontFamily,
1010
labelFontSize: '0.875rem',
1111
labelFontWeight: 'normal',
1212
labelLineHeight: '1.25rem',
@@ -15,7 +15,7 @@ export default createTheme('rcx-field', {
1515
helpMargin: '0.25rem 0 0 0',
1616
helpColor: colors.dark600,
1717
helpFontSize: '0.875rem',
18-
helpFontFamily: typography.baseFont,
18+
helpFontFamily: theme.typography.p1.fontFamily,
1919
helpFontWeight: 'normal',
2020
helpLineHeight: '1.25rem',
2121
});

packages/fuselage/src/components/Input/theme.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { createTheme } from '../../helpers/createTheme';
22
import colors from '../../tokens/colors';
3-
import dimensions from '../../theme/dimensions';
4-
import typography from '../../theme/typography';
3+
import theme from '../../styles/theme';
54

65

76
export default createTheme('rcx-input', {
87
padding: '0.625rem 0.875rem',
9-
borderWidth: dimensions.borderWidth,
10-
borderRadius: dimensions.borderRadius,
8+
borderWidth: theme.borders.default.width,
9+
borderRadius: theme.borders.default.radius,
1110
color: colors.dark800,
1211
iconColor: colors.dark800,
1312
placeholderColor: colors.dark600,
@@ -25,7 +24,7 @@ export default createTheme('rcx-input', {
2524
disabledBorderColor: colors.dark500,
2625
disabledColor: colors.dark800,
2726
disabledIconColor: colors.dark500,
28-
fontFamily: typography.baseFont,
27+
fontFamily: theme.typography.p1.fontFamily,
2928
fontSize: '0.875rem',
3029
fontWeight: '500',
3130
lineHeight: '1.25rem',
@@ -38,7 +37,7 @@ export default createTheme('rcx-input', {
3837
iconMarginVertical: '0.75rem',
3938
labelMargin: '0 0 0.5rem 0',
4039
labelColor: colors.dark800,
41-
labelFontFamily: typography.baseFont,
40+
labelFontFamily: theme.typography.p1.fontFamily,
4241
labelFontSize: '0.875rem',
4342
labelFontWeight: 'normal',
4443
labelLineHeight: '1.25rem',
@@ -47,7 +46,7 @@ export default createTheme('rcx-input', {
4746
helpMargin: '0.25rem 0 0 0',
4847
helpColor: colors.dark600,
4948
helpFontSize: '0.875rem',
50-
helpFontFamily: typography.baseFont,
49+
helpFontFamily: theme.typography.p1.fontFamily,
5150
helpFontWeight: 'normal',
5251
helpLineHeight: '1.25rem',
5352
});

packages/fuselage/src/components/RadioButton/theme.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { createTheme } from '../../helpers/createTheme';
22
import colors from '../../tokens/colors';
3-
import dimensions from '../../theme/dimensions';
4-
import typography from '../../theme/typography';
3+
import theme from '../../styles/theme';
54

65
export default createTheme('rcx-radio-button', {
7-
size: dimensions.inputLineHeight,
8-
borderWidth: dimensions.borderWidth,
6+
size: theme.typography.p1.lineHeight,
7+
borderWidth: theme.borders.default.width,
98
borderRadius: '50%',
109
labelColor: colors.dark800,
11-
labelFontFamily: typography.baseFont,
10+
labelFontFamily: theme.typography.p1.fontFamily,
1211
labelFontSize: '0.875rem',
1312
labelFontWeight: '400',
14-
labelLineHeight: dimensions.inputLineHeight,
13+
labelLineHeight: theme.typography.p1.lineHeight,
1514
color: colors.white,
1615
borderColor: colors.dark400,
1716
hoverBorderColor: colors.dark500,

packages/fuselage/src/components/ToggleSwitch/theme.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { createTheme } from '../../helpers/createTheme';
2-
import dimensions from '../../theme/dimensions';
2+
import theme from '../../styles/theme';
33
import colors from '../../tokens/colors';
44

55

66
export default createTheme('rcx-toggle-switch', {
77
trackWidth: '2.5rem',
8-
trackHeight: dimensions.inputLineHeight,
9-
thumbSize: `calc(${ dimensions.inputLineHeight } - 2 * ${ dimensions.borderWidth })`,
10-
borderWidth: dimensions.borderWidth,
8+
trackHeight: theme.typography.p1.lineHeight,
9+
thumbSize: `calc(${ theme.typography.p1.lineHeight } - 2 * ${ theme.borders.default.width })`,
10+
borderWidth: theme.borders.default.width,
1111
borderRadius: '9999px',
1212
color: colors.white,
1313
backgroundColor: colors.dark400,

packages/fuselage/src/mixins/reset.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { css } from 'styled-components';
22

3-
import dimensions from '../theme/dimensions';
3+
import dimensions from '../styles/theme';
44

55

66
export const reset = css`
@@ -11,7 +11,7 @@ export const reset = css`
1111
font-weight: normal;
1212
appearance: none;
1313
list-style: none;
14-
transition: all ${ dimensions.shortTransitionDuration };
14+
transition: all ${ dimensions.transitions.shortDuration };
1515
outline: none;
1616
1717
&[hidden] {

packages/fuselage/src/mixins/withText.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { css } from 'styled-components';
22

3-
import typography from '../theme/typography';
3+
import theme from '../styles/theme';
44

55
export const withText = css`
6-
font-family: ${ ({ fontName = 'base' }) => typography[`${ fontName }Font`] };
6+
font-family: ${ theme.typography.p1.fontFamily };
77
font-weight: 400;
88
font-variant-numeric: tabular-nums;
99
text-decoration: none;

packages/fuselage/src/styles/colorPalette.stories.js

-63
This file was deleted.

packages/fuselage/src/styles/dimensions.stories.js

-36
This file was deleted.

packages/fuselage/src/styles/exports.scss

-18
This file was deleted.

packages/fuselage/src/styles/stories.js

-95
This file was deleted.

0 commit comments

Comments
 (0)