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

feat: support colors as args for create tokens #2290

Merged
merged 26 commits into from
Aug 27, 2024
Merged

Conversation

mimarz
Copy link
Collaborator

@mimarz mimarz commented Aug 20, 2024

resolves #2269

Use theme-builder to select desired colors
image

Paste provided cli command in a terminal to generate desired design-tokens
image

Copy link

changeset-bot bot commented Aug 20, 2024

🦋 Changeset detected

Latest commit: e6ab6fb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@digdir/designsystemet Minor
@digdir/designsystemet-css Minor
@digdir/designsystemet-theme Minor
@digdir/designsystemet-react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Aug 20, 2024

Preview deployments for this pull request:

📖 Storybook 27. Aug 2024 - 14:04 (Norwegian time)

See all deployments at https://dev.designsystemet.no

@mimarz mimarz marked this pull request as ready for review August 26, 2024 22:26
@mimarz
Copy link
Collaborator Author

mimarz commented Aug 26, 2024

Still abit of work left on the CLI for scaling this to multiple themes and typography, but this serves currently as a good start.

Also works in Figma with Token Studio.

Suggest we have a small demo+talk about whats been done here, and the way further @eirikbacker @Barsnes @Thuneer

tokenCmd
.command('build')
.description('Build Designsystemet tokens')
.option('-t, --tokens <string>', `Path to ${chalk.blue('design-tokens')}`, './design-tokens')
Copy link
Contributor

@eirikbacker eirikbacker Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

her har vi -t / --tokens på kommando tokens build
og senere kommer -w / --write på kommando tokens create
Om jeg forstår rett er begge hvilken mappe tokens skal legges i?
Skulle vi kjørt den mer konvensjonelle --dir eller --out i såfall? :)

Copy link
Collaborator Author

@mimarz mimarz Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Det var en av tinga jeg ville ta opp i demoen :)

Jeg brukte --out tidligere, men ble litt inspirert av biomejs sin --write.

Slik den fungere nå:

  • cmd --write -> skriver til default (./design-tokens)
  • cmd --write ./my-path-for-tokens -> skriver til ønsket sti
  • cmd -> token generes, men ingenting skrives til disk. Returnere json objekt med tokens. Dette kan være nyttig for de som vil pipe output selv en plass (f.eks, cmd > tokens.json, cmd | pbcopy)

Du kan og forsåvidt kjøre dette skriptet direkte fra kode

import { createTokens } from "@digdir/designsystemet/tokens" 

const tokens = createTokens({colors:})

.option('-b3, --brand3 <number>', `Brand3 hex color`)
.option('-f, --font-family <string>', `Font family`)
.action(async (opts) => {
// const out = typeof opts.out === 'string' ? opts.out : './dist/tokens';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kommentert ut? ☺️

}
},
"publishConfig": {
"access": "public"
},
"scripts": {
"designsystemet": "tsx ./bin/designsystemet.ts",
"build:tokens": "yarn clean:theme && yarn designsystemet tokens -p -t ../../design-tokens -o ../../packages/theme/brand",
"build:tokens:debug": "yarn clean:theme && tsx --inspect-brk ./bin/designsystemet.ts tokens -p -t ../../design-tokens -o ../../packages/theme/brand",
"build:tokens": "yarn clean:theme && yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand",
Copy link
Contributor

@eirikbacker eirikbacker Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Veldig minor: Skulle vi skrevet ut parameter i fullversjon i våre egne scripts? Dersom noen utenifra skal bidra inn i prosjektet, så er det lettere å lese tokens build --preview enn å gjette hva -p betyr <3

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ja, men ikke glad i den optionen, har lyst å ta livet av den 😅 Men det gjøres i egen PR :)

// 'primitives/size/compact': TokenSetStatus.ENABLED,
// },
// group: 'Size',
// },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stored for later? :)

'primitives/modes/typography/default',
'primitives/size/default',
'primitives/modes/typography/primary/theme',
'primitives/modes/typography/secondary/theme',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Æ skjønne det itj helt, men det er nok fordi jeg ikke har vært nok borti dette helt enda :)

Copy link
Collaborator Author

@mimarz mimarz Aug 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dette er fil for Token Studio pluginen :)

},
bold: {
$type: 'fontWeights',
$value: 'Medium',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dette er for vårt theme eller bare nysgerrig hvorfor mappingen? :)
bold => medium
extra-bold => semi bold

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dette har med Token Studio vs Figma å gjøre. @Febakke kan best svare på dette :)


for (const file of files) {
const path_ = path.resolve(file.path);
const filePath = path.resolve(file.filePath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

er file.path det samme som dirPath og file.filePath med filnavn? I såfall, kan path_ være dirPath? 😇

@mimarz
Copy link
Collaborator Author

mimarz commented Aug 27, 2024

Merging this in to avoid further conflicts on work for theme. Will continue work on this in a new PR.

@mimarz mimarz merged commit cd1c607 into next Aug 27, 2024
4 checks passed
@mimarz mimarz deleted the new-tokens-with-color-args branch August 27, 2024 12:05
mimarz pushed a commit that referenced this pull request Aug 28, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to next, this PR will
be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`next` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `next`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @digdir/designsystemet@1.0.0-next.32

### Minor Changes

- Fix design-token warning contrast color reference
([#2339](#2339))

- New create tokens script with color options support
([#2290](#2290))

## @digdir/designsystemet-css@1.0.0-next.32

### Patch Changes

- Chip: Support wrapping in group
([#2324](#2324))

## @digdir/designsystemet-react@1.0.0-next.32



## @digdir/designsystemet-theme@1.0.0-next.32

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for passing theme colors to init script
2 participants