-
Notifications
You must be signed in to change notification settings - Fork 0
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
style(tokens): new token sets for core, semantic, and branding #318
Open
ju-Skinner
wants to merge
70
commits into
main
Choose a base branch
from
style/new-tokensets
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 63 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
cdaa8e4
style: create new core tokenset
dev-kjbot 1cda9af
style: change font-weight to use numerical values in core tokenset
dev-kjbot 624fc1c
style: adds half of semantic tokens
dev-kjbot 7f40bd5
style: adds the second half of the semantic tokens
dev-kjbot 21d1eea
style: add kajabi products themes and mode (light and dark)
dev-kjbot b782987
feat: add sd-transformations to generate tokens from token-studio
ju-Skinner 367d60e
style(transform): refactor transform scripts to be more modular
ju-Skinner 6b677bf
style: update themes to include component/avatar
dev-kjbot bb83584
style: remove old core and semantic tokens
dev-kjbot 265fedc
style: changes for brand semantic and modes
dev-kjbot 1d9aa55
style(tokens): working version of token studio to figma variables wit…
dev-kjbot 7ba1f72
style(tokens): add color.brand to kajabi semantic tokens
dev-kjbot 657f952
style(tokens): cleanup semantic tokens and a few core tokens for dime…
dev-kjbot cb98e75
style(tokens): newly generated tokens from style dictionary
ju-Skinner ec8901f
style(tokens): restructure semantic brand token names and locations
ju-Skinner f5d5e5d
style(button): update styles to use semantic tokens
ju-Skinner 44dc49d
style(token-studio): update tokens
dev-kjbot 833cce8
style(tokens): generate new style sheets from sd-transforms
ju-Skinner 6d37418
style(avatar): clean up testing of component semantic level tokens
ju-Skinner 6723bcb
style(application): add a the brand semantic style sheet for testing
ju-Skinner 437b661
style(token-studio): remove border-radius default and none
dev-kjbot 446a9db
style(token-studio): add font-family semantic tokens
dev-kjbot 6190959
style(token-studio): adds color.background.container.hover semantic t…
dev-kjbot ddf70fc
style(tokens): update the semantic tokens by running build.tokens
ju-Skinner 30e5569
style(token-studio): add line-spacing for headings and new dimension …
dev-kjbot 4677778
style(button): change styles to use semantic tokens (#288)
ju-Skinner 17998d4
style(checkbox): change or remove CSS Custom props to use semantic to…
ju-Skinner c120027
style(divider): change tokens to use new semantic tokens from token s…
ju-Skinner 749e17d
style(copytext): update copytext tokens (#293)
anechol 03407ef
style(token-studio): add fallback for font-families Greet and Inter
dev-kjbot b08468d
style(accordion): update accordion tokens (#292)
anechol a7bd66a
style(token-studio): update sentiment colors to *-100 colors
ju-Skinner d3206eb
style: updates component with semantic tokens (#297)
anechol b720be4
style: updates component with semantic tokens (#298)
anechol aff72f8
style(input): update input component to use new semantic tokens (#299)
ju-Skinner 509b8e7
style(loader): change css properties to use semantic tokens (#300)
ju-Skinner 21aec5b
style(progress): change progress css custom props to become semantic …
ju-Skinner 1e0790d
style(tooltip): updates component with semantic tokens (#302)
anechol 08f843b
style(radio): change radio component to use new semantic tokens (#303)
ju-Skinner 915ee32
style(tabs): updates component with semantic tokens (#306)
anechol 7e4cbc5
style(switch): updates component with semantic tokens (#308)
anechol 8d34f9c
style(box): use semantic tokens in box stylesheet (#304)
ju-Skinner 953bbb1
style(sortable): change tokens to use semantic tokens (#305)
ju-Skinner e2d8383
style(table): change css custom props to use semantic tokens (#309)
ju-Skinner d16a474
style(chip): change css props to use semantic tokens (#312)
ju-Skinner c1bcb1d
chore: removes base css file from components (#313)
anechol 989cefe
style(avatar): clean up missing semantic tokens
ju-Skinner fd8cf6e
style(button): change text color to match their variant
ju-Skinner ed846e0
style(token-studio): change sentiment colors to use *-500
ju-Skinner 39fb137
style(token-studio): create semantic tokens for chip
dev-kjbot 39015f7
style(token-studio): refactor component generator
ju-Skinner 6a6f560
style(tokens-studio): remove avatar semantic tokens
dev-kjbot 26b6535
style(tokens): refactor sd-tranforms to read component names from tok…
ju-Skinner dd8f7a3
style(box): refactor to use new semantic tokens (#319)
ju-Skinner 4459c5c
fix: update incorrect core color token values (#322)
pixelflips c2e2dd6
style: updates some components with semantic tokens (#325)
anechol 0137230
style(tokens-studio): update background container disabled token
ju-Skinner 66d6b50
style(input): sync styles for readonly and disabled label and input e…
ju-Skinner 86b2e27
style(textarea): sync styles for readonly and disabled label and text…
ju-Skinner 0c5b75f
refactor(label): moves label to a style utils
ju-Skinner 066fec9
style(textarea): refactor to use utils/label.scss
ju-Skinner 5c69f0f
style(fonts): add Greet Condensed font family
ju-Skinner f222bf8
test: fix failling specs for readonly components
ju-Skinner 701b8f3
style: update line-heights to percentage
ju-Skinner 390b71e
style: update Font Family's to match the system installed font name
ju-Skinner b083bda
style: update references for Figma
dev-kjbot b6c8720
style: refactor border-radius to dimension
ju-Skinner 8177304
style: token studio changes
dev-kjbot a714266
style: add new typography tokens for body and body-sm
dev-kjbot d456c9f
style: update line-height to unit-less
dev-kjbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { basePath } from "../utils.mjs"; | ||
|
||
// filters tokens by themable and from which tokenset they originate | ||
// must match per component name, in this repository we currently only have "button" | ||
export const componentFilter = | ||
(cat) => | ||
(token) => token.filePath.startsWith(`${basePath}/components/${cat}.json`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const coreFilter = (token) => token.filePath.endsWith("base/core.json"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { coreFilter } from "./core.mjs"; | ||
export { componentFilter } from './component.mjs'; | ||
export { semanticFilter } from "./semantic.mjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import fs from 'fs-extra'; | ||
|
||
import { basePath } from '../utils.mjs'; | ||
|
||
// filters only tokens originating from semantic sets (not core, not components) and also check themeable or not | ||
export const semanticFilter = | ||
(themeable = false) => | ||
(token) => { | ||
// const themeDimensions = ["brand"]; | ||
const tokenThemable = Boolean(token.attributes.themeable); | ||
|
||
const brandDimensions = fs.readdirSync(`${basePath}/brand`); | ||
return ( | ||
themeable === tokenThemable && | ||
[...brandDimensions, "semantic"].some((cat) => { | ||
return ( | ||
token.filePath.startsWith(`${basePath}/base/${cat}`) || | ||
token.filePath.startsWith(`${basePath}/brand/${cat}`) | ||
); | ||
} | ||
) | ||
); | ||
}; |
32 changes: 32 additions & 0 deletions
32
libs/core/scripts/style-dictionary/generators/component.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import fs from 'fs-extra' | ||
import { outputReferencesTransformed } from "style-dictionary/utils"; | ||
import { componentFilter } from "../filters/index.mjs"; | ||
import { basePath } from "../utils.mjs"; | ||
|
||
const componentPrefix = 'pds'; | ||
const format = "css/variables"; | ||
|
||
// for each component, filter those specific component tokens and output them | ||
// to the component folder where the component source code will live | ||
export const generateComponentFiles = () => { | ||
const filesArr = []; | ||
|
||
// Generates a list of components from the tokens/components folder | ||
const components = fs.readdirSync(`${basePath}/components`).map((comp) => comp.replace(/.json$/g, "")); | ||
|
||
for (const comp of components) { | ||
// theme-specific outputs | ||
const componentName = `${componentPrefix}-${comp}`; | ||
|
||
filesArr.push({ | ||
format, | ||
filter: componentFilter(comp, true), | ||
options: { | ||
selector: ":host", | ||
outputReferences: outputReferencesTransformed, | ||
}, | ||
destination: `../../../components/${componentName}/${componentName}.tokens.scss`, | ||
}); | ||
} | ||
return filesArr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { coreFilter } from "../filters/index.mjs"; | ||
|
||
const format = "css/variables"; | ||
|
||
export const generateCoreFiles = () => [ | ||
{ | ||
destination: `base/_core.scss`, | ||
format, | ||
filter: coreFilter | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { generateCoreFiles } from "./core.mjs"; | ||
export { generateComponentFiles } from "./component.mjs"; | ||
export { generateSemanticFiles } from "./semantic.mjs"; |
25 changes: 25 additions & 0 deletions
25
libs/core/scripts/style-dictionary/generators/semantic.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { semanticFilter } from "../filters/semantic.mjs"; | ||
|
||
const format = "css/variables"; | ||
|
||
export const generateSemanticFiles = (theme) => { | ||
const filesArr = []; | ||
const [themeName, mode] = theme.toLowerCase().split('-'); | ||
|
||
// theme-specific outputs | ||
filesArr.push({ | ||
format, | ||
filter: semanticFilter(true), | ||
destination: `brand/${themeName}/styles/${mode}.scss`, | ||
}); | ||
|
||
|
||
// not theme-specific outputs | ||
filesArr.push({ | ||
format, | ||
filter: semanticFilter(false), | ||
destination: `brand/${themeName}/styles/semantic.scss`, | ||
}); | ||
|
||
return filesArr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import { register, permutateThemes } from '@tokens-studio/sd-transforms'; | ||
import {generateCoreFiles, generateComponentFiles, generateSemanticFiles } from './generators/index.mjs'; | ||
import StyleDictionary from 'style-dictionary'; | ||
import { getReferences, usesReferences } from "style-dictionary/utils"; | ||
import { promises } from 'fs'; | ||
|
||
register(StyleDictionary, { | ||
/* options here if needed */ | ||
}); | ||
|
||
const basePath = `src/global/styles/tokens`; | ||
|
||
async function run() { | ||
const $themes = JSON.parse(await promises.readFile(`${basePath}/$themes.json`, 'utf-8')); | ||
const themes = permutateThemes($themes, { separator: '-' }); | ||
|
||
const tokenSets = [ | ||
...new Set( | ||
Object.values(themes) | ||
.reduce((acc, sets) => [...acc, ...sets], []) | ||
), | ||
]; | ||
|
||
const themeableSets = tokenSets.filter(set => { | ||
return !Object.values(themes).every(sets => sets.includes(set)); | ||
}); | ||
|
||
const configs = Object.entries(themes).map(([theme, tokensets]) => ({ | ||
log: { | ||
verbosity: 'verbose', | ||
}, | ||
source: tokensets.map(tokenset => `${basePath}/${tokenset}.json`), | ||
preprocessors: ['tokens-studio'], // <-- since 0.16.0 this must be explicit | ||
platforms: { | ||
css: { | ||
transformGroup: 'tokens-studio', | ||
transforms: ['attribute/themeable', 'name/kebab', 'color/hex', 'ts/resolveMath', 'size/px'], | ||
buildPath: `${basePath}/`, | ||
files: [ | ||
...generateCoreFiles(), | ||
...generateSemanticFiles(theme), | ||
...generateComponentFiles(), | ||
], | ||
prefix: 'pine' | ||
}, | ||
}, | ||
})); | ||
|
||
for (const cfg of configs) { | ||
const sd = new StyleDictionary(cfg); | ||
|
||
/** | ||
* This transform checks for each token whether that token's value could change | ||
* due to Tokens Studio theming. | ||
* Any tokenset from Tokens Studio marked as "enabled" in the $themes.json is considered | ||
* a set in which any token could change if the theme changes. | ||
* Any token that is inside such a set or is a reference with a token in that reference chain | ||
* that is inside such a set, is considered "themeable", | ||
* which means it could change by theme switching. | ||
* | ||
* This metadata is applied to the token so we can use it as a way of filtering outputs | ||
* later in the "format" stage. | ||
*/ | ||
sd.registerTransform({ | ||
name: "attribute/themeable", | ||
type: "attribute", | ||
transform: (token) => { | ||
function isPartOfEnabledSet(token) { | ||
const pathRegex = new RegExp(`^${basePath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, "g"); | ||
const set = token.filePath | ||
.replace(pathRegex, "") | ||
.replace(/^\/+/g, "") | ||
.replace(/.json$/g, ""); | ||
|
||
return themeableSets.includes(set); | ||
} | ||
|
||
// Set token to themeable if it's part of an enabled set | ||
if (isPartOfEnabledSet(token)) { | ||
return { | ||
themeable: true, | ||
}; | ||
} | ||
|
||
// Set token to themeable if it's using a reference and inside the reference chain | ||
// any one of them is from a themeable set | ||
if (usesReferences(token.original.value)) { | ||
const refs = getReferences(token.original.value, sd.tokens); | ||
if (refs.some((ref) => isPartOfEnabledSet(ref))) { | ||
return { | ||
themeable: true, | ||
}; | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
await sd.cleanAllPlatforms(); | ||
await sd.buildAllPlatforms(); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const basePath = `src/global/styles/tokens`; |
14 changes: 0 additions & 14 deletions
14
libs/core/src/components/_internal/pds-label/pds-label.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a border-radius token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below