@kaizen/tailwind 1.2.14 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/cjs/index.cjs +5 -0
  2. package/dist/cjs/kz-spacing.cjs +21 -0
  3. package/dist/cjs/tailwind-presets.cjs +112 -0
  4. package/dist/esm/index.mjs +1 -0
  5. package/dist/esm/kz-spacing.mjs +18 -0
  6. package/dist/esm/tailwind-presets.mjs +109 -0
  7. package/dist/{index.d.ts → types/index.d.ts} +0 -1
  8. package/dist/{kz-height.d.ts → types/kz-height.d.ts} +0 -1
  9. package/dist/{kz-spacing.d.ts → types/kz-spacing.d.ts} +0 -1
  10. package/dist/{tailwind-presets.d.ts → types/tailwind-presets.d.ts} +0 -1
  11. package/package.json +17 -6
  12. package/src/_docs/assets/copy-utility-class.gif +0 -0
  13. package/src/_docs/assets/css-generation.png +0 -0
  14. package/src/_docs/assets/inline-fold.gif +0 -0
  15. package/src/_docs/assets/tailwind-play.gif +0 -0
  16. package/src/_docs/assets/tw-anatomy.png +0 -0
  17. package/src/_docs/assets/utility-search-result.png +0 -0
  18. package/src/_docs/pages/backgrounds/background-color.mdx +10 -0
  19. package/src/_docs/pages/backgrounds/background-color.stories.tsx +43 -0
  20. package/src/_docs/pages/borders/border-color.mdx +10 -0
  21. package/src/_docs/pages/borders/border-color.stories.tsx +45 -0
  22. package/src/_docs/pages/borders/border-radius.mdx +10 -0
  23. package/src/_docs/pages/borders/border-radius.stories.tsx +47 -0
  24. package/src/_docs/pages/borders/border-spacing.mdx +10 -0
  25. package/src/_docs/pages/borders/border-spacing.stories.tsx +52 -0
  26. package/src/_docs/pages/borders/border-width.mdx +28 -0
  27. package/src/_docs/pages/borders/border-width.stories.tsx +47 -0
  28. package/src/_docs/pages/configuration.mdx +78 -0
  29. package/src/_docs/pages/contributing.mdx +38 -0
  30. package/src/_docs/pages/effects/shadow.mdx +10 -0
  31. package/src/_docs/pages/effects/shadow.stories.tsx +40 -0
  32. package/src/_docs/pages/getting-started.mdx +125 -0
  33. package/src/_docs/pages/modifiers/media-queries.mdx +16 -0
  34. package/src/_docs/pages/modifiers/media-queries.stories.tsx +81 -0
  35. package/src/_docs/pages/modifiers/pseudo-states.mdx +26 -0
  36. package/src/_docs/pages/modifiers/pseudo-states.stories.tsx +49 -0
  37. package/src/_docs/pages/overview.mdx +26 -0
  38. package/src/_docs/pages/spacing/margin.mdx +27 -0
  39. package/src/_docs/pages/spacing/margin.stories.tsx +49 -0
  40. package/src/_docs/pages/spacing/padding.mdx +27 -0
  41. package/src/_docs/pages/spacing/padding.stories.tsx +47 -0
  42. package/src/_docs/pages/typography/font-family.mdx +10 -0
  43. package/src/_docs/pages/typography/font-family.stories.tsx +41 -0
  44. package/src/_docs/pages/typography/font-size.mdx +10 -0
  45. package/src/_docs/pages/typography/font-size.stories.tsx +38 -0
  46. package/src/_docs/pages/typography/font-weight.mdx +10 -0
  47. package/src/_docs/pages/typography/font-weight.stories.tsx +41 -0
  48. package/src/_docs/pages/typography/line-height.mdx +10 -0
  49. package/src/_docs/pages/typography/line-height.stories.tsx +44 -0
  50. package/src/_docs/pages/typography/max-text-width.mdx +12 -0
  51. package/src/_docs/pages/typography/max-text-width.stories.tsx +60 -0
  52. package/src/_docs/pages/typography/text-color.mdx +10 -0
  53. package/src/_docs/pages/typography/text-color.stories.tsx +52 -0
  54. package/src/_docs/pages/utility-class-helpers-overview.mdx +95 -0
  55. package/src/_docs/pages/working-with-tailwind.mdx +85 -0
  56. package/src/_docs/pages/working-with-tailwind.stories.tsx +100 -0
  57. package/src/_docs/utils/TailwindStoryTemplate/TailwindStoryTemplate.tsx +81 -0
  58. package/src/_docs/utils/TailwindStoryTemplate/components/CardContent/CardContent.tsx +26 -0
  59. package/src/_docs/utils/TailwindStoryTemplate/components/CardContent/index.ts +1 -0
  60. package/src/_docs/utils/TailwindStoryTemplate/components/CodeSnippet/CodeSnippet.tsx +36 -0
  61. package/src/_docs/utils/TailwindStoryTemplate/components/CodeSnippet/index.ts +1 -0
  62. package/src/_docs/utils/TailwindStoryTemplate/index.ts +1 -0
  63. package/src/_docs/utils/flattenEntries.ts +37 -0
  64. package/src/_docs/utils/utilityDescription.ts +5 -0
  65. package/src/tailwind-presets.ts +53 -53
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js +0 -18
  68. package/dist/index.js.map +0 -1
  69. package/dist/kz-height.d.ts.map +0 -1
  70. package/dist/kz-height.js +0 -16
  71. package/dist/kz-height.js.map +0 -1
  72. package/dist/kz-spacing.d.ts.map +0 -1
  73. package/dist/kz-spacing.js +0 -41
  74. package/dist/kz-spacing.js.map +0 -1
  75. package/dist/tailwind-presets.d.ts.map +0 -1
  76. package/dist/tailwind-presets.js +0 -112
  77. package/dist/tailwind-presets.js.map +0 -1
@@ -0,0 +1,47 @@
1
+ import React from "react"
2
+ import { Meta, StoryFn } from "@storybook/react"
3
+ import classnames from "classnames"
4
+ import { TailwindStoryTemplate } from "~tailwind/_docs/utils/TailwindStoryTemplate"
5
+ import { utilityDescription } from "~tailwind/_docs/utils/utilityDescription"
6
+ import { kaizenTailwindTheme } from "~tailwind/tailwind-presets"
7
+
8
+ const prefix = "border-"
9
+ const classEntries: Array<{ utilityClassName: string; cssProperty: string }> =
10
+ Object.entries(kaizenTailwindTheme.borderWidth || []).map(
11
+ ([suffix, cssProperty]) => ({
12
+ utilityClassName: `${prefix}${suffix}`,
13
+ cssProperty,
14
+ })
15
+ )
16
+
17
+ export default {
18
+ title: "Guides/Tailwind/Utility Class References/Borders/Border Width",
19
+ parameters: {
20
+ a11y: { disable: true },
21
+ chromatic: { disable: false },
22
+ docsLayout: "fullPage",
23
+ docs: {
24
+ description: {
25
+ component: utilityDescription(prefix, classEntries[1].utilityClassName),
26
+ },
27
+ },
28
+ },
29
+ } satisfies Meta
30
+
31
+ export const BorderWidth: StoryFn<{ isReversed: boolean }> = ({
32
+ isReversed,
33
+ }) => (
34
+ <TailwindStoryTemplate
35
+ compiledCssPropertyName="border-width"
36
+ classKeyValues={classEntries}
37
+ renderExampleComponent={(utilityClass): React.ReactElement => (
38
+ <div
39
+ className={classnames(
40
+ "w-[100px] h-[100px] border rounded",
41
+ !utilityClass.includes("-DEFAULT") && utilityClass
42
+ )}
43
+ />
44
+ )}
45
+ isReversed={isReversed}
46
+ />
47
+ )
@@ -0,0 +1,78 @@
1
+ import { Meta } from "@storybook/blocks"
2
+ import { InlineNotification } from "~components/Notification"
3
+
4
+ <Meta title="Guides/Tailwind/Configuration" />
5
+
6
+ # Configuration
7
+
8
+ This page provides guidance on potential configuration options and how they work with the preset and Kaizen components.
9
+
10
+ - [Extending the Kaizen preset](#extending-the-kaizen-preset)
11
+ - [Customising the important selector](#customising-the-important-selector)
12
+
13
+ <br/>
14
+
15
+ ## Extending the Kaizen preset
16
+
17
+ > Extending your config is a good option when you intend to _reuse_ the style.
18
+ > If you need a value not available in our preset for a specific use case, consider using [arbitrary values](https://tailwindcss.com/docs/adding-custom-styles#using-arbitrary-values) instead.
19
+
20
+ To extend upon the preset with values specific to your project, we recommend passing a theme object to `theme.extend`.
21
+
22
+ ```js
23
+ const { Preset } = require("@kaizen/tailwind")
24
+
25
+ module.exports = {
26
+ presets: [Preset],
27
+ theme: {
28
+ extend: {
29
+ colors: {
30
+ myCoolNewColor: "#ffffff",
31
+ "purple-100": "lime"
32
+ }
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ Here, the Kaizen preset overwrites the default Tailwind preset, and the `extend` field adds in some new values.
39
+ Be careful though! While adding in a _new_ field to `colors` won't overwrite any existing ones, passing in an existing field _will_. In this example, `purple-100` has unfortunately been overwritten.
40
+
41
+ `<p className="text-sky">...` ❌ Default TW config overwritten by `Preset`
42
+
43
+ `<p className="text-myCoolNewColor">` ✅ New color added
44
+
45
+ `<p className="text-purple-100">` ️❗️ Value from `Preset` overwritten to "Lime"
46
+
47
+ `<p className="text-purple-200">` ✅ Value from `Preset` not overwritten
48
+
49
+ <br/>
50
+
51
+ ## Customising the important selector
52
+
53
+ If the `"#root"` id selector is incompatible with your application wrapper or you are working with a mono-repo that needs to target a selector with lower specificity, you can change the `important` [configuration option](https://tailwindcss.com/docs/configuration#important-modifier) in your `tailwind.config.js`.
54
+
55
+ If this is changed or you are not using the [Frontend Template](https://github.com/cultureamp/frontend-template), be sure that the `important` selector matches to an `id`, `class`, or `HTML Element` within your application, ie:
56
+
57
+ ``` tsx
58
+ <div id="#root">
59
+ {/* Application code */}
60
+ </div>
61
+ ```
62
+
63
+ <InlineNotification
64
+ persistent
65
+ type="cautionary"
66
+ style="inline"
67
+ title="Changing the selector"
68
+ >
69
+ We advise using an <code>id</code> with <code>&quot;#root&quot;</code> as the default selector. Using different id&apos;s, classes or HTML elements like <code>body</code> as the selector could result in:
70
+ <ul>
71
+ <li>
72
+ Utility classes not superseding Kaizen defaults when using <code>classNameOverride</code>
73
+ </li>
74
+ <li>
75
+ Duplication of utillity classes in your CSS bundle caused by consuming components with different <code>important</code> selectors
76
+ </li>
77
+ </ul>
78
+ </InlineNotification>
@@ -0,0 +1,38 @@
1
+ import { Meta } from "@storybook/blocks"
2
+
3
+ <Meta title="Guides/Tailwind/Contributing to this package" />
4
+
5
+ # Contributing
6
+
7
+ <br/>
8
+
9
+ ## Local Development within Kaizen
10
+
11
+ Note: While Taiwlind utilities can be used within `.stories.tsx` and `.mdx` files for documentation and layout purposes, Kaizen components will not render or compile Tailwind styles in the final bundle, i.e: `mr-8` will not apply `margin-right: $spacing-8` if added to a classname in `Button.tsx`.
12
+
13
+ ### Gotchas
14
+
15
+ **New preset created but not available / rendering in DOM**
16
+
17
+ Any time you update the Tailwind presets, make sure you run `pnpm build` in the root `@kaizen/tailwind` folder.
18
+ You may also need to reload the window for these to be picked up with TW IntelliSense.
19
+
20
+ **Intellisense not working within the class attributes**
21
+
22
+ For configuring IntelliSense refer to the [CONFIGURATION.md](/story/systems-tailwind-preset-configuration--page)
23
+
24
+ Check the output in your terminal output for TailwindCSS IntelliSense.
25
+
26
+ If you see the following:
27
+
28
+ ```
29
+ Tailwind CSS: Can't resolve "@kaizen/design-tokens" in... '/Users/.../kaizen-design-system'
30
+ // OR
31
+ Tailwind CSS: Can't resolve '@kaizen/tailwind' in '/Users/.../kaizen-design-system'
32
+ ```
33
+
34
+ **Solution**
35
+
36
+ Run build in both the design-tokens and tailwind package folders.
37
+
38
+ In consuming repos this will not be an issue but for local develop we are requiring on `/dist` folders having compile ts for the plugin to consume.
@@ -0,0 +1,10 @@
1
+ import { Description, Meta, Story } from "@storybook/blocks"
2
+ import * as Examples from "./shadow.stories"
3
+
4
+ <Meta of={Examples} />
5
+
6
+ # Box Shadow
7
+
8
+ <Description />
9
+
10
+ <Story of={Examples.BoxShadow} />
@@ -0,0 +1,40 @@
1
+ import React from "react"
2
+ import { Meta, StoryFn } from "@storybook/react"
3
+ import classnames from "classnames"
4
+ import { TailwindStoryTemplate } from "~tailwind/_docs/utils/TailwindStoryTemplate"
5
+ import { utilityDescription } from "~tailwind/_docs/utils/utilityDescription"
6
+ import { kaizenTailwindTheme } from "~tailwind/tailwind-presets"
7
+
8
+ const prefix = "shadow-"
9
+ const classEntries: Array<{ utilityClassName: string; cssProperty: string }> =
10
+ Object.entries(kaizenTailwindTheme.boxShadow || []).map(
11
+ ([suffix, cssProperty]) => ({
12
+ utilityClassName: `${prefix}${suffix}`,
13
+ cssProperty,
14
+ })
15
+ )
16
+
17
+ export default {
18
+ title: "Guides/Tailwind/Utility Class References/Effects/Box Shadow",
19
+ parameters: {
20
+ a11y: { disable: true },
21
+ chromatic: { disable: false },
22
+ docsLayout: "fullPage",
23
+ docs: {
24
+ description: {
25
+ component: utilityDescription(prefix, classEntries[0].utilityClassName),
26
+ },
27
+ },
28
+ },
29
+ } satisfies Meta
30
+
31
+ export const BoxShadow: StoryFn<{ isReversed: boolean }> = ({ isReversed }) => (
32
+ <TailwindStoryTemplate
33
+ compiledCssPropertyName="box-shadow"
34
+ classKeyValues={classEntries}
35
+ renderExampleComponent={(utilityClass): React.ReactElement => (
36
+ <div className={classnames("w-[100px] h-[100px]", utilityClass)} />
37
+ )}
38
+ isReversed={isReversed}
39
+ />
40
+ )
@@ -0,0 +1,125 @@
1
+ import { Meta } from "@storybook/blocks"
2
+ import CssGeneration from "../assets/css-generation.png"
3
+ import InlineFold from "../assets/inline-fold.gif"
4
+ import TailwindPlay from "../assets/tailwind-play.gif"
5
+
6
+ <Meta title="Guides/Tailwind/Getting Started" />
7
+
8
+ # Getting Started
9
+
10
+ This page describes the steps needed to use our [Kaizen Tailwind preset](https://github.com/cultureamp/kaizen-design-system/tree/main/packages/tailwind), not Tailwind itself.
11
+ To learn more about Tailwind and how to install it in your project, check out there docs [here](https://tailwindcss.com/docs/installation).
12
+
13
+ Note: Projects created from [frontend-template](https://github.com/cultureamp/frontend-template) should have steps 1 - 3 completed out of the box.
14
+ If your project was created from this template, you should only need to do [Step 4: Useful tools](#4-useful-tools).
15
+
16
+ - [1. Install the preset](#1-install-the-preset)
17
+ - [2. Implement the preset](#2-implement-the-preset)
18
+ - [3. Add the Tailwind directives](#3-add-the-tailwind-directives)
19
+ - [4. Useful tools](#4-useful-tools)
20
+
21
+ <br/>
22
+
23
+ ## 1. Install the preset
24
+
25
+ ```bash
26
+ yarn add -D @kaizen/tailwind
27
+ ```
28
+
29
+ ## 2. Implement the Preset
30
+
31
+ In your tailwind config file, import the preset and add it to your `presets` array.
32
+ This will override the default Tailwind preset, and make ours available for use.
33
+
34
+ ```js
35
+ // tailwind.config.js
36
+
37
+ const { Preset } = require("@kaizen/tailwind")
38
+
39
+ module.exports = {
40
+ // Glob pattern to match files containing TW classes. May be different for your project.
41
+ content: ["./**/*.{ts,tsx}"],
42
+ // Override the default Tailwind preset with the Kaizen one.
43
+ presets: [Preset],
44
+ // This should be a selector that wraps your app. It ensures that your Tailwind classes supersede component styles, by increasing their specificity with the chosen selector.
45
+ important: "#root",
46
+ // Preflight is a heavy-handed css reset. We recommend disabling it in your project.
47
+ corePlugins: {
48
+ preflight: false,
49
+ },
50
+ }
51
+ ```
52
+
53
+ For preset configuration options, see our [configuration docs](/story/systems-tailwind-configuration--page)
54
+
55
+ ## 3. Add the Tailwind Directives
56
+
57
+ The following directives need to be included in your project's main css file.
58
+
59
+ ```css
60
+ @tailwind base;
61
+ @tailwind components;
62
+ @tailwind utilities;
63
+ ```
64
+
65
+ These directives inject classes that are needed for certain Tailwind features.
66
+ For more information, see [here](https://tailwindcss.com/docs/functions-and-directives).
67
+
68
+ ## 4. Useful tools
69
+
70
+ ### Tailwind Play
71
+
72
+ Tailwind Play is an online code sandbox with Tailwind set up out of the box. The Kaizen Team has created an instance with the Kaizen Preset values [here](https://play.tailwindcss.com/OUogvUgXQR)
73
+
74
+ Use this playground to get familiar with our preset, test out new config extensions, create a quick proof of concept, or share code examples with other engineers. Feel free to hit ‘Share’ - it’ll create a new url without overriding the one provided here.
75
+
76
+ <img src={TailwindPlay} alt="Tailwind Play" />
77
+
78
+ The playground also has a great “Generated CSS” feature that let’s you see which css classes are generated by your preset when you implement tailwind utilities. It’s a great way to see what Tailwind is doing under the hood.
79
+
80
+ <div className="flex justify-center">
81
+ <img src={CssGeneration} alt="CSS Generation" />
82
+ </div>
83
+
84
+ ### Tailwind CSS VSCode IntelliSense plugin
85
+
86
+ Basic config for the [VSCode plugin](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss) for Tailwind IntelliSense lives in your project's `settings.json`.
87
+
88
+ You can customise which keywords trigger IntelliSense using basic strings, or even regex expressions.
89
+ Here are some examples you may wish to include in your own project:
90
+
91
+ ```
92
+ "tailwindCSS.classAttributes": [
93
+ "class",
94
+ "className",
95
+ "ngClass",
96
+ "classNameOverride"
97
+ ],
98
+ "tailwindCSS.experimental.classRegex": [
99
+ "classnames\\(([^)]*)\\)",
100
+ "classNames\\(([^)]*)\\)",
101
+ "clsx\\(([^)]*)\\)",
102
+ "csx\\(([^)]*)\\)"
103
+ ]
104
+ ```
105
+
106
+ `tailwindCSS.experimental.classRegex` is used to provide intelliSense within your `classnames` functions in your codebase.
107
+ Ideally you only add the pattern that is used in your repo.
108
+
109
+ Calling out that this is still an experimental feature for the VSCode plugin.
110
+
111
+ ### Inline fold VSCode extension
112
+ Using tailwind often results in long class names, that can even span over multiple lines.
113
+ Inline fold is a great extension that hides/ shows long class strings.
114
+
115
+ Check it out [here](https://marketplace.visualstudio.com/items?itemName=moalamri.inline-fold):
116
+
117
+
118
+ <div className="flex justify-center">
119
+ <img src={InlineFold} alt="Inline fold VSCode extension" />
120
+ </div>
121
+
122
+ ### Prettier plugin
123
+
124
+ Tailwind now has prettier support! 🎉 This [prettier plugin](https://github.com/tailwindlabs/prettier-plugin-tailwindcss) will order your classnames for you.
125
+ We’d highly recommend it for the sake of consistency. The Tailwind docs even have a guide [here](https://tailwindcss.com/blog/automatic-class-sorting-with-prettier).
@@ -0,0 +1,16 @@
1
+ import { Description, Meta, Story } from "@storybook/blocks"
2
+ import * as Examples from "./media-queries.stories"
3
+
4
+ <Meta of={Examples} />
5
+
6
+ # Media Queries
7
+
8
+ <Description />
9
+
10
+ ## Preset media queries
11
+
12
+ <Story of={Examples.MediaQueries} />
13
+
14
+ ## Using arbitrary values
15
+
16
+ <Story of={Examples.ArbitraryMediaQueries} />
@@ -0,0 +1,81 @@
1
+ import React from "react"
2
+ import { Meta, StoryFn } from "@storybook/react"
3
+ import { Heading } from "~components/Heading"
4
+ import { Text } from "~components/Text"
5
+
6
+ export default {
7
+ title: "Guides/Tailwind/Utility Class References/Modifiers/Media Queries",
8
+ parameters: {
9
+ docsLayout: "fullPage",
10
+ docs: {
11
+ a11y: { disable: true },
12
+ description: {
13
+ component:
14
+ "Require @kaizen/tailwind and add it into your tailwind config",
15
+ },
16
+ },
17
+ },
18
+ } satisfies Meta
19
+
20
+ type QueryInfoProps = {
21
+ selector: string
22
+ selectorValue: string
23
+ children: React.ReactElement
24
+ }
25
+ const QueryInfo = ({
26
+ selector,
27
+ selectorValue,
28
+ children,
29
+ }: QueryInfoProps): React.ReactElement => (
30
+ <div className="my-12">
31
+ <Text variant="intro-lede">Pseudo selector: {selector}</Text>
32
+ <Text variant="body">Breakpoint: {selectorValue}</Text>
33
+ <Text variant="body">In this example: {selector}:bg-blue-400</Text>
34
+ {/* Passing in as children, as dynamically creating the media query with interpolation fails */}
35
+ {children}
36
+ </div>
37
+ )
38
+
39
+ export const MediaQueries: StoryFn = () => (
40
+ <div className="py-32">
41
+ <Heading tag="p" variant="heading-4" classNameOverride="text-center">
42
+ These breakpoints activate <em>over</em> a certain screen width. Meaning
43
+ that bg-blue-400 will be applied when the screen gets <em>wider</em>.
44
+ </Heading>
45
+ <QueryInfo selector="md" selectorValue="768px">
46
+ <div className="border-solid md:bg-blue-400 h-[50px] w-full rounded" />
47
+ </QueryInfo>
48
+ <QueryInfo selector="lg" selectorValue="1080px">
49
+ <div className="border-solid lg:bg-blue-400 h-[50px] w-full rounded" />
50
+ </QueryInfo>
51
+ </div>
52
+ )
53
+
54
+ export const ArbitraryMediaQueries: StoryFn = () => (
55
+ <div className="py-32">
56
+ <Heading tag="p" variant="heading-4" classNameOverride="text-center">
57
+ Bespoke, one-off media queries can be created with arbitrary values. See
58
+ the{" "}
59
+ <a href="https://tailwindcss.com/docs/responsive-design#arbitrary-values">
60
+ Tailwind docs
61
+ </a>{" "}
62
+ for more info.
63
+ </Heading>
64
+
65
+ <div className="py-32">
66
+ <Text variant="body">
67
+ <strong>Min-width breakpoint</strong> (applied when the screen gets{" "}
68
+ <em>wider</em>)
69
+ </Text>
70
+ <Text variant="body">In this example: min-[500px]:bg-blue-400</Text>
71
+ <div className="border-solid min-[500px]:bg-blue-400 h-[50px] w-full rounded-default" />
72
+ </div>
73
+
74
+ <Text variant="body">
75
+ <strong>Max-width breakpoint</strong> (applied when the screen gets{" "}
76
+ <em>slimmer</em>)
77
+ </Text>
78
+ <Text variant="body">In this example: max-[500px]:bg-blue-400</Text>
79
+ <div className="border-solid max-[500px]:bg-blue-400 h-[50px] w-full rounded-default" />
80
+ </div>
81
+ )
@@ -0,0 +1,26 @@
1
+ import { Description, Meta, Story, Unstyled } from "@storybook/blocks"
2
+ import { Card } from "~components/Card"
3
+ import * as Examples from "./pseudo-states.stories"
4
+
5
+ <Meta of={Examples} />
6
+
7
+ # Pseudo Selectors
8
+
9
+ <Description />
10
+
11
+ <Unstyled>
12
+ <Card variant="informative" classNameOverride="w-fit mb-24">
13
+ <div className="font-family-paragraph p-24">
14
+ <p>
15
+ Pseudo selectors can be used to apply standard Tailwind utility
16
+ classes under certain pseudo states, such as on hover or focus.
17
+ </p>
18
+ <p>
19
+ Read more on Tailwind&apos;s pseudo selectors
20
+ <a href="https://tailwindcss.com/docs/hover-focus-and-other-states#pseudo-classes">here</a>.
21
+ </p>
22
+ </div>
23
+ </Card>
24
+ </Unstyled>
25
+
26
+ <Story of={Examples.PseudoSelectors} />
@@ -0,0 +1,49 @@
1
+ /* eslint-disable jsx-a11y/anchor-is-valid */
2
+ import React from "react"
3
+ import { Meta, StoryFn } from "@storybook/react"
4
+ import { StickerSheet } from "~storybook/components/StickerSheet"
5
+
6
+ export default {
7
+ title: "Guides/Tailwind/Utility Class References/Modifiers/Pseudo Selectors",
8
+ parameters: {
9
+ a11y: { disable: true },
10
+ docsLayout: "fullPage",
11
+ docs: {
12
+ description: {
13
+ component:
14
+ "Add a modifier before a standard tailwind utility class to have it apply in certain states. For example, hover:text-blue-500 will set the font color to blue-500 on hover.",
15
+ },
16
+ },
17
+ },
18
+ } satisfies Meta
19
+
20
+ export const PseudoSelectors: StoryFn<{ isReversed: boolean }> = ({
21
+ isReversed,
22
+ }) => (
23
+ <StickerSheet isReversed={isReversed}>
24
+ <StickerSheet.Header
25
+ headings={["Utility Class", "Compiled CSS", "Example"]}
26
+ />
27
+ <StickerSheet.Row rowTitle="hover">
28
+ <p className="font-family-paragraph">hover:bg-blue-200</p>
29
+ <p className="font-family-paragraph">background-color: #bde2f5</p>
30
+ <button
31
+ type="button"
32
+ className="border-solid bg-white border-[black] font-family-paragraph w-[150px] rounded hover:bg-blue-200 py-16 px-12 text-center"
33
+ >
34
+ Hover me
35
+ </button>
36
+ </StickerSheet.Row>
37
+ <StickerSheet.Row rowTitle="focus">
38
+ <p className="font-family-paragraph">focus:bg-blue-200</p>
39
+ <p className="font-family-paragraph">background-color: #bde2f5</p>
40
+ <button
41
+ type="button"
42
+ tabIndex={0}
43
+ className="border-solid bg-white border-[black] font-family-paragraph w-[150px] rounded focus:bg-blue-200 py-16 px-12 text-center"
44
+ >
45
+ Focus me
46
+ </button>
47
+ </StickerSheet.Row>
48
+ </StickerSheet>
49
+ )
@@ -0,0 +1,26 @@
1
+ import { Meta } from "@storybook/blocks"
2
+ import AnatomyDiagram from "../assets/tw-anatomy.png"
3
+
4
+ <Meta title="Guides/Tailwind/Overview" />
5
+
6
+ # Overview
7
+
8
+ <br/>
9
+
10
+ ## Caveat before use
11
+ This is an early release of the Kaizen Tailwind Preset - the API may change and evolve as we receive feedback from our teams. We will endeavour to assist where possible if classes or utilities are updated in the future.
12
+
13
+ ## What our package does
14
+ The `@kaizen/tailwind` package is essentially a custom Tailwind preset. For more information about Tailwind presets, see their docs [here](https://tailwindcss.com/docs/presets). This package does not change how Tailwind works; it only defines the suffixes that can be applied when constructing utility classes.
15
+ To see a list of utilities generated by our preset, see our [Utility Class Reference Docs](/story/systems-tailwind-utility-class-references-utility-class-references--page).
16
+ The following diagram shows the construction of a utility class that adds a background of `blue-400` on hover. The modifier `hover:` and the prefix `bg-` are part of Tailwind by default. The suffix `gray-400` is defined by our preset, and represents one of our color design tokens.
17
+
18
+
19
+ <img src={AnatomyDiagram} alt="Tailwind utility class anatomy" />
20
+
21
+ ```css
22
+ .hover\:bg-blue-400:hover {
23
+ --tw-bg-opacity: 1;
24
+ background-color: rgb(0 139 214 / var(--tw-bg-opacity))
25
+ }
26
+ ```
@@ -0,0 +1,27 @@
1
+ import { Description, Meta, Story, Unstyled } from "@storybook/blocks"
2
+ import { Card } from "~components/Card"
3
+ import * as Examples from "./margin.stories"
4
+
5
+ <Meta of={Examples} />
6
+
7
+ # Margin
8
+
9
+ <Description />
10
+
11
+ <Unstyled>
12
+ <Card variant="informative" classNameOverride="w-fit mb-24">
13
+ <div className="font-family-paragraph p-24">
14
+ <p>
15
+ The padding prefix &apos;m-&apos; has been used in the examples in this
16
+ document, which compiles to the `margin` property in CSS.
17
+ </p>
18
+ <p>
19
+ Note that there are other prefixes (such as `ml-` for `margin-left`)
20
+ that can be used instead. Available padding prefixes can be referenced
21
+ <a href="https://tailwindcss.com/docs/margin#basic-usage">here</a>.
22
+ </p>
23
+ </div>
24
+ </Card>
25
+ </Unstyled>
26
+
27
+ <Story of={Examples.Margin} />
@@ -0,0 +1,49 @@
1
+ import React from "react"
2
+ import { Meta, StoryFn } from "@storybook/react"
3
+ import classnames from "classnames"
4
+ import { TailwindStoryTemplate } from "~tailwind/_docs/utils/TailwindStoryTemplate"
5
+ import { utilityDescription } from "~tailwind/_docs/utils/utilityDescription"
6
+ import { kaizenTailwindTheme } from "~tailwind/tailwind-presets"
7
+
8
+ const prefix = "m-"
9
+ const classEntries: Array<{ utilityClassName: string; cssProperty: string }> =
10
+ Object.entries(kaizenTailwindTheme.spacing || []).map(
11
+ ([suffix, cssProperty]) => ({
12
+ utilityClassName: `${prefix}${suffix}`,
13
+ cssProperty,
14
+ })
15
+ )
16
+
17
+ export default {
18
+ title: "Guides/Tailwind/Utility Class References/Spacing/Margin",
19
+ parameters: {
20
+ a11y: { disable: true },
21
+ chromatic: { disable: false },
22
+ docsLayout: "fullPage",
23
+ docs: {
24
+ description: {
25
+ component: utilityDescription(prefix, classEntries[0].utilityClassName),
26
+ },
27
+ },
28
+ },
29
+ } satisfies Meta
30
+
31
+ export const Margin: StoryFn<{ isReversed: boolean }> = ({ isReversed }) => (
32
+ <TailwindStoryTemplate
33
+ compiledCssPropertyName="margin"
34
+ classKeyValues={classEntries}
35
+ renderExampleComponent={(utilityClass): React.ReactElement => (
36
+ <div className="w-min border rounded">
37
+ <p
38
+ className={classnames(
39
+ "p-4 border border-dashed w-min rounded bg-blue-100",
40
+ utilityClass
41
+ )}
42
+ >
43
+ Margin
44
+ </p>
45
+ </div>
46
+ )}
47
+ isReversed={isReversed}
48
+ />
49
+ )
@@ -0,0 +1,27 @@
1
+ import { Description, Meta, Story, Unstyled } from "@storybook/blocks"
2
+ import { Card } from "~components/Card"
3
+ import * as Examples from "./padding.stories"
4
+
5
+ <Meta of={Examples} />
6
+
7
+ # Padding
8
+
9
+ <Description />
10
+
11
+ <Unstyled>
12
+ <Card variant="informative" classNameOverride="w-fit mb-24">
13
+ <div className="font-family-paragraph p-24">
14
+ <p>
15
+ The padding prefix &apos;p-&apos; has been used in the examples in this
16
+ document, which compiles to the `padding` property in CSS.
17
+ </p>
18
+ <p>
19
+ Note that there are other prefixes (such as `pl-` for `padding-left`)
20
+ that can be used instead. Available padding prefixes can be referenced
21
+ <a href="https://tailwindcss.com/docs/padding#basic-usage">here</a>.
22
+ </p>
23
+ </div>
24
+ </Card>
25
+ </Unstyled>
26
+
27
+ <Story of={Examples.Padding} />