diff --git a/packages/react/src/docs/colors.mdx b/packages/react/src/docs/colors.mdx index 6435a9b..18d07af 100644 --- a/packages/react/src/docs/colors.mdx +++ b/packages/react/src/docs/colors.mdx @@ -10,6 +10,19 @@ export const tints = [900, 800, 700, 600, 500, 400, 300, 200, 100]; Cunningham comes with an existing toolkit to deal with colors, and it's easy. 🎨 +### Contextual Backgrounds + + + `} +/> + + + ## Background color You can use custom utility classes to set the background color of an element. These classes are named using the format `.bg-{color}`. @@ -19,7 +32,7 @@ You can use custom utility classes to set the background color of an element. Th dark format={false} code={` -
+
`} /> @@ -27,6 +40,8 @@ You can find all existing classes below. + + ## Text color You can use custom utility classes to set the color attribute of an element. These classes are named using the format `.clr-{color}`. diff --git a/packages/react/src/docs/colors.stories.tsx b/packages/react/src/docs/colors.stories.tsx index 1c52e9d..9e8023d 100644 --- a/packages/react/src/docs/colors.stories.tsx +++ b/packages/react/src/docs/colors.stories.tsx @@ -1,5 +1,6 @@ import type { Meta, StoryObj } from "@storybook/react"; import React from "react"; +import { tokens } from ":/cunningham-tokens"; const meta: Meta = { title: "Misc/Colors", @@ -9,20 +10,49 @@ export default meta; type Story = StoryObj<{}>; const colors = [ - "primary", - "secondary", - "greyscale", + "brand", + "gray", "success", "info", "warning", - "danger", + "error", + "red", + "orange", + "brown", + "yellow", + "green", + "blue-1", + "blue-2", + "purple", + "pink", +]; +const tints = [ + 950, + 900, + 850, + 800, + 750, + 700, + 650, + 600, + 550, + 500, + 450, + 400, + 350, + 300, + 250, + 200, + 150, + 100, + "050", ]; -const tints = [900, 800, 700, 600, 500, 400, 300, 200, 100]; export const BackgroundColors: Story = { render: () => { return (
+
{}
{colors.map((color) => (
{tints.map((tint) => ( @@ -41,7 +71,7 @@ export const BackgroundColors: Story = { style={{ width: "72px", height: "48px" }} className={"bg-" + color + "-" + tint} /> -
+                
                   bg-{color}-{tint}
                 
@@ -53,6 +83,111 @@ export const BackgroundColors: Story = { }, }; +export const ContextualBackgrounds: Story = { + render: () => { + const { background } = tokens.themes.default.contextuals; + + // Extract all background values from the contextuals + const backgroundEntries = Object.entries(background).flatMap( + ([category, values]) => { + if (typeof values === "object" && values !== null) { + return Object.entries(values).map(([key, value]) => ({ + category, + key, + value, + fullKey: `${category}-${key}`, + })); + } + return []; + } + ); + + // Group by category + const groupedBackgrounds = backgroundEntries.reduce( + (acc, entry) => { + if (!acc[entry.category]) { + acc[entry.category] = []; + } + acc[entry.category].push(entry); + return acc; + }, + {} as Record + ); + + return ( +
+ {Object.entries(groupedBackgrounds).map(([category, entries]) => ( +
+

+ {category} +

+
+ {entries.map(({ key, value, fullKey }) => ( +
+
+ {key} +
+ {value} +
+
+ .bg-{fullKey} +
+
+ ))} +
+
+ ))} +
+ ); + }, +}; + export const TextColors: Story = { render: () => { return ( @@ -90,13 +225,13 @@ export const Example: Story = { render: () => { return ( <> -
+
I am a text on top of a primary-500 background 👋
-
+
I am a text on top of a secondary-500 background 👋
-
+
I am a text on top of a danger-500 background 👋
diff --git a/packages/react/src/docs/spacings.stories.tsx b/packages/react/src/docs/spacings.stories.tsx index a33923c..07988e8 100644 --- a/packages/react/src/docs/spacings.stories.tsx +++ b/packages/react/src/docs/spacings.stories.tsx @@ -33,12 +33,12 @@ export const Default: Story = { {value}
); - }, + } )}
); @@ -48,11 +48,11 @@ export const Default: Story = { export const Example: Story = { render: () => { return ( -
-
+
+
Tiny padding + Large margin bottom
-
+
Large padding + Base margin left