Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Use tokens from Figma in Stitches (#728)
Roman Pominov62d870ad8e3d
diff --git a/packages/design-system/bin/transform-figma-tokens.ts b/packages/design-system/bin/transform-figma-tokens.tsnew file mode 100644index 0000000000..0e37bbf802--- /dev/null+++ b/packages/design-system/bin/transform-figma-tokens.ts@@ -0,0 +1,98 @@+/* eslint-disable no-console */++import { execSync } from "child_process";+import camelCase from "camelcase";+import { readFileSync, writeFileSync, existsSync, rmSync } from "fs";++const SOURCE_FILE = "./src/__generated__/figma-design-tokens.json";+const TMP_OUTPUT_FILE = "./src/__generated__/figma-design-tokens.tmp";+const OUTPUT_FILE = "./src/__generated__/figma-design-tokens.ts";++const traverse = (+ node: unknown,+ nodePath: string[],+ fn: (path: string[], type: string, value: unknown) => void+) => {+ if (typeof node !== "object" || node === null) {+ return;+ }++ const entries = Object.entries(node);++ // TypeScript forces us to use entries to read properties of an unknown object+ const type = entries.find(([key]) => key === "type");+ const value = entries.find(([key]) => key === "value");++ // if there's a `type` and `value` properties, treat it as a tree leaf+ if (type && value && typeof type[1] === "string") {+ fn(nodePath, type[1], value[1]);+ // otherwise, traverse deeper+ } else {+ for (const [key, value] of entries) {+ traverse(value, [...nodePath, key], fn);+ }+ }+};++const pathToName = (path: string[], type: string) => {+ const cleanedUp = path.join(" ").replace(/[^a-z0-9]+/gi, " ");++ const withoutPrefix = cleanedUp+ .toLocaleLowerCase()+ .startsWith(type.toLocaleLowerCase())+ ? cleanedUp.slice(type.length)+ : cleanedUp;++ return camelCase(withoutPrefix, { locale: false });+};++const main = () => {+ execSync(`token-transformer ${SOURCE_FILE} ${TMP_OUTPUT_FILE}`, {+ stdio: "inherit",+ });++ const data = JSON.parse(readFileSync(TMP_OUTPUT_FILE, "utf-8"));++ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ const byType = new Map<string, Record<string, any>>();++ traverse(data, [], (path, type, value) => {+ const record = byType.get(type) ?? {};+ byType.set(type, record);++ // no need to check for __proto__ (prototype polution)+ // because we know pathToName returns a string without "_"+ record[pathToName(path, type)] = value;+ });++ writeFileSync(+ OUTPUT_FILE,+ `// Generated by transform-figma-tokens.ts from ${SOURCE_FILE}\n\n` ++ [...byType.entries()]+ .map(+ ([type, values]) =>+ `export const ${type} = ${JSON.stringify(values)} as const`+ )+ .join(";\n\n")+ );++ execSync(`prettier --write ${OUTPUT_FILE}`, { stdio: "inherit" });+};++const cleanup = () => {+ if (existsSync(TMP_OUTPUT_FILE)) {+ rmSync(TMP_OUTPUT_FILE);+ }+};++try {+ main();+} catch (error) {+ try {+ cleanup();+ } catch (cleanupError) {+ console.error("Cleanup failed:", cleanupError);+ }+ throw error;+}+cleanup();diff --git a/packages/design-system/documentation/assets/1.png b/packages/design-system/documentation/assets/1.pngnew file mode 100644index 0000000000..b57a070ca3Binary files /dev/null and b/packages/design-system/documentation/assets/1.png differdiff --git a/packages/design-system/documentation/assets/2.png b/packages/design-system/documentation/assets/2.pngnew file mode 100644index 0000000000..001b5cd9f3Binary files /dev/null and b/packages/design-system/documentation/assets/2.png differdiff --git a/packages/design-system/documentation/assets/3.png b/packages/design-system/documentation/assets/3.pngnew file mode 100644index 0000000000..c3c1b2cd85Binary files /dev/null and b/packages/design-system/documentation/assets/3.png differdiff --git a/packages/design-system/documentation/assets/4.png b/packages/design-system/documentation/assets/4.pngnew file mode 100644index 0000000000..2da32dca76Binary files /dev/null and b/packages/design-system/documentation/assets/4.png differdiff --git a/packages/design-system/documentation/assets/5.png b/packages/design-system/documentation/assets/5.pngnew file mode 100644index 0000000000..87f903a934Binary files /dev/null and b/packages/design-system/documentation/assets/5.png differdiff --git a/packages/design-system/documentation/figma-design-tokens.md b/packages/design-system/documentation/figma-design-tokens.mdnew file mode 100644index 0000000000..f9d6004782--- /dev/null+++ b/packages/design-system/documentation/figma-design-tokens.md@@ -0,0 +1,39 @@+# Figma Design Tokens++We use [Tokens Studio for Figma](https://docs.tokens.studio) plugin to sync design tokens between Figma and our code.++- [`__generated__/figma-design-tokens.json`](../src/__generated__/figma-design-tokens.json) — this file is synced with Figma by the plugin.+- [`__generated__/figma-design-tokens.ts`](../src/__generated__/figma-design-tokens.ts) — this file is generated from `figma-design-tokens.json` by [`transform-figma-tokens.ts`](../bin/transform-figma-tokens.ts) and contains data in format ready to be used in code.++### Generating Access Token for sync++1. Create a GitHub account if you don't have one.+2. Ask Oleg to add you to the `@webstudio-is/core` team if you are not already in it.+3. Go to https://github.com/settings/personal-access-tokens/new+ - Under "Resource owner" choose "webstudio-is" <br /><img src="./assets/1.png" width="349" />+ - Under "Repository access" choose `webstudio-is/webstudio-designer` <br /><img src="./assets/2.png" width="514" />+ - Set "Repository permissions" / "Contents" to "Read and write", and leave other permissions as is <br /><img src="./assets/3.png" width="806" />+ - Press "Generate token and request access"+ - COPY THE TOKEN NOW AND SAVE IT SOMEWHERE SAFE (you won't be able to see it again)+4. Ask Oleg to approve your token using [this instruction](https://docs.github.com/en/organizations/managing-programmatic-access-to-your-organization/managing-requests-for-personal-access-tokens-in-your-organization).++### Syncing via plugin UI++1. Open a Figma file with design tokens, such as: https://www.figma.com/file/xCBegXEWxROLqA1Y31z2Xo/%F0%9F%93%96-Webstudio-Design-Docs+2. Click "Resources" in the topbar, then "Plugins" > "Tokens Studio for Figma" > Run <br/><img src="./assets/4.png" width="611" />+3. You might be asked for an access token. You can generate one by following the instructions above, or ask someone to share theirs (not recommended).+4. You should be able to sync with GitHub using ↧ and ↥ buttons at the bottom of the plugin window. <br/><img src="./assets/5.png" width="420" />++In case sync provider is not configured in the plugin, you can add one using these settings:++- Name: up to you+- Personal Access Token: token generated using the instructions above+- Repository: `webstudio-is/webstudio-designer`+- Branch: `figma-tokens`+- File Path: `packages/design-system/src/__generated__/figma-design-tokens.json`+- baseUrl: leave empty++### Links++- https://docs.tokens.studio/sync/github — documentation on sync with GitHub by plugin authors+- https://github.com/tokens-studio/figma-plugin/issues/1285 — why we use fine-grained tokens unlike what the documentation above suggestsdiff --git a/packages/design-system/package.json b/packages/design-system/package.jsonindex eedb9ad0ea..fe47abdbac 100644--- a/packages/design-system/package.json+++ b/packages/design-system/package.json@@ -6,8 +6,8 @@"homepage": "https://webstudio.is","type": "module","scripts": {- "dev": "build-package --watch",- "build": "build-package",+ "dev": "tsx ./bin/transform-figma-tokens.ts && build-package --watch",+ "build": "tsx ./bin/transform-figma-tokens.ts && build-package","typecheck": "tsc --noEmit","lint": "eslint ./src --ext .ts,.tsx --max-warnings 0","test": "NODE_OPTIONS=--experimental-vm-modules jest",@@ -72,11 +72,13 @@"@stitches/react": "^1.2.8","@webstudio-is/css-vars": "workspace:^","@webstudio-is/icons": "workspace:^",+ "camelcase": "^6.3.0","downshift": "^6.1.7","immer": "^9.0.12","lodash.merge": "^4.6.2","match-sorter": "^6.3.1","react-hot-toast": "^2.3.0",+ "token-transformer": "^0.0.28","use-debounce": "^9.0.2"},"exports": "./lib/index.js",diff --git a/packages/design-system/src/__generated__/figma-design-tokens.json b/packages/design-system/src/__generated__/figma-design-tokens.jsonnew file mode 100644index 0000000000..cd6f8afb26--- /dev/null+++ b/packages/design-system/src/__generated__/figma-design-tokens.json@@ -0,0 +1,830 @@+{+ "global": {+ "menu drop shadow": {+ "value": [+ {+ "color": "#00000026",+ "type": "dropShadow",+ "x": "0",+ "y": "5",+ "blur": "17",+ "spread": "0"+ },+ {+ "color": "#0000001a",+ "type": "dropShadow",+ "x": "0",+ "y": "2",+ "blur": "7",+ "spread": "0"+ }+ ],+ "type": "boxShadow"+ },+ "fontFamilies": {+ "inter": {+ "value": "Inter",+ "type": "fontFamilies"+ },+ "roboto": {+ "value": "Roboto",+ "type": "fontFamilies"+ },+ "manrope": {+ "value": "Manrope",+ "type": "fontFamilies"+ }+ },+ "lineHeights": {+ "0": {+ "value": "16",+ "type": "lineHeights"+ },+ "1": {+ "value": "8",+ "type": "lineHeights"+ },+ "2": {+ "value": "10",+ "type": "lineHeights"+ },+ "3": {+ "value": "AUTO",+ "type": "lineHeights"+ }+ },+ "fontWeights": {+ "inter-0": {+ "value": "Regular",+ "type": "fontWeights"+ },+ "inter-1": {+ "value": "Medium",+ "type": "fontWeights"+ },+ "inter-2": {+ "value": "Bold",+ "type": "fontWeights"+ },+ "roboto-3": {+ "value": "Regular",+ "type": "fontWeights"+ },+ "inter-4": {+ "value": "Semi Bold",+ "type": "fontWeights"+ },+ "manrope-5": {+ "value": "SemiBold",+ "type": "fontWeights"+ }+ },+ "fontSize": {+ "0": {+ "value": "8",+ "type": "fontSizes"+ },+ "1": {+ "value": "10",+ "type": "fontSizes"+ },+ "2": {+ "value": "12",+ "type": "fontSizes"+ },+ "3": {+ "value": "20",+ "type": "fontSizes"+ },+ "4": {+ "value": "32",+ "type": "fontSizes"+ }+ },+ "letterSpacing": {+ "0": {+ "value": "0.5%",+ "type": "letterSpacing"+ },+ "1": {+ "value": "1%",+ "type": "letterSpacing"+ },+ "2": {+ "value": "0%",+ "type": "letterSpacing"+ },+ "3": {+ "value": "0",+ "type": "letterSpacing"+ }+ },+ "paragraphSpacing": {+ "0": {+ "value": "0",+ "type": "paragraphSpacing"+ }+ },+ "Regular": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-0}",+ "lineHeight": "{lineHeights.0}",+ "fontSize": "{fontSize.2}",+ "letterSpacing": "{letterSpacing.0}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Labels": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-1}",+ "lineHeight": "{lineHeights.0}",+ "fontSize": "{fontSize.2}",+ "letterSpacing": "{letterSpacing.0}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Titles": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-2}",+ "lineHeight": "{lineHeights.0}",+ "fontSize": "{fontSize.2}",+ "letterSpacing": "{letterSpacing.1}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Mono": {+ "value": {+ "fontFamily": "{fontFamilies.roboto}",+ "fontWeight": "{fontWeights.roboto-3}",+ "lineHeight": "{lineHeights.0}",+ "fontSize": "{fontSize.2}",+ "letterSpacing": "{letterSpacing.2}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Tiny": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-1}",+ "lineHeight": "{lineHeights.1}",+ "fontSize": "{fontSize.0}",+ "letterSpacing": "{letterSpacing.1}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Unit": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-1}",+ "lineHeight": "{lineHeights.2}",+ "fontSize": "{fontSize.1}",+ "letterSpacing": "{letterSpacing.3}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.uppercase}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Spacing Section Value Text": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-1}",+ "lineHeight": "{lineHeights.2}",+ "fontSize": "{fontSize.1}",+ "letterSpacing": "{letterSpacing.2}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Spacing Section Unit Text": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-4}",+ "lineHeight": "{lineHeights.1}",+ "fontSize": "{fontSize.0}",+ "letterSpacing": "{letterSpacing.1}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.uppercase}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "Big Title": {+ "value": {+ "fontFamily": "{fontFamilies.inter}",+ "fontWeight": "{fontWeights.inter-1}",+ "lineHeight": "{lineHeights.3}",+ "fontSize": "{fontSize.4}",+ "letterSpacing": "{letterSpacing.0}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ },+ "textCase": {+ "none": {+ "value": "none",+ "type": "textCase"+ },+ "uppercase": {+ "value": "uppercase",+ "type": "textCase"+ }+ },+ "textDecoration": {+ "none": {+ "value": "none",+ "type": "textDecoration"+ }+ },+ "radius": {+ "1": {+ "value": "1px",+ "type": "borderRadius"+ },+ "2": {+ "value": "2px",+ "type": "borderRadius"+ },+ "3": {+ "value": "3px",+ "type": "borderRadius"+ },+ "4": {+ "value": "4px",+ "type": "borderRadius"+ },+ "5": {+ "value": "5px",+ "type": "borderRadius"+ },+ "6": {+ "value": "6px",+ "type": "borderRadius"+ }+ },+ "white": {+ "value": "#ffffff",+ "type": "color"+ },+ "black": {+ "value": "#000000",+ "type": "color"+ },+ "background": {+ "panel": {+ "value": "#f8f8f8",+ "type": "color",+ "description": "background color for all panels, titles, columns and rows."+ },+ "primary": {+ "value": "#0081f1",+ "type": "color",+ "description": "primary color, used in button"+ },+ "hover": {+ "value": "#dfe3e6",+ "type": "color",+ "description": "hover color for toggle group button, icon button, toggle button, small icon button, small toggle button, nested select button, menu item large"+ },+ "active": {+ "value": "#0081f1",+ "type": "color",+ "description": "color for active elements"+ },+ "menu": {+ "value": "#ededed",+ "type": "color",+ "description": "background color for menu and select menu"+ },+ "controls": {+ "value": "#ffffff",+ "type": "color",+ "description": "background color for text input, toggle group, input field, color input, select button, panel button, text-area, search field, checkbox, spacing, flex control"+ },+ "assetcard-hover": {+ "value": "#e6e8eb",+ "type": "color",+ "description": "used only for the hover state for the asset card component"+ },+ "brand-gradient": {+ "value": "linear-gradient(180deg, #e63cfe 0%, #ffae3c 100%)",+ "type": "color"+ },+ "neutral": {+ "main": {+ "value": "#687076",+ "type": "color",+ "description": "used for neutral button"+ },+ "accent": {+ "value": "#11181c",+ "type": "color",+ "description": "accent color on neutral toast"+ },+ "notification": {+ "value": "#ffffff",+ "type": "color",+ "description": "background color on neutral toast"+ }+ },+ "destructive": {+ "main": {+ "value": "#dc3d43",+ "type": "color",+ "description": "used for destructive button and accent color on destructive toast"+ },+ "notification": {+ "value": "#ffefef",+ "type": "color",+ "description": "background for destructive toast"+ }+ },+ "success": {+ "main": {+ "value": "#299764",+ "type": "color",+ "description": "used for success button and accent color on success toast"+ },+ "notification": {+ "value": "#e9f9ee",+ "type": "color",+ "description": "background for success banner & toast"+ }+ },+ "alert": {+ "main": {+ "value": "#f5d90a",+ "type": "color",+ "description": "used for alert button and accent color on alert toast"+ },+ "notification": {+ "value": "#fffbd1",+ "type": "color",+ "description": "background for alert banner & toast"+ }+ },+ "info": {+ "main": {+ "value": "#006adc",+ "type": "color"+ },+ "notification": {+ "value": "#edf6ff",+ "type": "color",+ "description": "background for info banner & toast"+ }+ },+ "preset": {+ "main": {+ "value": "#dfe3e6",+ "type": "color"+ },+ "hover": {+ "value": "#d7dbdf",+ "type": "color"+ }+ },+ "set": {+ "main": {+ "value": "#e1f0ff",+ "type": "color"+ },+ "hover": {+ "value": "#cee7fe",+ "type": "color"+ }+ },+ "inherited": {+ "main": {+ "value": "#ffe8d7",+ "type": "color"+ },+ "hover": {+ "value": "#ffdcc3",+ "type": "color"+ }+ },+ "input": {+ "selected": {+ "value": "#b7d9f8",+ "type": "color",+ "description": "background color for selected text"+ },+ "disabled": {+ "value": "#f8f8f8",+ "type": "color",+ "description": "background for disabled text fields"+ }+ },+ "button": {+ "hover": {+ "value": "#ffffff17",+ "type": "color",+ "description": "transparent color to create the hover state for button"+ },+ "pressed": {+ "value": "#0000001c",+ "type": "color",+ "description": "transparent color to create the pressed state for button"+ },+ "disabled": {+ "value": "#dfe3e6",+ "type": "color",+ "description": "disabled state for button"+ }+ },+ "item": {+ "current": {+ "value": "#0081f1",+ "type": "color",+ "description": "color for current item in the navigator item, menu item, pages panel item components"+ },+ "current-child": {+ "value": "#e1f0ff",+ "type": "color",+ "description": "color for child of current item in the navigator item, pages panel item components"+ },+ "current-hidden": {+ "value": "#7e868c",+ "type": "color",+ "description": "color for the hidden current item in the navigator item component"+ }+ },+ "tooltip": {+ "main": {+ "value": "#11181c",+ "type": "color"+ },+ "designer": {+ "value": "#ffffff",+ "type": "color"+ }+ },+ "spacing": {+ "top-bottom": {+ "value": "#f1f3f5",+ "type": "color"+ },+ "left-right": {+ "value": "#eceef0",+ "type": "color"+ },+ "hover": {+ "value": "#d7dbdf",+ "type": "color"+ }+ },+ "project-card": {+ "front": {+ "value": "linear-gradient(0deg, #fbf8ff 25%, #e2e2e2 66%)",+ "type": "color",+ "description": "big text color in the project card component"+ },+ "back": {+ "value": "linear-gradient(0deg, #fbf8ff 0%, #c7c7c7 100%)",+ "type": "color"+ },+ "text-area": {+ "value": "#ffffffe6",+ "type": "color"+ }+ },+ "published": {+ "main": {+ "value": "#39fbbb",+ "type": "color"+ },+ "contrast": {+ "value": "#ebfffc",+ "type": "color"+ }+ }+ },+ "border": {+ "main": {+ "value": "#c1c8cd",+ "type": "color",+ "description": "color for separators, panel borders, preset borders, input fields, select buttons, panel buttons, text area, search field, menu, select menu, spacing controls, "+ },+ "focus": {+ "value": "#0081f1",+ "type": "color",+ "description": "border color for all focus elements"+ },+ "menu-inner": {+ "value": "#fcfcfc",+ "type": "color",+ "description": "inner border color for menu and select menu"+ },+ "color-swatch": {+ "value": "#687076",+ "type": "color",+ "description": "border color for color swatch"+ },+ "neutral": {+ "value": "#e8e8e8",+ "type": "color",+ "description": "border color for neutral toast"+ },+ "success": {+ "value": "#30a46c",+ "type": "color",+ "description": "border color for success banner & toast"+ },+ "alert": {+ "value": "#f5d90a",+ "type": "color",+ "description": "border color for alert banner & toast"+ },+ "info": {+ "value": "#0091ff",+ "type": "color",+ "description": "border color for info banner & toast"+ },+ "contrast": {+ "value": "#ffffff",+ "type": "color",+ "description": "border color to create contrast on dark/colored elements. Used in button, new position indicator for navigator"+ },+ "published": {+ "value": "#ebfffc",+ "type": "color"+ },+ "item": {+ "child-line": {+ "value": "#889096",+ "type": "color",+ "description": "color of child lines within the navigator item & pages panel item"+ },+ "child-line-current": {+ "value": "#96c7f2",+ "type": "color",+ "description": "color of child lines within the current item of the navigator item & pages panel item"+ }+ },+ "set": {+ "main": {+ "value": "#b7d9f8",+ "type": "color",+ "description": "border color of set elements"+ },+ "flex-ui": {+ "value": "#0091ff",+ "type": "color",+ "description": "border color of set elements within the flex controls ui"+ }+ },+ "inherited": {+ "main": {+ "value": "#ffcca7",+ "type": "color",+ "description": "border color of inherited elements"+ },+ "flex-ui": {+ "value": "#fa934e",+ "type": "color",+ "description": "border color of inherited elements within the flex controls ui"+ }+ },+ "destructive": {+ "main": {+ "value": "#dc3d43",+ "type": "color",+ "description": "border color for destructive input field, text area and search field"+ },+ "notification": {+ "value": "#f9c6c6",+ "type": "color",+ "description": "border color for destructive toast"+ }+ }+ },+ "foreground": {+ "main": {+ "value": "#11181c",+ "type": "color",+ "description": "default color for all text and icons"+ },+ "subtle": {+ "value": "#7e868c",+ "type": "color",+ "description": "color for less prominent elements. Used in small icon button, nested select button, input field, color input, select button, panel button, text area, search field & toast"+ },+ "category-label": {+ "value": "#889096",+ "type": "color",+ "description": "foreground color for the category label element within the font item component"+ },+ "text-subtle": {+ "value": "#687076",+ "type": "color",+ "description": "foreground color for spacing controls text"+ },+ "destructive": {+ "value": "#dc3d43",+ "type": "color",+ "description": "destructive foreground color. Used in input field, text field, search area, & toast"+ },+ "success": {+ "value": "#30a46c",+ "type": "color",+ "description": "success foreground color. Used in toast"+ },+ "info": {+ "value": "#006adc",+ "type": "color",+ "description": "info foreground color. Used in toast"+ },+ "disabled": {+ "value": "#c1c8cd",+ "type": "color",+ "description": "color for disabled foreground elements"+ },+ "hidden-item": {+ "value": "#7e868c",+ "type": "color",+ "description": "color for hidden item element within navigator item component"+ },+ "published": {+ "value": "#005406",+ "type": "color"+ },+ "flex-ui": {+ "main": {+ "value": "#c7c7c7",+ "type": "color",+ "description": "color for flex control ui elements"+ },+ "hover": {+ "value": "#96c7f2",+ "type": "color",+ "description": "color for hovered state of flex control ui elements"+ }+ },+ "contrast": {+ "main": {+ "value": "#ffffff",+ "type": "color",+ "description": "color to create contrast over colored and dark backgrounds"+ },+ "subtle": {+ "value": "#c1c8cd",+ "type": "color",+ "description": "color to create a more subtle contrast over colored and dark backgrounds"+ }+ },+ "set": {+ "main": {+ "value": "#006adc",+ "type": "color",+ "description": "foreground color for set elements"+ },+ "flex-ui": {+ "value": "#0091ff",+ "type": "color",+ "description": "foreground color for flex-ui set elements"+ }+ },+ "inherited": {+ "main": {+ "value": "#bd4b00",+ "type": "color",+ "description": "foreground color for inherited elements"+ },+ "flex-ui": {+ "value": "#fa934e",+ "type": "color",+ "description": "foreground color for flex-ui inherited elements"+ }+ }+ },+ "Brand": {+ "elevation-small": {+ "value": {+ "color": "#1717171a",+ "type": "dropShadow",+ "x": "0",+ "y": "4",+ "blur": "4",+ "spread": "0"+ },+ "type": "boxShadow",+ "description": "elevation for small things within the dashboard"+ },+ "elevation-big": {+ "value": {+ "color": "#1717171a",+ "type": "dropShadow",+ "x": "0",+ "y": "8",+ "blur": "16",+ "spread": "0"+ },+ "type": "boxShadow",+ "description": "elevation for big things within the dashboard"+ },+ "Title": {+ "value": {+ "fontFamily": "{fontFamilies.manrope}",+ "fontWeight": "{fontWeights.manrope-5}",+ "lineHeight": "{lineHeights.3}",+ "fontSize": "{fontSize.3}",+ "letterSpacing": "{letterSpacing.0}",+ "paragraphSpacing": "{paragraphSpacing.0}",+ "paragraphIndent": "{paragraphIndent.0}",+ "textCase": "{textCase.none}",+ "textDecoration": "{textDecoration.none}"+ },+ "type": "typography"+ }+ },+ "inner-glow": {+ "01": {+ "value": {+ "color": "#fbf8ff",+ "type": "innerShadow",+ "x": "0",+ "y": "2",+ "blur": "1",+ "spread": "0"+ },+ "type": "boxShadow"+ },+ "03": {+ "value": {+ "color": "#fbf8ff",+ "type": "innerShadow",+ "x": "0",+ "y": "5",+ "blur": "3",+ "spread": "0"+ },+ "type": "boxShadow"+ },+ "05": {+ "value": {+ "color": "#fbf8ff",+ "type": "innerShadow",+ "x": "0",+ "y": "8",+ "blur": "5",+ "spread": "0"+ },+ "type": "boxShadow"+ }+ },+ "maintenance": {+ "light": {+ "value": "#ededed",+ "type": "color"+ },+ "medium": {+ "value": "#c7c7c7",+ "type": "color"+ },+ "dark": {+ "value": "#858585",+ "type": "color"+ },+ "spacerViz": {+ "value": "#f9c6c6",+ "type": "color"+ }+ }+ },+ "$themes": [],+ "$metadata": {+ "tokenSetOrder": ["global"]+ }+}diff --git a/packages/design-system/src/__generated__/figma-design-tokens.ts b/packages/design-system/src/__generated__/figma-design-tokens.tsnew file mode 100644index 0000000000..f05f5494a0--- /dev/null+++ b/packages/design-system/src/__generated__/figma-design-tokens.ts@@ -0,0 +1,298 @@+// Generated by transform-figma-tokens.ts from ./src/__generated__/figma-design-tokens.json++export const boxShadow = {+ menuDropShadow: [+ { color: "#00000026", type: "dropShadow", x: 0, y: 5, blur: 17, spread: 0 },+ { color: "#0000001a", type: "dropShadow", x: 0, y: 2, blur: 7, spread: 0 },+ ],+ brandElevationSmall: {+ color: "#1717171a",+ type: "dropShadow",+ x: 0,+ y: 4,+ blur: 4,+ spread: 0,+ },+ brandElevationBig: {+ color: "#1717171a",+ type: "dropShadow",+ x: 0,+ y: 8,+ blur: 16,+ spread: 0,+ },+ innerGlow01: {+ color: "#fbf8ff",+ type: "innerShadow",+ x: 0,+ y: 2,+ blur: 1,+ spread: 0,+ },+ innerGlow03: {+ color: "#fbf8ff",+ type: "innerShadow",+ x: 0,+ y: 5,+ blur: 3,+ spread: 0,+ },+ innerGlow05: {+ color: "#fbf8ff",+ type: "innerShadow",+ x: 0,+ y: 8,+ blur: 5,+ spread: 0,+ },+} as const;++export const fontFamilies = {+ inter: "Inter",+ roboto: "Roboto",+ manrope: "Manrope",+} as const;++export const lineHeights = { "0": 16, "1": 8, "2": 10, "3": "AUTO" } as const;++export const fontWeights = {+ inter0: "Regular",+ inter1: "Medium",+ inter2: "Bold",+ roboto3: "Regular",+ inter4: "Semi Bold",+ manrope5: "SemiBold",+} as const;++export const fontSizes = {+ fontSize0: 8,+ fontSize1: 10,+ fontSize2: 12,+ fontSize3: 20,+ fontSize4: 32,+} as const;++export const letterSpacing = {+ "0": "0.5%",+ "1": "1%",+ "2": "0%",+ "3": 0,+} as const;++export const paragraphSpacing = { "0": 0 } as const;++export const typography = {+ regular: {+ fontFamily: "Inter",+ fontWeight: "Regular",+ lineHeight: 16,+ fontSize: 12,+ letterSpacing: "0.5%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ labels: {+ fontFamily: "Inter",+ fontWeight: "Medium",+ lineHeight: 16,+ fontSize: 12,+ letterSpacing: "0.5%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ titles: {+ fontFamily: "Inter",+ fontWeight: "Bold",+ lineHeight: 16,+ fontSize: 12,+ letterSpacing: "1%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ mono: {+ fontFamily: "Roboto",+ fontWeight: "Regular",+ lineHeight: 16,+ fontSize: 12,+ letterSpacing: "0%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ tiny: {+ fontFamily: "Inter",+ fontWeight: "Medium",+ lineHeight: 8,+ fontSize: 8,+ letterSpacing: "1%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ unit: {+ fontFamily: "Inter",+ fontWeight: "Medium",+ lineHeight: 10,+ fontSize: 10,+ letterSpacing: 0,+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "uppercase",+ textDecoration: "none",+ },+ spacingSectionValueText: {+ fontFamily: "Inter",+ fontWeight: "Medium",+ lineHeight: 10,+ fontSize: 10,+ letterSpacing: "0%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ spacingSectionUnitText: {+ fontFamily: "Inter",+ fontWeight: "Semi Bold",+ lineHeight: 8,+ fontSize: 8,+ letterSpacing: "1%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "uppercase",+ textDecoration: "none",+ },+ bigTitle: {+ fontFamily: "Inter",+ fontWeight: "Medium",+ lineHeight: "AUTO",+ fontSize: 32,+ letterSpacing: "0.5%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+ brandTitle: {+ fontFamily: "Manrope",+ fontWeight: "SemiBold",+ lineHeight: "AUTO",+ fontSize: 20,+ letterSpacing: "0.5%",+ paragraphSpacing: 0,+ paragraphIndent: "{paragraphIndent.0}",+ textCase: "none",+ textDecoration: "none",+ },+} as const;++export const textCase = { none: "none", uppercase: "uppercase" } as const;++export const textDecoration = { none: "none" } as const;++export const borderRadius = {+ radius1: "1px",+ radius2: "2px",+ radius3: "3px",+ radius4: "4px",+ radius5: "5px",+ radius6: "6px",+} as const;++export const color = {+ white: "#ffffff",+ black: "#000000",+ backgroundPanel: "#f8f8f8",+ backgroundPrimary: "#0081f1",+ backgroundHover: "#dfe3e6",+ backgroundActive: "#0081f1",+ backgroundMenu: "#ededed",+ backgroundControls: "#ffffff",+ backgroundAssetcardHover: "#e6e8eb",+ backgroundBrandGradient: "linear-gradient(180deg, #e63cfe 0%, #ffae3c 100%)",+ backgroundNeutralMain: "#687076",+ backgroundNeutralAccent: "#11181c",+ backgroundNeutralNotification: "#ffffff",+ backgroundDestructiveMain: "#dc3d43",+ backgroundDestructiveNotification: "#ffefef",+ backgroundSuccessMain: "#299764",+ backgroundSuccessNotification: "#e9f9ee",+ backgroundAlertMain: "#f5d90a",+ backgroundAlertNotification: "#fffbd1",+ backgroundInfoMain: "#006adc",+ backgroundInfoNotification: "#edf6ff",+ backgroundPresetMain: "#dfe3e6",+ backgroundPresetHover: "#d7dbdf",+ backgroundSetMain: "#e1f0ff",+ backgroundSetHover: "#cee7fe",+ backgroundInheritedMain: "#ffe8d7",+ backgroundInheritedHover: "#ffdcc3",+ backgroundInputSelected: "#b7d9f8",+ backgroundInputDisabled: "#f8f8f8",+ backgroundButtonHover: "#ffffff17",+ backgroundButtonPressed: "#0000001c",+ backgroundButtonDisabled: "#dfe3e6",+ backgroundItemCurrent: "#0081f1",+ backgroundItemCurrentChild: "#e1f0ff",+ backgroundItemCurrentHidden: "#7e868c",+ backgroundTooltipMain: "#11181c",+ backgroundTooltipDesigner: "#ffffff",+ backgroundSpacingTopBottom: "#f1f3f5",+ backgroundSpacingLeftRight: "#eceef0",+ backgroundSpacingHover: "#d7dbdf",+ backgroundProjectCardFront: "linear-gradient(0deg, #fbf8ff 25%, #e2e2e2 66%)",+ backgroundProjectCardBack: "linear-gradient(0deg, #fbf8ff 0%, #c7c7c7 100%)",+ backgroundProjectCardTextArea: "#ffffffe6",+ backgroundPublishedMain: "#39fbbb",+ backgroundPublishedContrast: "#ebfffc",+ borderMain: "#c1c8cd",+ borderFocus: "#0081f1",+ borderMenuInner: "#fcfcfc",+ borderColorSwatch: "#687076",+ borderNeutral: "#e8e8e8",+ borderSuccess: "#30a46c",+ borderAlert: "#f5d90a",+ borderInfo: "#0091ff",+ borderContrast: "#ffffff",+ borderPublished: "#ebfffc",+ borderItemChildLine: "#889096",+ borderItemChildLineCurrent: "#96c7f2",+ borderSetMain: "#b7d9f8",+ borderSetFlexUi: "#0091ff",+ borderInheritedMain: "#ffcca7",+ borderInheritedFlexUi: "#fa934e",+ borderDestructiveMain: "#dc3d43",+ borderDestructiveNotification: "#f9c6c6",+ foregroundMain: "#11181c",+ foregroundSubtle: "#7e868c",+ foregroundCategoryLabel: "#889096",+ foregroundTextSubtle: "#687076",+ foregroundDestructive: "#dc3d43",+ foregroundSuccess: "#30a46c",+ foregroundInfo: "#006adc",+ foregroundDisabled: "#c1c8cd",+ foregroundHiddenItem: "#7e868c",+ foregroundPublished: "#005406",+ foregroundFlexUiMain: "#c7c7c7",+ foregroundFlexUiHover: "#96c7f2",+ foregroundContrastMain: "#ffffff",+ foregroundContrastSubtle: "#c1c8cd",+ foregroundSetMain: "#006adc",+ foregroundSetFlexUi: "#0091ff",+ foregroundInheritedMain: "#bd4b00",+ foregroundInheritedFlexUi: "#fa934e",+ maintenanceLight: "#ededed",+ maintenanceMedium: "#c7c7c7",+ maintenanceDark: "#858585",+ maintenanceSpacerViz: "#f9c6c6",+} as const;++export const other = { tokenSetOrder0: "global" } as const;diff --git a/packages/design-system/src/design-tokens.json b/packages/design-system/src/design-tokens.jsonindex c0728eaaee..cd6f8afb26 100644--- a/packages/design-system/src/design-tokens.json+++ b/packages/design-system/src/design-tokens.json@@ -5,18 +5,18 @@{"color": "#00000026","type": "dropShadow",- "x": 0,- "y": 5,- "blur": 17,- "spread": 0+ "x": "0",+ "y": "5",+ "blur": "17",+ "spread": "0"},{"color": "#0000001a","type": "dropShadow",- "x": 0,- "y": 2,- "blur": 7,- "spread": 0+ "x": "0",+ "y": "2",+ "blur": "7",+ "spread": "0"}],"type": "boxShadow"@@ -646,7 +646,7 @@"type": "color","description": "foreground color for the category label element within the font item component"},- "spacing": {+ "text-subtle": {"value": "#687076","type": "color","description": "foreground color for spacing controls text"@@ -734,10 +734,10 @@"value": {"color": "#1717171a","type": "dropShadow",- "x": 0,- "y": 4,- "blur": 4,- "spread": 0+ "x": "0",+ "y": "4",+ "blur": "4",+ "spread": "0"},"type": "boxShadow","description": "elevation for small things within the dashboard"@@ -746,10 +746,10 @@"value": {"color": "#1717171a","type": "dropShadow",- "x": 0,- "y": 8,- "blur": 16,- "spread": 0+ "x": "0",+ "y": "8",+ "blur": "16",+ "spread": "0"},"type": "boxShadow","description": "elevation for big things within the dashboard"@@ -774,10 +774,10 @@"value": {"color": "#fbf8ff","type": "innerShadow",- "x": 0,- "y": 2,- "blur": 1,- "spread": 0+ "x": "0",+ "y": "2",+ "blur": "1",+ "spread": "0"},"type": "boxShadow"},@@ -785,10 +785,10 @@"value": {"color": "#fbf8ff","type": "innerShadow",- "x": 0,- "y": 5,- "blur": 3,- "spread": 0+ "x": "0",+ "y": "5",+ "blur": "3",+ "spread": "0"},"type": "boxShadow"},@@ -796,15 +796,15 @@"value": {"color": "#fbf8ff","type": "innerShadow",- "x": 0,- "y": 8,- "blur": 5,- "spread": 0+ "x": "0",+ "y": "8",+ "blur": "5",+ "spread": "0"},"type": "boxShadow"}},- "👷♂️ maintenance": {+ "maintenance": {"light": {"value": "#ededed","type": "color"@@ -825,8 +825,6 @@},"$themes": [],"$metadata": {- "tokenSetOrder": [- "global"- ]+ "tokenSetOrder": ["global"]}-}\ No newline at end of file+}diff --git a/packages/design-system/src/stitches.config.ts b/packages/design-system/src/stitches.config.tsindex d9b4fee496..0f8dc364d2 100644--- a/packages/design-system/src/stitches.config.ts+++ b/packages/design-system/src/stitches.config.ts@@ -117,6 +117,7 @@ import {} from "@radix-ui/colors";import type * as Stitches from "@stitches/react";export type { VariantProps } from "@stitches/react";+import { color as figmaColors } from "./__generated__/figma-design-tokens";const spacing = {0: "0px",@@ -170,6 +171,8 @@ const {} = createStitches({theme: {colors: {+ ...figmaColors,+...gray,...mauve,...slate,diff --git a/packages/design-system/tsconfig.json b/packages/design-system/tsconfig.jsonindex c5f13fda36..a57ebd8d14 100644--- a/packages/design-system/tsconfig.json+++ b/packages/design-system/tsconfig.json@@ -1,6 +1,6 @@{"extends": "@webstudio-is/tsconfig/base.json",- "include": ["src"],+ "include": ["src", "bin/transform.ts"],"compilerOptions": {"lib": ["DOM", "DOM.Iterable", "ES2020"],"module": "ES2020",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d874be5fae..61b197b8f2 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -416,6 +416,7 @@ importers:'@webstudio-is/scripts': workspace:^'@webstudio-is/storybook-config': workspace:^'@webstudio-is/tsconfig': workspace:^+ camelcase: ^6.3.0downshift: ^6.1.7immer: ^9.0.12jest: ^29.3.1@@ -424,6 +425,7 @@ importers:react: ^17.0.2react-dom: 17.0.2react-hot-toast: ^2.3.0+ token-transformer: ^0.0.28typescript: 4.7.4use-debounce: ^9.0.2dependencies:@@ -460,11 +462,13 @@ importers:'@stitches/react': [email protected]'@webstudio-is/css-vars': link:../css-vars'@webstudio-is/icons': link:../icons+ camelcase: 6.3.0downshift: [email protected]immer: 9.0.15lodash.merge: 4.6.2match-sorter: 6.3.1react-hot-toast: 2.3.0_sfoxds7t5ydpegc3knd667wn6m+ token-transformer: 0.0.28use-debounce: [email protected]devDependencies:'@jest/globals': 29.3.1@@ -20833,6 +20837,13 @@ packages:resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}engines: {node: '>=0.6'}+ /token-transformer/0.0.28:+ resolution: {integrity: sha512-DINP+5T3ruZwOWMNd5mJMiM3h5YvwZEoRL+NAKZf+e93/5Vy1P0R5eWeaynCWcqprPNm4ceV5CPgjqo1u48big==}+ hasBin: true+ dependencies:+ yargs: 17.6.2+ dev: false+/toml/3.0.0:resolution: {integrity: sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==}dev: true