From 85b676c90caae420e79b6c3aadbeafcf7a06934b Mon Sep 17 00:00:00 2001 From: Jamie Henson Date: Mon, 18 Nov 2024 22:16:08 +0000 Subject: [PATCH 1/7] chore: bump version to 14.9.0 --- package.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3da91365a..dca92dea0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ably/ui", - "version": "14.8.0", + "version": "14.9.0", "description": "Home of the Ably design system library ([design.ably.com](https://design.ably.com)). It provides a showcase, development/test environment and a publishing pipeline for different distributables.", "repository": { "type": "git", @@ -59,9 +59,8 @@ "build:swc": "swc src/core src/reset -d dist --copy-files --include-dotfiles --strip-leading-paths --config-file .swc --ignore **/*.stories.tsx,**/*.snap", "build:tsc": "tsc && node tsc.js && rm -r types", "build:cleanup": "mv dist/* . && rm -r dist", - "build:colors": "ts-node scripts/compute-colors.ts", "build:sprites": "ts-node scripts/generate-sprites.ts", - "build": "yarn build:prebuild && yarn build:colors && yarn build:sprites && yarn build:swc && yarn build:tsc && yarn build:cleanup", + "build": "yarn build:prebuild && yarn build:sprites && yarn build:swc && yarn build:tsc && yarn build:cleanup", "watch": "yarn build:swc -w", "format:check": "prettier -c *.{js,ts} src/**/*.{js,ts,tsx}", "format:write": "prettier -w *.{js,ts} src/**/*.{js,ts,tsx}", From a97e2dd74b048fe92c1591df2b12ba2c3a34d6bf Mon Sep 17 00:00:00 2001 From: Jamie Henson Date: Mon, 18 Nov 2024 17:29:29 +0000 Subject: [PATCH 2/7] chore: update code text size values --- src/core/styles/properties.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/styles/properties.css b/src/core/styles/properties.css index fde0800e7..c1fa135a6 100644 --- a/src/core/styles/properties.css +++ b/src/core/styles/properties.css @@ -199,8 +199,8 @@ --fs-menu2: 0.938rem; --fs-menu3: 0.875rem; --fs-quote: 1.25rem; - --fs-code: 0.938rem; - --fs-code2: 0.813rem; + --fs-code: 0.813rem; + --fs-code2: 0.688rem; --lh-dense: 1; --lh-tight: 1.125; From b6224b6480023bf40995c523010c95d87f4020bd Mon Sep 17 00:00:00 2001 From: Jamie Henson Date: Mon, 18 Nov 2024 17:29:59 +0000 Subject: [PATCH 3/7] fix: add module declarations for scripts folder --- tsc.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tsc.js b/tsc.js index 6e5a51c1d..236930f56 100644 --- a/tsc.js +++ b/tsc.js @@ -64,6 +64,12 @@ dtsFiles.forEach((file) => { ); }); +const additionalModules = ["@ably/ui/core/scripts"]; + +additionalModules.forEach((module) => { + fs.appendFileSync(indexPath, `declare module '${module}';\n\n`, "utf8"); +}); + console.log( `🔬 index.d.ts file has been generated with ${dtsFiles.length} exports.`, ); From 634539ac313a54e91c618107f2af1eeaf371dde1 Mon Sep 17 00:00:00 2001 From: Jamie Henson Date: Mon, 18 Nov 2024 22:16:59 +0000 Subject: [PATCH 4/7] chore: prepare more fitting dark mode styling for Storybook --- .storybook/application.css | 30 ++++++++++++++++++++++++++++++ .storybook/preview.tsx | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.storybook/application.css b/.storybook/application.css index 37b2d1916..1e82818f7 100644 --- a/.storybook/application.css +++ b/.storybook/application.css @@ -28,3 +28,33 @@ var(--double) var(--double), var(--double) var(--double); } + +.ui-theme-dark, +.ui-theme-dark .sbdocs { + @apply bg-neutral-1300; +} + +.sb-show-main.dark .sb-bar, +.sb-show-main.dark .sb-anchor > p > code { + @apply bg-neutral-1200; +} + +.sb-show-main.dark .docblock-code-toggle { + @apply bg-neutral-1200 text-neutral-000; +} + +.sb-show-main.dark .sbdocs h1, +.sb-show-main.dark .sb-anchor > h3, +.sb-show-main.dark .sb-anchor > p, +.sb-show-main.dark .sb-anchor > p > code { + @apply text-neutral-000; +} + +.sb-show-main.dark .sbdocs td, +.sb-show-main.dark .sbdocs th { + @apply text-neutral-200; +} + +.sb-show-main.dark .sbdocs td { + @apply bg-neutral-1100 text-neutral-200; +} diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 214641d38..390e87e5e 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -52,8 +52,8 @@ const preview = { brandImage: brandImage, }, stylePreview: true, - darkClass: ["bg-neutral-1300"], - lightClass: ["bg-neutral-000"], + darkClass: ["dark"], + lightClass: ["light"], }, }, loaders: [mswLoader], From 1e9e54ef054c741dd40210c666082b0f56cf7c68 Mon Sep 17 00:00:00 2001 From: Jamie Henson Date: Mon, 18 Nov 2024 22:17:53 +0000 Subject: [PATCH 5/7] feat: use Tailwind theming prefixes over custom approach --- .storybook/application.css | 22 +- .storybook/preview.tsx | 4 +- scripts/compute-colors.ts | 81 - .../ContactFooter.stories.tsx.snap | 6 +- .../__snapshots__/Expander.stories.tsx.snap | 2 +- src/core/FeaturedLink.tsx | 4 +- .../FeaturedLink.stories.tsx.snap | 10 +- .../__snapshots__/Footer.stories.tsx.snap | 12 +- src/core/Icon.tsx | 97 +- src/core/Icon/EncapsulatedIcon.tsx | 12 +- src/core/Icon/Icon.stories.tsx | 66 +- .../Icon/__snapshots__/Icon.stories.tsx.snap | 1637 +++++++---------- src/core/Pricing/PricingCards.stories.tsx | 11 +- src/core/Pricing/PricingCards.tsx | 165 +- src/core/Pricing/data.tsx | 44 +- src/core/Pricing/types.ts | 6 +- src/core/ProductTile.tsx | 61 +- src/core/ProductTile/ProductTile.stories.tsx | 2 +- .../ProductTile.stories.tsx.snap | 206 +-- .../__snapshots__/Slider.stories.tsx.snap | 42 +- .../__snapshots__/Table.stories.tsx.snap | 30 +- src/core/Tooltip.tsx | 12 +- .../__snapshots__/Tooltip.stories.tsx.snap | 24 +- src/core/hooks/useTheming.tsx | 25 - .../__snapshots__/Button.stories.tsx.snap | 18 +- .../__snapshots__/Forms.stories.tsx.snap | 4 +- src/core/styles/colors/Colors.stories.tsx | 43 +- .../__snapshots__/Colors.stories.tsx.snap | 543 +++--- src/core/styles/colors/types.ts | 10 +- tailwind.config.js | 1 + 30 files changed, 1430 insertions(+), 1770 deletions(-) delete mode 100644 scripts/compute-colors.ts delete mode 100644 src/core/hooks/useTheming.tsx diff --git a/.storybook/application.css b/.storybook/application.css index 1e82818f7..7bb271778 100644 --- a/.storybook/application.css +++ b/.storybook/application.css @@ -34,27 +34,27 @@ @apply bg-neutral-1300; } -.sb-show-main.dark .sb-bar, -.sb-show-main.dark .sb-anchor > p > code { +.ui-theme-dark .sb-bar, +.ui-theme-dark .sb-anchor > p > code { @apply bg-neutral-1200; } -.sb-show-main.dark .docblock-code-toggle { +.ui-theme-dark .docblock-code-toggle { @apply bg-neutral-1200 text-neutral-000; } -.sb-show-main.dark .sbdocs h1, -.sb-show-main.dark .sb-anchor > h3, -.sb-show-main.dark .sb-anchor > p, -.sb-show-main.dark .sb-anchor > p > code { +.ui-theme-dark .sbdocs-content > *, +.ui-theme-dark .sb-anchor > h3, +.ui-theme-dark .sb-anchor > p, +.ui-theme-dark .sb-anchor > p > code { @apply text-neutral-000; } -.sb-show-main.dark .sbdocs td, -.sb-show-main.dark .sbdocs th { +.ui-theme-dark .sbdocs td, +.ui-theme-dark .sbdocs th { @apply text-neutral-200; } -.sb-show-main.dark .sbdocs td { - @apply bg-neutral-1100 text-neutral-200; +.ui-theme-dark .sbdocs td { + @apply !bg-neutral-1100 text-neutral-200; } diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 390e87e5e..96a24aa1c 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -52,8 +52,8 @@ const preview = { brandImage: brandImage, }, stylePreview: true, - darkClass: ["dark"], - lightClass: ["light"], + darkClass: ["ui-theme-dark"], + lightClass: ["ui-theme-light"], }, }, loaders: [mswLoader], diff --git a/scripts/compute-colors.ts b/scripts/compute-colors.ts deleted file mode 100644 index 95e8a2511..000000000 --- a/scripts/compute-colors.ts +++ /dev/null @@ -1,81 +0,0 @@ -import fs from "fs"; -import path from "path"; -import { invertTailwindClassVariant } from "../src/core/styles/colors/utils"; -import { colors, prefixes, variants } from "../src/core/styles/colors/types"; - -const directoryPath = path.join(__dirname, "../src"); -const outputPath = path.join( - __dirname, - "../src/core/styles/colors", - "computed-colors.json", -); - -const joinedVariants = variants.join("|"); -const joinedPrefixes = prefixes.join("|"); -const joinedColors = colors.join("|"); -const pattern = `themeColor\\("((?:${joinedVariants}-)(${joinedPrefixes})-(${joinedColors})-(000|[1-9]00|1[0-3]00))"\\)`; -const regex = new RegExp(pattern, "g"); - -const findStringInFiles = (dir: string) => { - const results: string[] = []; - - const readDirectory = (dir: string) => { - let files: string[]; - try { - files = fs.readdirSync(dir); - } catch (error) { - console.error(`Error reading directory ${dir}:`, error); - return; - } - - files.forEach((file) => { - const filePath = path.join(dir, file); - let stat; - try { - stat = fs.statSync(filePath); - } catch (error) { - console.error(`Error accessing ${filePath}:`, error); - return; - } - - if (stat.isDirectory()) { - readDirectory(filePath); - } else if (filePath.endsWith(".tsx")) { - let content = ""; - try { - content = fs.readFileSync(filePath, "utf-8"); - const matches = [...content.matchAll(regex)].map((match) => match[1]); - - if (matches.length > 0) { - results.push(...matches); - } - } catch (error) { - console.error(`Error reading file ${filePath}:`, error); - return; - } - } - }); - }; - - readDirectory(dir); - return Array.from(new Set(results)).sort(); -}; - -const matches = findStringInFiles(directoryPath); - -const flippedMatches = matches.map((match) => - invertTailwindClassVariant(match), -); - -try { - const outputDir = path.dirname(outputPath); - if (!fs.existsSync(outputDir)) { - fs.mkdirSync(outputDir, { recursive: true }); - } - fs.writeFileSync(outputPath, JSON.stringify(flippedMatches)); - console.log( - `🎨 Tailwind theme classes have been computed and written to JSON files.`, - ); -} catch (error) { - console.error(`Error persisting computed colors:`, error); -} diff --git a/src/core/ContactFooter/__snapshots__/ContactFooter.stories.tsx.snap b/src/core/ContactFooter/__snapshots__/ContactFooter.stories.tsx.snap index 9678682c5..82458df10 100644 --- a/src/core/ContactFooter/__snapshots__/ContactFooter.stories.tsx.snap +++ b/src/core/ContactFooter/__snapshots__/ContactFooter.stories.tsx.snap @@ -6,7 +6,7 @@ exports[`JS Components/Contact Footer Default smoke-test 1`] = ` >