From ac87c45e26a128feb6158053b23aad0b77ec0fd7 Mon Sep 17 00:00:00 2001 From: Joschka de Cuveland Date: Wed, 8 Nov 2023 18:34:49 +0100 Subject: [PATCH] feat!: remove support for stitches more information in #82 BREAKING CHANGE: will no longer work for projects using stitches --- build.ts | 88 ------------------------ package.json | 2 +- website/docs/how-to/use-with-stitches.md | 20 ------ website/docs/intro.md | 4 -- 4 files changed, 1 insertion(+), 113 deletions(-) delete mode 100644 website/docs/how-to/use-with-stitches.md diff --git a/build.ts b/build.ts index f863279..be2e2b0 100644 --- a/build.ts +++ b/build.ts @@ -76,83 +76,6 @@ StyleDictionary.registerFormat({ }, }); -StyleDictionary.registerFormat({ - name: "stitches", - formatter: ({ dictionary, file }: { dictionary: Dictionary; file: File }) => { - return format( - `${fileHeader({ file })}export default ${JSON.stringify( - dictionary.allTokens.reduce( - (acc, token) => { - invariant(token.attributes, "Token attributes are undefined."); - const { category, type, item } = token.attributes; - // console.log(category, type, item, token); - - if (token.path[0] === "color" && token.path[1] === "base") { - if (token.path.at(-1)?.match(/\d{2,3}/)) { - return merge(acc, { - theme: { - colors: token.path.slice(2, -2).reduceRight( - (acc, k) => { - return { [k]: acc }; - }, - { - [`${token.path.at(-2)}${token.path.at(-1)}`]: - token.value, - } - ), - }, - }); - } - return merge(acc, { - theme: { - colors: token.path.slice(2).reduceRight((acc, k) => { - return { [k]: acc }; - }, token.value), - }, - }); - } - - if (category === "size" && type === "spacing") { - return merge(acc, { - theme: { - space: { - [item as string]: token.value, - }, - }, - }); - } - - if (token.path[0] === "font" && token.path[1] === "family") { - return merge(acc, { - theme: { - fontFamily: { - [token.name]: token.value, - }, - }, - }); - } - - return acc; - }, - { - theme: { - colors: { - inherit: "inherit", - current: "currentColor", - transparent: "transparent", - }, - fontFamily: {}, - }, - } - ), - null, - 2 - )};`, - { parser: "babel" } - ); - }, -}); - const getStyleDictionaryConfig = (brand: string, platform: string) => { return { source: [ @@ -184,17 +107,6 @@ const getStyleDictionaryConfig = (brand: string, platform: string) => { }, ], }, - stitches: { - buildPath: - brand === "default" ? "dist/stitches/" : `dist/stitches/${brand}/`, - transforms: ["attribute/cti", "name/cti/camel", "size/rem"], - files: [ - { - destination: "index.js", - format: "stitches", - }, - ], - }, }, }; }; diff --git a/package.json b/package.json index 40ff8a2..60e4fc9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "clean": "rimraf dist", "build": "ts-node build.ts && npm run ts-types", - "ts-types": "tsc --emitDeclarationOnly --esModuleInterop --module nodenext --moduleResolution nodenext --target es2015 -d --allowJs ./dist/stitches/index.js ./dist/tailwind/index.js", + "ts-types": "tsc --emitDeclarationOnly --esModuleInterop --module nodenext --moduleResolution nodenext --target es2015 -d --allowJs ./dist/tailwind/index.js", "lint": "eslint . --ext .ts", "postversion": "cp package.json LICENSE README.md ./dist/", "test": "jest test/*" diff --git a/website/docs/how-to/use-with-stitches.md b/website/docs/how-to/use-with-stitches.md deleted file mode 100644 index a4d75b6..0000000 --- a/website/docs/how-to/use-with-stitches.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -sidebar_position: 4 ---- - -# Use with Stitches - -See [Stitches docs](https://stitches.dev/docs/tokens) for more information. - -```js - // stitches.config.js|ts - import stitchesConfig from "@digitalservice4germany/style-dictionary/stitches"; - export const { css, … } = createStitches(stitchesConfig); - - // use in code - const button = css({ - backgroundColor: "$blue900" - }); -``` - -Only a sensible subset of the tokens is available in the Stitches configuration. diff --git a/website/docs/intro.md b/website/docs/intro.md index 74217ef..2b3afb2 100644 --- a/website/docs/intro.md +++ b/website/docs/intro.md @@ -8,14 +8,12 @@ Currently the following platforms are supported. Please get in touch if you need - JavaScript/TypeScript - [Tailwind CSS](https://tailwindcss.com/) -- [Stitches](https://stitches.dev/) (CSS-in-JS) ## How-to guides - [Install](./how-to/install.md) - [Use with Tailwind](./how-to/use-with-tailwind.md) - [Use with JS/TS](./how-to/use-with-javascript.md) -- [Use with Stitches](./how-to/use-with-stitches.md) ## Reference @@ -26,5 +24,3 @@ Currently the following platforms are supported. Please get in touch if you need - [Spacing](./explanation/spacing.md) - [Colors](./explanation/colors.md) - -