Skip to content
Draft
Show file tree
Hide file tree
Changes from 13 commits
Commits
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
42 changes: 41 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@
"copy-tokens": {
"dependencies": [
"copy-tokens:core",
"copy-tokens:base"
"copy-tokens:base",
"copy-tokens:primitives",
"copy-tokens:system",
"copy-tokens:base-new",
"copy-tokens:theme-new"
]
},
"copy-tokens:core": {
Expand All @@ -120,6 +124,42 @@
"src/_data/tokens/base.json"
]
},
"copy-tokens:primitives": {
"command": "cpx '../packages/tokens/src/tokens/primitives.json' 'src/_data/tokens/'",
"files": [
"../packages/tokens/src/tokens/primitives.json"
],
"output": [
"src/_data/tokens/primitives.json"
]
},
"copy-tokens:system": {
"command": "cpx '../packages/tokens/src/tokens/system.json' 'src/_data/tokens/'",
"files": [
"../packages/tokens/src/tokens/system.json"
],
"output": [
"src/_data/tokens/system.json"
]
},
"copy-tokens:base-new": {
"command": "cpx '../packages/tokens/src/tokens/tokens/base-new.json' 'src/_data/tokens/'",
"files": [
"../packages/tokens/src/tokens/tokens/base-new.json"
],
"output": [
"src/_data/tokens/base-new.json"
]
},
"copy-tokens:theme-new": {
"command": "cpx '../packages/tokens/src/tokens/tokens/theme-new.json' 'src/_data/tokens/'",
"files": [
"../packages/tokens/src/tokens/tokens/theme-new.json"
],
"output": [
"src/_data/tokens/theme-new.json"
]
},
"lint": {
"dependencies": [
"lint:scss",
Expand Down
238 changes: 238 additions & 0 deletions website/src/_data/tokens/base-new.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
{
"icon": {
"typeset": {
"fontWeight": {
"solid": {
"$type": "fontWeights",
"$value": "{icon.typeset.fontWeight.icon-solid}"
},
"regular": {
"$type": "fontWeights",
"$value": "{icon.typeset.fontWeight.icon-regular}"
}
}
}
},
"size": {
"icon": {
"font": {
"lg": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.lg}"
},
"md": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.md}"
},
"sm": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.sm}"
},
"xl": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.xl}"
},
"xs": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.xs}"
},
"2xl": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.2xl}"
},
"2xs": {
"$type": "fontSizes",
"$value": "{size-new.icon.2xs}"
},
"3xl": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.3xl}"
},
"4xl": {
"$type": "fontSizes",
"$value": "{base.size.icon.font.4xl}"
}
}
},
"text-new": {
"body": {
"lg": {
"$type": "fontSizes",
"$value": "{base.size.text-new.body.lg}"
},
"md": {
"$type": "fontSizes",
"$value": "{base.size.text-new.body.md}",
"$description": "default text size for body"
},
"sm": {
"$type": "fontSizes",
"$value": "{base.size.text-new.body.sm}"
}
},
"heading": {
"lg": {
"$type": "fontSizes",
"$value": "{base.size.text-new.heading.lg}"
},
"md": {
"$type": "fontSizes",
"$value": "{base.size.text-new.heading.md}"
},
"sm": {
"$type": "fontSizes",
"$value": "{base.size.text-new.heading.sm}"
},
"xl": {
"$type": "fontSizes",
"$value": "{base.size.text-new.heading.xl}"
},
"2xl": {
"$type": "fontSizes",
"$value": "{base.size.text-new.heading.2xl}"
}
}
},
"borderWidth": {
"action": {
"$type": "borderWidth",
"$value": "{base.size.borderWidth.action}",
"$description": "Sets the standard border width for action components."
},
"default": {
"$type": "borderWidth",
"$value": "{base.size.borderWidth.default}",
"$description": "Sets the standard border width for UI elements."
}
},
"borderRadius": {
"full": {
"$type": "borderRadius",
"$value": "{base.size.borderRadius.full}",
"$description": "Use for pill-shaped elements like badges, and circular rounding for components with equal width and height, such as icon buttons and avatars."
},
"child": {
"$type": "borderRadius",
"$value": "{base.size.borderRadius.child}",
"$description": "The standard border radius for most components. Use for elements that need subtle rounding without emphasizing their shape."
},
"default": {
"$type": "borderRadius",
"$value": "{base.size.borderRadius.default}",
"$description": "The standard border radius for most components. Use for elements that need subtle rounding without emphasizing their shape."
},
"focusRing": {
"inside": {
"$type": "borderRadius",
"$value": "{base.size.borderRadius.focusRing.inside}",
"$description": "Use for focusring inside of component when outside focus ring is not possible"
},
"outside": {
"$type": "borderRadius",
"$value": "{base.size.borderRadius.focusRing.outside}",
"$description": "Use for focusring outside of component"
}
}
},
"outlineWidth": {
"default": {
"$type": "borderWidth",
"$value": "{base.size.outlineWidth.default}",
"$description": "Sets the standard outline width for UI elements."
}
}
},
"space": {
"offset": {
"default": {
"$type": "spacing",
"$value": "{base.space.offset.default}",
"$description": "Defines the standard spacing offset."
}
}
},
"text-new": {
"body": {
"lg": {
"$type": "typography",
"$value": "{base.text-new.body.lg}"
},
"md": {
"$type": "typography",
"$value": "{base.text-new.body.md}"
},
"sm": {
"$type": "typography",
"$value": "{base.text-new.body.sm}"
}
},
"icon": {
"solid": {
"$type": "typography",
"$value": "{base.text-new.icon.solid}"
},
"outline": {
"$type": "typography",
"$value": "{base.text-new.icon.outline}"
}
},
"input": {
"lg": {
"$type": "typography",
"$value": "{base.text-new.input.lg}"
},
"md": {
"$type": "typography",
"$value": "{base.text-new.input.md}"
}
},
"heading": {
"lg": {
"$type": "typography",
"$value": "{base.text-new.heading.lg}"
},
"md": {
"$type": "typography",
"$value": "{base.text-new.heading.md}"
},
"sm": {
"$type": "typography",
"$value": "{base.text-new.heading.sm}"
},
"xl": {
"$type": "typography",
"$value": "{base.text-new.heading.xl}"
},
"2xl": {
"$type": "typography",
"$value": "{base.text-new.heading.2xl}"
}
},
"typeset": {
"fontFamily": {
"body": {
"$type": "fontFamilies",
"$value": "{base.text-new.typeset.fontFamily.body}"
},
"icon": {
"$type": "fontFamilies",
"$value": "{base.text-new.typeset.fontFamily.icon}"
},
"heading": {
"$type": "fontFamilies",
"$value": "{base.text-new.typeset.fontFamily.heading}"
}
},
"fontWeight": {
"regular": {
"$type": "fontWeights",
"$value": "{base.text-new.typeset.fontWeight.regular}"
},
"semiBold": {
"$type": "fontWeights",
"$value": "{base.text-new.typeset.fontWeight.semiBold}"
}
}
}
}
}
45 changes: 45 additions & 0 deletions website/src/_data/tokens/borderTokens.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const baseNew = require('./base-new.json');
const system = require('./system.json');

function flattenTokens(obj, prefix) {
const results = [];
for (const [key, val] of Object.entries(obj)) {
if (val && val['$type']) {
let rawValue = (typeof val['$value'] === 'string' ? val['$value'] : '').replace(/[{}]/g, '');
if (/\s[-+*/]\s/.test(rawValue)) {
rawValue = `calc(${rawValue})`;
}
const tokenName = (prefix + key).replace(/^--sl-/, '');
results.push({
token: prefix + key,
value: rawValue,
title: tokenName
.replace(/([a-z])([A-Z])/g, '$1 $2')
.replace(/[.\-]/g, ' ')
.replace(/\b\w/g, c => c.toUpperCase()),
type: val['$type'] || '',
description: val['$description'] || ''
});
} else if (val && typeof val === 'object') {
results.push(...flattenTokens(val, prefix + key + '-'));
}
}
return results;
}

module.exports = {
borderWidth: [
...flattenTokens(system.size.borderWidth, '--sl-size-borderWidth-'),
...flattenTokens(baseNew.size.borderWidth, '--sl-size-borderWidth-')
],
borderRadius: [
...flattenTokens(system.size.borderRadius, '--sl-size-borderRadius-'),
...flattenTokens(baseNew.size.borderRadius, '--sl-size-borderRadius-')
],
outlineWidth: [
...flattenTokens(system.size.outlineWidth, '--sl-size-outlineWidth-'),
...flattenTokens(baseNew.size.outlineWidth, '--sl-size-outlineWidth-')
],
outlineOffset: flattenTokens(system.size.outlineOffset, '--sl-size-outlineOffset-')
};

42 changes: 42 additions & 0 deletions website/src/_data/tokens/elevationTokens.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const system = require('./system.json');
const themeNew = require('./theme-new.json');

function flattenTokens(obj, prefix) {
const results = [];
for (const [key, val] of Object.entries(obj)) {
if (val && val['$type']) {
const rawValue = val['$value'];
const tokenName = (prefix + key).replace(/^--sl-/, '');
const isBoxShadow = val['$type'] === 'boxShadow';
results.push({
token: prefix + key,
value: isBoxShadow ? formatBoxShadow(rawValue) : (typeof rawValue === 'string' ? rawValue.replace(/[{}]/g, '') : rawValue),
title: tokenName
.replace(/([a-z])([A-Z])/g, '$1 $2')
.replace(/[.\-]/g, ' ')
.replace(/\b\w/g, c => c.toUpperCase()),
type: val['$type'] || '',
description: val['$description'] || ''
});
} else if (val && typeof val === 'object' && !Array.isArray(val)) {
results.push(...flattenTokens(val, prefix + key + '-'));
}
}
return results;
}

function formatBoxShadow(layers) {
if (!Array.isArray(layers)) return String(layers);
return layers.map(l => {
const parts = [l.x || '0', l.y || '0', l.blur || '0'];
if (l.spread) parts.push(l.spread);
parts.push(String(l.color || '').replace(/[{}]/g, ''));
return parts.join(' ');
}).join(', ');
Comment thread
anna-lach marked this conversation as resolved.
}

module.exports = {
shadow: flattenTokens(system.elevation.shadow, '--sl-elevation-shadow-'),
surface: flattenTokens(themeNew.elevation.surface, '--sl-elevation-surface-')
};

Loading
Loading