Skip to content

Commit 5363293

Browse files
committed
chore: initialize tokens for belonging
Signed-off-by: Paul-Xavier Ceccaldi <[email protected]> Signed-off-by: Camille Nairi<[email protected]>
1 parent a2e7566 commit 5363293

File tree

20 files changed

+7502
-963
lines changed

20 files changed

+7502
-963
lines changed

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"start": "vite build --watch",
3030
"build": "vite build",
3131
"build:tokens": "style-dictionary build --config=style-dictionary.json --verbose",
32-
"theme:generate": "yarn build:tokens && tsx src/theme/generate-theme.ts && yarn run -W prettier --write 'src/theme/theme.css'",
32+
"theme:generate": "tsx src/theme/generate-theme.ts && yarn run -W prettier --write 'src/theme/theme.css'",
3333
"test": "vitest"
3434
},
3535
"repository": {

lib/src/theme/fontFaces.css

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,45 +137,45 @@
137137

138138
@font-face {
139139
font-family: welcome-font;
140-
font-weight: 400;
140+
font-weight: 500;
141141
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-regular.woff2') format('woff2');
142142
}
143143

144144
@font-face {
145145
font-family: welcome-font;
146-
font-weight: 400;
146+
font-weight: 500;
147147
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-regular.woff2') format('woff2');
148148
}
149149

150150
@font-face {
151151
font-family: welcome-font;
152-
font-weight: 500;
152+
font-weight: 700;
153153
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-medium.woff2') format('woff2');
154154
}
155155

156156
@font-face {
157157
font-family: welcome-font;
158-
font-weight: 600;
158+
font-weight: 900;
159159
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-bold.woff2') format('woff2');
160160
}
161161

162162
@font-face {
163163
font-family: welcome-font;
164164
font-style: italic;
165-
font-weight: 400;
165+
font-weight: 500;
166166
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-regular-italic.woff2') format('woff2');
167167
}
168168

169169
@font-face {
170170
font-family: welcome-font;
171171
font-style: italic;
172-
font-weight: 500;
172+
font-weight: 700;
173173
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-medium-italic.woff2') format('woff2');
174174
}
175175

176176
@font-face {
177177
font-family: welcome-font;
178178
font-style: italic;
179-
font-weight: 600;
179+
font-weight: 900;
180180
src: url('https://cdn.welcome-ui.com/fonts/welcome-font-bold-italic.woff2') format('woff2');
181181
}

lib/src/theme/generate-theme.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,32 @@ import fs from 'fs'
22
import path from 'path'
33
import { fileURLToPath } from 'url'
44

5-
import tokens from './tokens.json' assert { type: 'json' }
5+
import primitives from './tokens/primitives.json' assert { type: 'json' }
66

7-
const indentation = ' ' // 2 spaces for indentation
87
const __filename = fileURLToPath(import.meta.url)
98
const __dirname = path.dirname(__filename)
109

1110
const fontFacesPath = path.join(__dirname, 'fontFaces.css')
1211
const basePath = path.join(__dirname, 'base.css')
1312
const resetPath = path.join(__dirname, 'resets.css')
1413
const themePath = path.join(__dirname, 'theme.css')
14+
const techTokensPath = path.join(__dirname, 'techTokens.css')
1515
const variablesPath = path.join(__dirname, 'variables.css')
1616
const breakpointsPath = path.join(__dirname, 'utils', 'breakpoints.scss')
1717

1818
const fontFaces = fs.readFileSync(fontFacesPath, 'utf8')
1919
const baseStyles = fs.readFileSync(basePath, 'utf8')
20+
const techTokens = fs.readFileSync(techTokensPath, 'utf8')
2021
const resetStyles = fs.readFileSync(resetPath, 'utf8')
2122
const variableStyles = fs.readFileSync(variablesPath, 'utf8')
2223

2324
const getStringFrom = (map: Record<string, string>) => `${map.property} {\n${map.value}}\n`
2425

25-
const addedVariables = '--spacing: 0.0625rem;'
26-
const resetTailwindTokens = `${indentation}--*: initial;\n`
26+
const stringifiedTechTokens = `${techTokens}`
27+
2728
const variablesStylesWithTailwindResets = variableStyles.replace(
2829
'@theme static {\n',
29-
`@theme static {\n${resetTailwindTokens}\n${addedVariables}`
30+
`@theme static {\n${stringifiedTechTokens}`
3031
)
3132

3233
const baseLayer = { property: '@layer base', value: `${resetStyles}\n${baseStyles}` }
@@ -38,9 +39,9 @@ const generateThemeCss = () =>
3839
fs.writeFileSync(themePath, generateThemeCss(), 'utf8')
3940

4041
// Generate scss breakpoints file
41-
const breakpointsContent = Object.entries(tokens.breakpoint).reduce((acc, [key, value]) => {
42-
if (key !== '$type' && typeof value === 'object' && '$value' in value) {
43-
return acc + `$breakpoint-${key}: ${value['$value']};\n`
42+
const breakpointsContent = Object.entries(primitives.breakpoints).reduce((acc, [key, value]) => {
43+
if (key !== '$type' && typeof value === 'object' && 'value' in value) {
44+
return acc + `$breakpoint-${key}: ${value['value']};\n`
4445
}
4546
return acc
4647
}, '/* screens - auto-generated from token.ts - do not edit directly */\n')

lib/src/theme/techTokens.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--*: initial;
2+
--spacing: 0.0625rem;
3+
--spacing-0: 0;
4+
--spacing-2: 0.125rem;
5+
--spacing-3: 0.1875rem;
6+
--spacing-4: 0.25rem;
7+
--spacing-8: 0.5rem;
8+
--spacing-12: 0.75rem;
9+
--spacing-16: 1rem;
10+
--spacing-24: 1.5rem;
11+
--spacing-28: 1.75rem;
12+
--spacing-32: 2rem;
13+
--spacing-36: 2.25rem;
14+
--spacing-48: 3rem;
15+
--spacing-64: 4rem;
16+
--spacing-96: 6rem;
17+
--spacing-128: 8rem;
18+
--spacing-192: 12rem;
19+
--font-size-11: 0.6875rem;
20+
--font-size-12: 0.75rem;
21+
--font-size-13: 0.8125rem;
22+
--font-size-14: 0.875rem;
23+
--font-size-16: 1rem;
24+
--font-size-18: 1.125rem;
25+
--font-size-20: 1.25rem;
26+
--font-size-24: 1.5rem;
27+
--font-size-26: 1.625rem;
28+
--font-size-36: 2.25rem;
29+
--font-size-45: 2.8125rem;
30+
--font-size-65: 4.0625rem;

0 commit comments

Comments
 (0)