Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SCSS variables from Figma tokens #1445

Open
wants to merge 272 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
272 commits
Select commit Hold shift + click to select a range
51b87eb
Update build-figma-tokens.js
vern-gora Oct 24, 2024
ac4d164
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
acafd25
add red
vern-gora Oct 24, 2024
9402216
.js -> .mjs
vern-gora Oct 24, 2024
aad6284
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
15a7467
add green
vern-gora Oct 24, 2024
19929e1
Update build-figma-tokens.mjs
vern-gora Oct 24, 2024
37f32bb
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
2891751
del green
vern-gora Oct 24, 2024
5441d5f
Update build-figma-tokens.mjs
vern-gora Oct 24, 2024
3001195
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
f2479a1
add green
vern-gora Oct 24, 2024
ca4f0db
.mjs -> .js
vern-gora Oct 24, 2024
d304b1a
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
f74ebab
del green
vern-gora Oct 24, 2024
fb6c201
add 1 more step, convert JSON to SCSS
vern-gora Oct 24, 2024
94be4c1
add green
vern-gora Oct 24, 2024
8a0cf49
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
79b1533
add azure
vern-gora Oct 24, 2024
1f2d0d2
Update build-figma-tokens.yml
vern-gora Oct 24, 2024
c388faf
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 24, 2024
4ab76a0
del azure
vern-gora Oct 24, 2024
3efb522
add azure
vern-gora Oct 24, 2024
7278499
Update build-figma-tokens.yml
vern-gora Oct 27, 2024
e0d9c1e
del color
vern-gora Oct 28, 2024
44e59ad
add azure
vern-gora Oct 28, 2024
8491b14
Update build-figma-tokens.yml
vern-gora Oct 28, 2024
cf5588a
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
689c90d
del black
vern-gora Oct 28, 2024
0bb53ca
add black
vern-gora Oct 28, 2024
a3fdaf3
Update build-figma-tokens.yml
vern-gora Oct 28, 2024
e0f08b9
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
4c59159
test
vern-gora Oct 28, 2024
4b44cbc
test
vern-gora Oct 28, 2024
d6efaa3
Update build-figma-tokens.yml
vern-gora Oct 28, 2024
3b9d4d9
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
0cffc37
test
vern-gora Oct 28, 2024
9edd1c9
Update build-figma-tokens.yml
vern-gora Oct 28, 2024
db9be27
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
6b8287b
test
vern-gora Oct 28, 2024
c0cc42e
Update build-figma-tokens.yml
vern-gora Oct 28, 2024
1256e6f
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
b20b258
test
vern-gora Oct 28, 2024
f9852ce
test after closed #1414.
vern-gora Oct 28, 2024
a246e58
Update build-figma-tokens.yml
vern-gora Oct 28, 2024
5329bca
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
a39a55e
the branch update-figma-tokens is not deleted
vern-gora Oct 28, 2024
3b5a0af
change js file
vern-gora Oct 28, 2024
b3d67cb
change js
vern-gora Oct 28, 2024
5d8a5df
change js to mjs
vern-gora Oct 28, 2024
622ccc5
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 28, 2024
4e3d6cc
js to mjs
vern-gora Oct 28, 2024
77ccd85
add config
vern-gora Oct 29, 2024
76be901
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
4215e68
add config
vern-gora Oct 29, 2024
c5362b3
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
579b82f
add config 2
vern-gora Oct 29, 2024
e299e0b
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
95e71bf
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
b6d25a2
add config 3
vern-gora Oct 29, 2024
0a2ccd5
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
4b984aa
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
f6fb12c
add config 4
vern-gora Oct 29, 2024
538f5be
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
b72c9fd
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
6b45e38
change path to config
vern-gora Oct 29, 2024
cf8701a
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
3a8b730
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
2e6c2df
change build-figma-tokens.mjs
vern-gora Oct 29, 2024
6865bce
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
9bf8d63
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
8bf5a8e
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
a95c7e2
Update build-figma-tokens.mjs
vern-gora Oct 29, 2024
d9ff1aa
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
28a0996
change path to config.json
vern-gora Oct 29, 2024
da7f7a5
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 29, 2024
ecc47a9
change path to config.json 2
vern-gora Oct 29, 2024
a698cc7
change gh actions for PR
vern-gora Oct 29, 2024
34c9d49
change yml
vern-gora Oct 30, 2024
34ac1a6
working config
vern-gora Oct 31, 2024
82504b7
first time after working code
vern-gora Oct 31, 2024
aaa813e
Ensure the branch exists before committing
vern-gora Oct 31, 2024
5661c27
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 31, 2024
9b264e4
update gh actions
vern-gora Oct 31, 2024
db9921f
Update build-figma-tokens.yml
vern-gora Oct 31, 2024
34aff95
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 31, 2024
d71de47
update gh actions PR
vern-gora Oct 31, 2024
643774a
Update build-figma-tokens.yml
vern-gora Oct 31, 2024
66427ff
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 31, 2024
a5877ce
gh-actions update
vern-gora Oct 31, 2024
485e024
test
vern-gora Oct 31, 2024
6274a88
Update build-figma-tokens.yml
vern-gora Oct 31, 2024
537a2b3
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 31, 2024
8247725
fix .yml
vern-gora Oct 31, 2024
079a990
Update build-figma-tokens.yml
vern-gora Oct 31, 2024
4eccc37
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 31, 2024
ba459d3
new method of creating new branch update-figma-tokens
vern-gora Oct 31, 2024
01ac836
Update build-figma-tokens.yml
vern-gora Oct 31, 2024
4c19d5a
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Oct 31, 2024
822ae8e
fix
vern-gora Oct 31, 2024
106ed7e
checkout
vern-gora Nov 4, 2024
a00b9a7
add git pull --rebase origin
vern-gora Nov 4, 2024
2d488d1
add git ls-remote
vern-gora Nov 4, 2024
7f11023
change gh actions
vern-gora Nov 4, 2024
7c0d895
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
58be8c3
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
1e07b63
fix
vern-gora Nov 4, 2024
cc7a0c0
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
1dfa06b
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
3786d03
delete user.email and user.name
vern-gora Nov 4, 2024
4e3a0a1
switch black and white
vern-gora Nov 4, 2024
167a52b
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
725a529
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
db36990
Save changes before switching branch
vern-gora Nov 4, 2024
4180c19
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
4fb5085
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
c17c18a
add name and email
vern-gora Nov 4, 2024
138824d
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
f04b340
fix
vern-gora Nov 4, 2024
0c1f63a
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
9e70cac
fix
vern-gora Nov 4, 2024
747a40e
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
ddc45da
fix
vern-gora Nov 4, 2024
7c88e44
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
5ddc6ee
add mkdir
vern-gora Nov 4, 2024
af6268c
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
83aba76
test
vern-gora Nov 4, 2024
1d59bfc
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
25c3611
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
e639f47
test
vern-gora Nov 4, 2024
91ad5fa
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
d3a96bd
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
8aa593d
test
vern-gora Nov 4, 2024
3291aca
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
4301ea9
test
vern-gora Nov 4, 2024
2be7a44
test
vern-gora Nov 4, 2024
58c8a4b
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
f39c548
test
vern-gora Nov 4, 2024
267b1b2
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
4423a5c
test
vern-gora Nov 4, 2024
3224d41
Save changes before switching branch
github-actions[bot] Nov 4, 2024
cc7b3c1
#995 - temporarily disable Chromatic tests
Jura Nov 4, 2024
349d79c
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
Jura Nov 4, 2024
f2b5819
test
vern-gora Nov 4, 2024
9f2db02
Save changes before switching branch
github-actions[bot] Nov 4, 2024
6a0b86e
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
8f3cf21
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 4, 2024
6fab880
Update build-figma-tokens.yml
vern-gora Nov 4, 2024
1e66600
test
vern-gora Nov 5, 2024
d1a2ead
test
vern-gora Nov 5, 2024
f4c0208
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
d83600b
test
vern-gora Nov 5, 2024
6b502d0
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
d7c8649
Update build-figma-tokens.yml
vern-gora Nov 5, 2024
e8b31cc
Save changes in the branch
github-actions[bot] Nov 5, 2024
021e85e
test
vern-gora Nov 5, 2024
cb2a371
Save changes in the branch
github-actions[bot] Nov 5, 2024
b821937
Update build-figma-tokens.yml
vern-gora Nov 5, 2024
932955c
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
89b088d
test
vern-gora Nov 5, 2024
4226c73
test red
vern-gora Nov 5, 2024
5a80c3e
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
cc62f0a
Save changes in the branch
github-actions[bot] Nov 5, 2024
38e59fa
test black
vern-gora Nov 5, 2024
2ab8298
Save changes in the branch
github-actions[bot] Nov 5, 2024
c6a2baa
Update build-figma-tokens.yml
vern-gora Nov 5, 2024
d1e0048
test red
vern-gora Nov 5, 2024
f63a2be
Save changes in the branch
github-actions[bot] Nov 5, 2024
ad3839b
add figma-tokens/transformed-tokens/tokens-transformed.json in gitignore
vern-gora Nov 5, 2024
e065a15
test
vern-gora Nov 5, 2024
c8f60e0
Save changes in the branch
github-actions[bot] Nov 5, 2024
1a85a95
Update build-figma-tokens.yml
vern-gora Nov 5, 2024
3924e48
test
vern-gora Nov 5, 2024
55e4ab4
test
vern-gora Nov 5, 2024
82778e7
test
vern-gora Nov 5, 2024
8d01a49
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
d1a43b3
test
vern-gora Nov 5, 2024
b425eb2
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
4563327
Update build-figma-tokens.yml
vern-gora Nov 5, 2024
096587a
test
vern-gora Nov 5, 2024
5d8d8d0
test
vern-gora Nov 5, 2024
737114e
test
vern-gora Nov 5, 2024
78f46fd
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 5, 2024
bfec8ba
test
vern-gora Nov 6, 2024
c694bc4
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 6, 2024
df30ed1
Update build-figma-tokens.yml
vern-gora Nov 7, 2024
f0126c5
test without fetch
vern-gora Nov 7, 2024
bf6f29c
Merge branch 'issue-995-design-tokens' of https://github.com/undp/des…
vern-gora Nov 7, 2024
7eecb92
Update build-figma-tokens.yml
vern-gora Nov 7, 2024
6ad3995
Update build-figma-tokens.yml
vern-gora Nov 7, 2024
17d3ad4
test
vern-gora Nov 7, 2024
e31cd51
Merge branch 'update-figma-tokens' into issue-995-design-tokens
vern-gora Nov 7, 2024
3f20fdd
test
vern-gora Nov 7, 2024
922f30e
Merge branch 'update-figma-tokens' into issue-995-design-tokens
vern-gora Nov 7, 2024
a210c57
Update build-figma-tokens.yml
vern-gora Nov 7, 2024
7b51501
Update build-figma-tokens.yml
vern-gora Nov 7, 2024
f000f57
Update .gitignore
vern-gora Nov 7, 2024
e14b6fb
test
vern-gora Nov 7, 2024
be74083
Update build-figma-tokens.yml
vern-gora Nov 7, 2024
b9f54f7
Merge branch 'update-figma-tokens' into issue-995-design-tokens
vern-gora Nov 7, 2024
baf8698
Update build-figma-tokens.yml
vern-gora Nov 8, 2024
c5a1ba3
Update build-figma-tokens.yml
vern-gora Nov 8, 2024
06f4ede
Update build-figma-tokens.yml
vern-gora Nov 12, 2024
42a1764
Merge pull request #1444 from undp/issue-995-design-tokens
vern-gora Nov 12, 2024
3ceb425
test
vern-gora Nov 12, 2024
4c53b0c
Save changes in the branch
github-actions[bot] Nov 12, 2024
7bdb9cc
test
vern-gora Nov 12, 2024
da52c0a
Save changes in the branch
github-actions[bot] Nov 12, 2024
64a6204
Update build-figma-tokens.yml
vern-gora Nov 12, 2024
5b5a403
Merge pull request #1447 from undp/issue-995-design-tokens
vern-gora Nov 12, 2024
f6617d2
add yellow
vern-gora Nov 12, 2024
8588ab2
Save changes in the branch
github-actions[bot] Nov 12, 2024
56a151c
del yellow
vern-gora Nov 12, 2024
ab35bc2
Save changes in the branch
github-actions[bot] Nov 12, 2024
08a108a
testing functional tokens
vern-gora Nov 13, 2024
0f5b5cc
Save changes in the branch
github-actions[bot] Nov 13, 2024
dbc52d0
new spacing
NMinksztym Nov 13, 2024
b128df8
Save changes in the branch
github-actions[bot] Nov 13, 2024
34d8814
Added spacing primitive tokens
theadamparker Nov 13, 2024
1d5c7af
Save changes in the branch
github-actions[bot] Nov 13, 2024
802c307
Add fontsize primitives; renamed sets
theadamparker Nov 13, 2024
f4f57b1
Save changes in the branch
github-actions[bot] Nov 13, 2024
5ceaf7d
Added pixel units to spacing and fontsize
theadamparker Nov 13, 2024
0a56806
Save changes in the branch
github-actions[bot] Nov 13, 2024
e46d53e
Added more font families, and some semantic token examples
theadamparker Nov 13, 2024
2fe32ff
Save changes in the branch
github-actions[bot] Nov 13, 2024
e00f711
Removed placeholder color tokens. Added a few real ones.
theadamparker Nov 13, 2024
e36557d
Save changes in the branch
github-actions[bot] Nov 13, 2024
ce4559e
15.11 update
NMinksztym Nov 15, 2024
fe18e8f
Save changes in the branch
github-actions[bot] Nov 15, 2024
543316e
Update _variables.scss
vern-gora Nov 15, 2024
5d5c76a
Merge branch 'update-figma-tokens' of https://github.com/undp/design-…
vern-gora Nov 15, 2024
f9ed8e0
update 18/11
NMinksztym Nov 18, 2024
24d1fa6
Save changes in the branch
github-actions[bot] Nov 18, 2024
5947ccb
Update build-figma-tokens.yml
vern-gora Nov 19, 2024
6564064
test push
vern-gora Nov 19, 2024
9e6d802
Save changes in the branch
github-actions[bot] Nov 19, 2024
5658da0
delete test black color
vern-gora Nov 19, 2024
08061c6
Save changes in the branch
github-actions[bot] Nov 19, 2024
9a571ef
update 20/11
NMinksztym Nov 20, 2024
3419d84
Save changes in the branch
github-actions[bot] Nov 20, 2024
1e44ec7
added black and white color primitives
theadamparker Nov 25, 2024
e3423eb
Save changes in the branch
github-actions[bot] Nov 25, 2024
4d387fc
Added semantic color tokens. Reworked the semantic font-sizes
theadamparker Nov 25, 2024
50d4e61
Save changes in the branch
github-actions[bot] Nov 25, 2024
aec6be6
renamed all three groups to remove "-tokens" from each
theadamparker Nov 25, 2024
8acac0b
Save changes in the branch
github-actions[bot] Nov 25, 2024
6b18a50
added border-weight subtle
theadamparker Nov 25, 2024
b821906
Save changes in the branch
github-actions[bot] Nov 25, 2024
83f826c
Update build-figma-tokens.mjs
vern-gora Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/build-figma-tokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Generate scss vars from figma tokens

on:
push:
branches:
- update-figma-tokens
paths:
- 'figma-tokens/input/**'

jobs:
build_tokens:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

# Configuring Node.js Environment
- name: Setup Node.js environment
uses: actions/[email protected]

# Setting dependencies
- name: Install dependencies
run: npm ci

# Token conversion using token-transformer
- name: Transform Figma tokens
run: npx token-transformer figma-tokens/input/tokens.json figma-tokens/transformed-tokens/tokens-transformed.json

# Run script for Style Dictionary, convert JSON to SCSS
- name: Build Figma tokens to SCSS
run: npm run build-tokens

# Create or update the `update-figma-tokens` branch
- name: Create or update branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

git add stories/assets/scss/figma-scss/_figma-variables.scss figma-tokens/transformed-tokens/tokens-transformed.json
git commit -m "Save changes in the branch" || echo "No changes to commit"

# Push changes to `update-figma-tokens` branch
- name: Push changes
run: |
git push origin ${{ github.ref_name }} || echo "No changes to push"

# Automatic pull request
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_DATA=$(jq -n \
--arg title "Update SCSS variables from Figma tokens" \
--arg body "This PR updates SCSS variables based on the latest Figma tokens." \
--arg head "${GITHUB_REF#refs/heads/}" \
--arg base "develop" \
'{title: $title, body: $body, head: $head, base: $base}')

curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls \
-d "$PR_DATA"
Empty file added .gitmodules
Empty file.
4 changes: 3 additions & 1 deletion .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default {
'@storybook/react-webpack5',
// '@chromatic-com/storybook',
'@storybook/addon-webpack5-compiler-babel',
'@whitespace/storybook-addon-html'
'@whitespace/storybook-addon-html',
'@storybook/addon-designs',
'storybook-addon-sass-postcss',
],
webpackFinal: async config => {
config.resolve.alias = {
Expand Down
2 changes: 1 addition & 1 deletion chromatic.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"$schema": "https://www.chromatic.com/config-file.schema.json",
"projectId": "UNDP Design System",
"exitOnceUploaded": true,
"skip": "dependabot/**",
"skip": true,
"onlyChanged": true
}
79 changes: 79 additions & 0 deletions figma-tokens/build-figma-tokens.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import StyleDictionary from 'style-dictionary';

// function kebabIt(str) {
// return str
// .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
// .join('-')
// .toLowerCase();
// }

// StyleDictionaryPackage.registerFormat({
// name: 'scss/variables',
// formatter: function (dictionary, config) {
// return `${this.selector} {
// ${dictionary.allProperties.map(prop => `${prop.name}: ${prop.value};`).join('\n')}
// }`
// }
// });

const sd = new StyleDictionary('./figma-tokens/config/config.json');
await sd.buildAllPlatforms();

//

// import {StyleDictionary} from 'style-dictionary-utils'

// const myStyleDictionary = new StyleDictionary()

// // when using style dictionary 4 you whave to await the extend method
// const extendedSd = await myStyleDictionary.extend({
// "source": ["../transformed-tokens/**/*.json"],
// "platforms": {
// "scss": {
// "transformGroup": "scss",
// "buildPath": "../../stories/assets/scss/figma-scss/",
// "files": [
// {
// "destination": "_figma-variables.scss",
// "format": "scss/variables"
// }
// ]
// }
// }
// });

// extendedSd.buildAllPlatforms();

//Px To Rem

// function fontPxToRem(token, options) {
// const baseFont = getBasePxFontSize(options);
// const floatVal = parseFloat(token.value);
// if (isNaN(floatVal)) {
// console.log('NaN error', token.name, token.value, 'rem');
// }
// if (floatVal === 0) {
// return '0';
// }
// return `${floatVal / baseFont}rem`;
// }

// StyleDictionaryPackage.registerTransform({
// name: 'size/pxToRem',
// type: 'value',
// matcher: (token) => ['fontSizes'].includes(token.type),
// transformer: (token, options) => fontPxToRem(token, options)
// })
// //
// StyleDictionaryPackage.registerTransform({
// name: 'sizes/px',
// type: 'value',
// matcher: function(prop) {
// // You can be more specific here if you only want 'em' units for font sizes
// return ["fontSize", "spacing", "borderRadius", "borderWidth", "sizing"].includes(prop.attributes.category);
// },
// transformer: function(prop) {
// // You can also modify the value here if you want to convert pixels to ems
// return parseFloat(prop.original.value) + 'px';
// }
// });
15 changes: 15 additions & 0 deletions figma-tokens/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"source": ["./figma-tokens/transformed-tokens/**/*.json"],
"platforms": {
"scss": {
"transformGroup": "scss",
"buildPath": "./stories/assets/scss/figma-scss/",
"files": [
{
"destination": "_figma-variables.scss",
"format": "scss/variables"
}
]
}
}
}
Loading