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

style(tokens): new token sets for core, semantic, and branding #318

Open
wants to merge 70 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Oct 29, 2024
1cda9af
style: change font-weight to use numerical values in core tokenset
dev-kjbot Oct 29, 2024
624fc1c
style: adds half of semantic tokens
dev-kjbot Oct 29, 2024
7f40bd5
style: adds the second half of the semantic tokens
dev-kjbot Oct 29, 2024
21d1eea
style: add kajabi products themes and mode (light and dark)
dev-kjbot Oct 29, 2024
b782987
feat: add sd-transformations to generate tokens from token-studio
ju-Skinner Oct 29, 2024
367d60e
style(transform): refactor transform scripts to be more modular
ju-Skinner Oct 30, 2024
6b677bf
style: update themes to include component/avatar
dev-kjbot Oct 30, 2024
bb83584
style: remove old core and semantic tokens
dev-kjbot Oct 30, 2024
265fedc
style: changes for brand semantic and modes
dev-kjbot Oct 31, 2024
1d9aa55
style(tokens): working version of token studio to figma variables wit…
dev-kjbot Nov 1, 2024
7ba1f72
style(tokens): add color.brand to kajabi semantic tokens
dev-kjbot Nov 6, 2024
657f952
style(tokens): cleanup semantic tokens and a few core tokens for dime…
dev-kjbot Nov 6, 2024
cb98e75
style(tokens): newly generated tokens from style dictionary
ju-Skinner Nov 6, 2024
ec8901f
style(tokens): restructure semantic brand token names and locations
ju-Skinner Nov 7, 2024
f5d5e5d
style(button): update styles to use semantic tokens
ju-Skinner Nov 7, 2024
44dc49d
style(token-studio): update tokens
dev-kjbot Nov 7, 2024
833cce8
style(tokens): generate new style sheets from sd-transforms
ju-Skinner Nov 7, 2024
6d37418
style(avatar): clean up testing of component semantic level tokens
ju-Skinner Nov 7, 2024
6723bcb
style(application): add a the brand semantic style sheet for testing
ju-Skinner Nov 7, 2024
437b661
style(token-studio): remove border-radius default and none
dev-kjbot Nov 8, 2024
446a9db
style(token-studio): add font-family semantic tokens
dev-kjbot Nov 8, 2024
6190959
style(token-studio): adds color.background.container.hover semantic t…
dev-kjbot Nov 8, 2024
ddf70fc
style(tokens): update the semantic tokens by running build.tokens
ju-Skinner Nov 8, 2024
30e5569
style(token-studio): add line-spacing for headings and new dimension …
dev-kjbot Nov 12, 2024
4677778
style(button): change styles to use semantic tokens (#288)
ju-Skinner Nov 13, 2024
17998d4
style(checkbox): change or remove CSS Custom props to use semantic to…
ju-Skinner Nov 13, 2024
c120027
style(divider): change tokens to use new semantic tokens from token s…
ju-Skinner Nov 13, 2024
749e17d
style(copytext): update copytext tokens (#293)
anechol Nov 13, 2024
03407ef
style(token-studio): add fallback for font-families Greet and Inter
dev-kjbot Nov 13, 2024
b08468d
style(accordion): update accordion tokens (#292)
anechol Nov 13, 2024
a7bd66a
style(token-studio): update sentiment colors to *-100 colors
ju-Skinner Nov 13, 2024
d3206eb
style: updates component with semantic tokens (#297)
anechol Nov 13, 2024
b720be4
style: updates component with semantic tokens (#298)
anechol Nov 13, 2024
aff72f8
style(input): update input component to use new semantic tokens (#299)
ju-Skinner Nov 13, 2024
509b8e7
style(loader): change css properties to use semantic tokens (#300)
ju-Skinner Nov 13, 2024
21aec5b
style(progress): change progress css custom props to become semantic …
ju-Skinner Nov 14, 2024
1e0790d
style(tooltip): updates component with semantic tokens (#302)
anechol Nov 14, 2024
08f843b
style(radio): change radio component to use new semantic tokens (#303)
ju-Skinner Nov 14, 2024
915ee32
style(tabs): updates component with semantic tokens (#306)
anechol Nov 14, 2024
7e4cbc5
style(switch): updates component with semantic tokens (#308)
anechol Nov 14, 2024
8d34f9c
style(box): use semantic tokens in box stylesheet (#304)
ju-Skinner Nov 14, 2024
953bbb1
style(sortable): change tokens to use semantic tokens (#305)
ju-Skinner Nov 14, 2024
e2d8383
style(table): change css custom props to use semantic tokens (#309)
ju-Skinner Nov 15, 2024
d16a474
style(chip): change css props to use semantic tokens (#312)
ju-Skinner Nov 15, 2024
c1bcb1d
chore: removes base css file from components (#313)
anechol Nov 15, 2024
989cefe
style(avatar): clean up missing semantic tokens
ju-Skinner Nov 18, 2024
fd8cf6e
style(button): change text color to match their variant
ju-Skinner Nov 18, 2024
ed846e0
style(token-studio): change sentiment colors to use *-500
ju-Skinner Nov 18, 2024
39fb137
style(token-studio): create semantic tokens for chip
dev-kjbot Nov 18, 2024
39015f7
style(token-studio): refactor component generator
ju-Skinner Nov 19, 2024
6a6f560
style(tokens-studio): remove avatar semantic tokens
dev-kjbot Nov 19, 2024
26b6535
style(tokens): refactor sd-tranforms to read component names from tok…
ju-Skinner Nov 19, 2024
dd8f7a3
style(box): refactor to use new semantic tokens (#319)
ju-Skinner Nov 20, 2024
4459c5c
fix: update incorrect core color token values (#322)
pixelflips Dec 2, 2024
c2e2dd6
style: updates some components with semantic tokens (#325)
anechol Dec 3, 2024
0137230
style(tokens-studio): update background container disabled token
ju-Skinner Dec 10, 2024
66d6b50
style(input): sync styles for readonly and disabled label and input e…
ju-Skinner Dec 11, 2024
86b2e27
style(textarea): sync styles for readonly and disabled label and text…
ju-Skinner Dec 11, 2024
0c5b75f
refactor(label): moves label to a style utils
ju-Skinner Dec 11, 2024
066fec9
style(textarea): refactor to use utils/label.scss
ju-Skinner Dec 11, 2024
5c69f0f
style(fonts): add Greet Condensed font family
ju-Skinner Jan 14, 2025
f222bf8
test: fix failling specs for readonly components
ju-Skinner Jan 14, 2025
701b8f3
style: update line-heights to percentage
ju-Skinner Jan 16, 2025
390b71e
style: update Font Family's to match the system installed font name
ju-Skinner Jan 16, 2025
b083bda
style: update references for Figma
dev-kjbot Jan 16, 2025
b6c8720
style: refactor border-radius to dimension
ju-Skinner Jan 22, 2025
8177304
style: token studio changes
dev-kjbot Jan 22, 2025
a714266
style: add new typography tokens for body and body-sm
dev-kjbot Jan 23, 2025
d456c9f
style: update line-height to unit-less
dev-kjbot Jan 24, 2025
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
2 changes: 1 addition & 1 deletion libs/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"build.stencil": "stencil build --docs",
"build.storybook": "storybook build",
"build.ts": "tsc -p scripts/tsconfig.json",
"build.tokens": "node scripts/sd-transforms.mjs",
"build.tokens": "node scripts/style-dictionary/transform.mjs",
"deploy": "npm run build.all",
"generate": "stencil generate",
"lint": "run-p lint.*",
Expand Down
50 changes: 0 additions & 50 deletions libs/core/scripts/sd-transforms.mjs

This file was deleted.

7 changes: 7 additions & 0 deletions libs/core/scripts/style-dictionary/filters/component.mjs
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`);
1 change: 1 addition & 0 deletions libs/core/scripts/style-dictionary/filters/core.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const coreFilter = (token) => token.filePath.endsWith("base/core.json");
3 changes: 3 additions & 0 deletions libs/core/scripts/style-dictionary/filters/index.mjs
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";
23 changes: 23 additions & 0 deletions libs/core/scripts/style-dictionary/filters/semantic.mjs
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 libs/core/scripts/style-dictionary/generators/component.mjs
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;
};
11 changes: 11 additions & 0 deletions libs/core/scripts/style-dictionary/generators/core.mjs
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
}
];
3 changes: 3 additions & 0 deletions libs/core/scripts/style-dictionary/generators/index.mjs
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 libs/core/scripts/style-dictionary/generators/semantic.mjs
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;
};
103 changes: 103 additions & 0 deletions libs/core/scripts/style-dictionary/transform.mjs
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();
1 change: 1 addition & 0 deletions libs/core/scripts/style-dictionary/utils.mjs
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 libs/core/src/components/_internal/pds-label/pds-label.scss

This file was deleted.

53 changes: 21 additions & 32 deletions libs/core/src/components/pds-accordion/pds-accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,14 @@
}

details {
--border-radius-default: var(--pine-border-radius-default);

--box-shadow-focus: 0 0 0 1px #ffffff, 0 0 0 3px var(--pine-color-purple-300);

--color-background-default: var(--pine-color-white);
--color-background-hover: var(--pine-color-grey-150);
--color-text-default: var(--pine-color-text-interactive-default);
--color-text-active: var(--pine-color-grey-950);
--color-text-hover: var(--pine-color-grey-800);

--font-weight-active: var(--pine-font-weight-semi-bold);

// TODO: Needs discussion
--box-shadow-focus: 0 0 0 1px #ffffff, 0 0 0 3px var(--pine-color-focus-ring);
--color-text-hover: var(--pine-color-text-secondary);
--number-animation-transform-timing: 200ms;

--spacing-details-padding-inline: var(--pine-spacing-150);
--spacing-details-padding-block-end: calc(var(--pine-spacing-200) + 2); //18 + 2 = 18px
--spacing-summary-padding-block: calc(var(--pine-spacing-150) / 2); //12 / 2 = 6px
--spacing-summary-padding-inline-start: var(--pine-spacing-100);
--spacing-summary-padding-inline-end: var(--pine-spacing-050);

--typography-default: var(--pine-typography-body-md-medium);

border-radius: var(--border-radius-default);
border-radius: var(--pine-dimension-xs);
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See comment below


pds-icon {
transform: scaleY(1);
Expand All @@ -34,11 +19,11 @@ details {

/* stylelint-disable-next-line */
details[open] {
background-color: var(--color-background-default);
background-color: var(--pine-color-background-container);

summary {
color: var(--color-text-active);
font-weight: var(--font-weight-active);
color: var(--pine-color-text-active);
font-weight: var(--pine-font-weight-semi-bold);

pds-icon {
transform: scaleY(-1);
Expand All @@ -47,13 +32,17 @@ details[open] {
}

summary {
background-color: var(--color-background-default);
border-radius: var(--border-radius-default);
color: var(--color-text-default);
font: var(--typography-default);
padding-block: var(--spacing-summary-padding-block);
padding-inline-end: var(--spacing-summary-padding-inline-end);
padding-inline-start: var(--spacing-summary-padding-inline-start);
background-color: var(--pine-color-background-container);
border-radius: var(--pine-dimension-xs);
color: var(--pine-color-text);
font-family: var(--pine-font-family-body);
font-size: var(--pine-font-size-body-md);
font-weight: var(--pine-font-weight-medium);
letter-spacing: var(--pine-letter-spacing);
line-height: var(--pine-line-height-body);
padding-block: calc(var(--pine-dimension-2xs) * 1.5);
padding-inline-end: var(var(--pine-dimension-2xs));
padding-inline-start: var(var(--pine-dimension-xs));

// Removes marker on Firefox/Chrome
/* stylelint-disable-next-line */
Expand All @@ -66,7 +55,7 @@ summary {
}

&:hover {
background: var(--color-background-hover);
background: var(--pine-color-background-container-hover);
color: var(--color-text-hover);
cursor: pointer;
}
Expand All @@ -84,6 +73,6 @@ summary {
}

.pds-accordion__body {
padding-block-end: var(--spacing-details-padding-block-end);
padding-inline: var(--spacing-details-padding-inline);
padding-block-end: calc(var(--pine-dimension-sm) + 2);
padding-inline: calc(var(--pine-dimension-2xs) * 1.5);
}
2 changes: 1 addition & 1 deletion libs/core/src/components/pds-accordion/pds-accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { downSmall } from '@pine-ds/icons/icons';
*/
@Component({
tag: 'pds-accordion',
styleUrls: ['../../global/styles/base.scss','pds-accordion.scss'],
styleUrls: ['pds-accordion.scss'],
shadow: true,
})
export class PdsAccordion {
Expand Down
Loading
Loading