@kaizen/tailwind 1.5.0 → 1.5.2

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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var designTokens = require('@kaizen/design-tokens');
3
+ var js = require('@kaizen/design-tokens/js');
4
4
  var tokenDenyList = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'xxxl', 'xxxxl', 'xxxxxl', 'xs-id', 'sm-id', 'md-id', 'lg-id', 'xl-id', 'xxl-id', 'xxxl-id', 'xxxxl-id', 'xxxxxl-id'];
5
5
  /**
6
6
  * checks if a key from design tokens should be filtered from tailwind
@@ -16,6 +16,6 @@ var filterDenyListValues = function (spacingTokensObject) {
16
16
  return isValidToken(key);
17
17
  }));
18
18
  };
19
- var kzSpacing = filterDenyListValues(designTokens.heartTheme.spacing);
19
+ var kzSpacing = filterDenyListValues(js.tokens.spacing);
20
20
  exports.filterDenyListValues = filterDenyListValues;
21
21
  exports.kzSpacing = kzSpacing;
@@ -102,7 +102,7 @@ var kaizenTailwindTheme = {
102
102
  screens: {
103
103
  md: js.tokens.layout.breakpoints.medium,
104
104
  // => @media (min-width: 768px) { ... }
105
- lg: js.tokens.layout.breakpoints.large // => @media (min-width: 1080px) { ... }
105
+ lg: js.tokens.layout.breakpoints.large // => @media (min-width: 1024px) { ... }
106
106
  }
107
107
  };
108
108
  var Preset = {
@@ -1,4 +1,4 @@
1
- import { heartTheme } from '@kaizen/design-tokens';
1
+ import { tokens } from '@kaizen/design-tokens/js';
2
2
  var tokenDenyList = ['xs', 'sm', 'md', 'lg', 'xl', 'xxl', 'xxxl', 'xxxxl', 'xxxxxl', 'xs-id', 'sm-id', 'md-id', 'lg-id', 'xl-id', 'xxl-id', 'xxxl-id', 'xxxxl-id', 'xxxxxl-id'];
3
3
  /**
4
4
  * checks if a key from design tokens should be filtered from tailwind
@@ -14,5 +14,5 @@ var filterDenyListValues = function (spacingTokensObject) {
14
14
  return isValidToken(key);
15
15
  }));
16
16
  };
17
- var kzSpacing = filterDenyListValues(heartTheme.spacing);
17
+ var kzSpacing = filterDenyListValues(tokens.spacing);
18
18
  export { filterDenyListValues, kzSpacing };
@@ -100,7 +100,7 @@ var kaizenTailwindTheme = {
100
100
  screens: {
101
101
  md: tokens.layout.breakpoints.medium,
102
102
  // => @media (min-width: 768px) { ... }
103
- lg: tokens.layout.breakpoints.large // => @media (min-width: 1080px) { ... }
103
+ lg: tokens.layout.breakpoints.large // => @media (min-width: 1024px) { ... }
104
104
  }
105
105
  };
106
106
  var Preset = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/tailwind",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "Kaizen Tailwind presets",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,21 +22,22 @@
22
22
  "private": false,
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@kaizen/design-tokens": "10.10.0"
25
+ "@kaizen/design-tokens": "11.0.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@cultureamp/package-bundler": "^2.3.1",
28
+ "@cultureamp/package-bundler": "^2.3.2",
29
+ "@tailwindcss/container-queries": "^0.1.1",
29
30
  "classnames": "^2.5.1",
30
- "rollup": "^4.40.2",
31
- "react": "^19.0.0",
32
- "react-dom": "^19.0.0",
31
+ "react": "^19.1.0",
32
+ "react-dom": "^19.1.0",
33
+ "rollup": "^4.46.2",
33
34
  "tailwindcss": "^3.4.17",
34
35
  "tslib": "^2.8.1"
35
36
  },
36
37
  "peerDependencies": {
37
- "tailwindcss": ">=3.4.7",
38
38
  "react": "^18.3.1 || ^19.0.0",
39
- "react-dom": "^18.3.1 || ^19.0.0"
39
+ "react-dom": "^18.3.1 || ^19.0.0",
40
+ "tailwindcss": ">=3.4.7"
40
41
  },
41
42
  "scripts": {
42
43
  "build": "pnpm package-bundler build",
@@ -59,7 +59,7 @@ If this is changed or you are not using the [Frontend Template](https://github.c
59
59
  ```
60
60
 
61
61
  <Unstyled>
62
- <InlineNotification persistent type="cautionary" style="inline" title="Changing the selector">
62
+ <InlineNotification persistent variant="cautionary" style="inline" title="Changing the selector">
63
63
  {
64
64
  <>
65
65
  We advise using an <code>id</code> with <code>&quot;#root&quot;</code> as the default
@@ -19,7 +19,7 @@ You may also need to reload the window for these to be picked up with TW Intelli
19
19
 
20
20
  **Intellisense not working within the class attributes**
21
21
 
22
- For configuring IntelliSense refer to the [CONFIGURATION.md](/story/systems-tailwind-preset-configuration--page)
22
+ For configuring IntelliSense refer to the [Getting Started guide](/docs/guides-tailwind-getting-started--docs#tailwind-css-vscode-intellisense-plugin)
23
23
 
24
24
  Check the output in your terminal output for TailwindCSS IntelliSense.
25
25
 
@@ -50,7 +50,7 @@ module.exports = {
50
50
  }
51
51
  ```
52
52
 
53
- For preset configuration options, see our [configuration docs](/story/systems-tailwind-configuration--page).
53
+ For preset configuration options, see our [configuration docs](/docs/guides-tailwind-configuration--docs).
54
54
 
55
55
  ## 3. Add the Tailwind Directives
56
56
 
@@ -0,0 +1,72 @@
1
+ import { Description, Meta, Story } from '@storybook/blocks'
2
+ import * as Examples from './container-queries.stories'
3
+
4
+ <Meta of={Examples} />
5
+
6
+ # Container Queries
7
+
8
+ <Description />
9
+
10
+ Container queries allow you to apply styles based on the size of a container rather than the viewport. This is especially useful for creating truly reusable components that adapt to their context.
11
+
12
+ ## Fallback container parent
13
+
14
+ The Kaizen design system includes a fallback container parent in the `_reset.css` file:
15
+
16
+ ```css
17
+ body {
18
+ container-type: inline-size;
19
+ }
20
+ ```
21
+
22
+ This means that if you use container query classes (like `@md:bg-blue-400`) without explicitly adding an `@container` parent, the body element will act as the container context. In this case, container queries will functionally behave the same as viewport media queries, making the transition from media queries to container queries non-breaking for existing components.
23
+
24
+ ## Preset container queries
25
+
26
+ Container queries work by establishing a containment context on a parent element using the `@container` class, then applying conditional styles to child elements using the `@` prefix.
27
+
28
+ <Story of={Examples.ContainerQueries} />
29
+
30
+ ## Using arbitrary values
31
+
32
+ For one-off container sizes that don't match your configured breakpoints, you can use arbitrary values in square brackets.
33
+
34
+ <Story of={Examples.ArbitraryContainerQueries} />
35
+
36
+ ## Named containers
37
+
38
+ When you have nested containers, you can use named containers to query specific containers by name. This prevents conflicts where a child element might respond to the wrong container.
39
+
40
+ ```tsx
41
+ <div className="mt-12 border-1 border-dashed border-purple-300 p-8">
42
+ <Text variant="body">
43
+ <strong>Outer container ("sidebar") - resize to see effect</strong>
44
+ </Text>
45
+ <div className="@container/sidebar mt-4 resize overflow-auto border-2 border-blue-300">
46
+ <div className="p-4">
47
+ <Text variant="body">
48
+ <strong>Inner container ("card")</strong>
49
+ </Text>
50
+ <div className="@container/card mt-2 border border-gray-300 p-2">
51
+ <div className="@md/sidebar:bg-green-400 h-[50px] w-full rounded border-solid">
52
+ <div className="flex h-full items-center justify-center text-xs">
53
+ <Text variant="body">Responds to sidebar container</Text>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ ```
61
+
62
+ <Story of={Examples.NamedContainers} />
63
+
64
+ ## Best practices
65
+
66
+ - **For container behavior**: Always establish a containment context with `@container` (or named `@container/name`) on the parent element
67
+ - **Fallback behavior**: Without an explicit `@container` parent, container queries will use the body element and behave like viewport media queries
68
+ - Container queries respond to the **container's** size, not the viewport size (unless using the body fallback)
69
+ - Use named containers when you have nested container contexts
70
+ - Combine container queries with regular responsive design for optimal flexibility
71
+ - Container queries work great for component-level responsive design
72
+ - The fallback body container makes migrating from media queries to container queries seamless
@@ -0,0 +1,124 @@
1
+ import React from 'react'
2
+ import { type Meta, type 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/Container Queries',
8
+ parameters: {
9
+ docsLayout: 'fullPage',
10
+ docs: {
11
+ a11y: { disable: true },
12
+ description: {
13
+ component: 'Require @kaizen/tailwind and add it into your tailwind config',
14
+ },
15
+ },
16
+ },
17
+ } satisfies Meta
18
+
19
+ type ContainerQueryInfoProps = {
20
+ selector: string
21
+ selectorValue: string
22
+ children: React.ReactElement
23
+ }
24
+
25
+ const ContainerQueryInfo = ({
26
+ selector,
27
+ selectorValue,
28
+ children,
29
+ }: ContainerQueryInfoProps): React.ReactElement => (
30
+ <div className="my-12">
31
+ <Text variant="intro-lede">Container query selector: @{selector}</Text>
32
+ <Text variant="body">Breakpoint: {selectorValue}</Text>
33
+ <Text variant="body">In this example: @{selector}:bg-blue-400</Text>
34
+ {/* Container wrapper to demonstrate container queries */}
35
+ <div className="mt-12 border-2 border-dashed border-purple-300 p-8">
36
+ <Text variant="body">
37
+ <strong>Container wrapper (resize to see effect)</strong>
38
+ </Text>
39
+ <div className="mt-4 resize overflow-auto border border-gray-300">{children}</div>
40
+ </div>
41
+ </div>
42
+ )
43
+
44
+ export const ContainerQueries: StoryFn = () => (
45
+ <div className="py-32">
46
+ <Heading tag="p" variant="heading-4" classNameOverride="mb-16">
47
+ Container query breakpoints activate based on the <em>container&apos;s</em> width, not the
48
+ viewport. These elements will change color when their parent container reaches the specified
49
+ width.
50
+ </Heading>
51
+
52
+ <ContainerQueryInfo selector="md" selectorValue="768px">
53
+ <div className="@container">
54
+ <div className="@md:bg-blue-400 h-[50px] w-full rounded border-solid" />
55
+ </div>
56
+ </ContainerQueryInfo>
57
+
58
+ <ContainerQueryInfo selector="lg" selectorValue="1080px">
59
+ <div className="@container">
60
+ <div className="@lg:bg-blue-400 h-[50px] w-full rounded border-solid" />
61
+ </div>
62
+ </ContainerQueryInfo>
63
+ </div>
64
+ )
65
+
66
+ export const ArbitraryContainerQueries: StoryFn = () => (
67
+ <div className="py-32">
68
+ <Heading tag="p" variant="heading-4" classNameOverride="mb-16">
69
+ Custom container query breakpoints can be created with arbitrary values.
70
+ </Heading>
71
+
72
+ <div className="my-12">
73
+ <Text variant="body">
74
+ <strong>Custom container width breakpoint</strong> (applied when the container gets wider
75
+ than 500px)
76
+ </Text>
77
+ <Text variant="body">In this example: @[500px]:bg-green-400</Text>
78
+ <div className="mt-12 border-2 border-dashed border-purple-300 p-8">
79
+ <Text variant="body">
80
+ <strong>Container wrapper (resize to see effect)</strong>
81
+ </Text>
82
+ <div className="@container mt-4 resize overflow-auto border border-gray-300">
83
+ <div className="@[500px]:bg-green-400 h-[50px] w-full rounded border-solid" />
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </div>
88
+ )
89
+
90
+ export const NamedContainers: StoryFn = () => (
91
+ <div className="py-32">
92
+ <Heading tag="p" variant="heading-4" classNameOverride="mb-16">
93
+ Named containers allow you to query specific containers by name, useful when you have nested
94
+ containers.
95
+ </Heading>
96
+
97
+ <div className="my-12">
98
+ <Text variant="body">
99
+ <strong>Named container example</strong> - The inner element responds to the outer
100
+ &quot;sidebar&quot; container, not the inner &quot;card&quot; container
101
+ </Text>
102
+ <Text variant="body">In this example: @container/sidebar and @md/sidebar:bg-green-400</Text>
103
+ <div className="mt-12 border-1 border-dashed border-purple-300 p-8">
104
+ <Text variant="body">
105
+ <strong>Outer container (&quot;sidebar&quot;) - resize to see effect</strong>
106
+ </Text>
107
+ <div className="@container/sidebar mt-4 resize overflow-auto border-2 border-blue-300">
108
+ <div className="p-4">
109
+ <Text variant="body">
110
+ <strong>Inner container (&quot;card&quot;)</strong>
111
+ </Text>
112
+ <div className="@container/card mt-2 border border-gray-300 p-2">
113
+ <div className="@md/sidebar:bg-green-400 h-[50px] w-full rounded border-solid">
114
+ <div className="flex h-full items-center justify-center text-xs">
115
+ <Text variant="body">Responds to sidebar container</Text>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ )
@@ -10,7 +10,7 @@ import AnatomyDiagram from '../assets/tw-anatomy.png'
10
10
  ## What our package does
11
11
 
12
12
  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.
13
- 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).
13
+ To see a list of utilities generated by our preset, see our [Utility Class Reference Docs](/docs/guides-tailwind-utility-class-references-overview--docs).
14
14
  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.
15
15
 
16
16
  <img src={AnatomyDiagram} alt="Tailwind utility class anatomy" />
@@ -16,7 +16,7 @@ This page describes and demonstrates the main intended use cases for this packag
16
16
 
17
17
  ## Spacing and layouts
18
18
 
19
- For information about Cultureamp's spacing and layout system in general, see [here](/story/systems-layout-and-spacing--page).
19
+ For information about Cultureamp's spacing and layout system in general, see [here](/docs/guides-layout-and-spacing--docs).
20
20
 
21
21
  When building a page, ideally [Kaizen](https://github.com/cultureamp/kaizen-design-system) components should be used as much as possible, with the front-end engineer responsible for the spacing between them. In these cases, our Tailwind preset makes it easy by adding our spacing tokens to Tailwind's core spacing modules.
22
22
 
@@ -27,7 +27,7 @@ Here, Tailwind has been used to center a Kaizen button within a div.
27
27
  - `flex`: Adds `display: flex`
28
28
  - `justify-center`: Adds `justify-content: center`
29
29
  - `border-solid`: Adds `border-style: solid`
30
- - `p-16`: Adds `padding: 1rem` (`16px` = `1rem` - see the [layout and spacing docs](/story/systems-layout-and-spacing--page) for more on this)
30
+ - `p-16`: Adds `padding: 1rem` (`16px` = `1rem` - see the [layout and spacing docs](/docs/guides-layout-and-spacing--docs) for more on this)
31
31
 
32
32
  Here's a more complex example, where some `<Card>` components and text have been spaced and laid out with Tailwind:
33
33
 
@@ -1,10 +1,11 @@
1
1
  import React from 'react'
2
2
  import { type StoryFn } from '@storybook/react'
3
- import { Button } from '~components/Button'
3
+ import { Button } from '~components/ButtonV1'
4
4
  import { Card } from '~components/Card'
5
+ import { Container } from '~components/Container'
6
+ import { Content } from '~components/Content'
5
7
  import { Heading } from '~components/Heading'
6
8
  import { CustomSurvey, CustomUnattributedSurvey } from '~components/Illustration'
7
- import { Skirt } from '~components/Skirt'
8
9
  import { TailwindStoryTemplate } from '../utils/TailwindStoryTemplate'
9
10
 
10
11
  export default {
@@ -19,14 +20,16 @@ export const TailwindExampleSpacingAndLayouts: StoryFn = () => (
19
20
 
20
21
  export const TailwindExampleSpacingAndLayoutsComplex: StoryFn = () => (
21
22
  <>
22
- <Skirt>
23
- <Heading variant="heading-2" color="white" classNameOverride="pt-24">
24
- Laid out with Tailwind
25
- </Heading>
26
- <Card variant="informative" classNameOverride="mt-24">
27
- <div className="h-[300px]" />
28
- </Card>
29
- </Skirt>
23
+ <Container>
24
+ <Content>
25
+ <Heading variant="heading-2" color="dark" classNameOverride="pt-24">
26
+ Laid out with Tailwind
27
+ </Heading>
28
+ <Card color="blue" classNameOverride="mt-24">
29
+ <div className="h-[300px]" />
30
+ </Card>
31
+ </Content>
32
+ </Container>
30
33
  {/* Adds flex, makes the width 100% and centers content */}
31
34
  <div className="flex w-full justify-center">
32
35
  {/* Adds margins, width, and max width */}
@@ -45,7 +48,7 @@ export const TailwindExampleSpacingAndLayoutsComplex: StoryFn = () => (
45
48
  {/* Adds margin-top, flex, and a height of 200px */}
46
49
  <div className="mt-64 flex h-[200px]">
47
50
  {[0, 1, 2, 3].map((index) => (
48
- <Card key={index} variant="informative" classNameOverride="mr-24 last:mr-0 w-full">
51
+ <Card key={index} color="blue" classNameOverride="mr-24 last:mr-0 w-full">
49
52
  {/* Adds height and width of 100% */}
50
53
  <div className="w-full h-100" />
51
54
  </Card>
@@ -70,7 +70,7 @@ export const TailwindStoryTemplate = ({
70
70
  <div className="fixed top-[10px] left-[10px]">
71
71
  {copiedText && (
72
72
  <InlineNotification
73
- type="positive"
73
+ variant="success"
74
74
  hideCloseIcon
75
75
  onHide={(): void => setCopiedText(null)}
76
76
  headingProps={{
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { Button } from '~components/Button'
2
+ import { Button } from '~components/ButtonV1'
3
3
  import { Heading } from '~components/Heading'
4
4
 
5
5
  type CardContentProps = {
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react'
2
- import { Icon } from '~components/__next__'
2
+ import { Icon } from '~components/Icon'
3
3
 
4
4
  type Props = {
5
5
  text: string
package/src/kz-spacing.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { heartTheme } from '@kaizen/design-tokens'
1
+ import { tokens } from '@kaizen/design-tokens/js'
2
2
 
3
3
  const tokenDenyList: string[] = [
4
4
  'xs',
@@ -35,4 +35,4 @@ export const filterDenyListValues = (
35
35
  return Object.fromEntries(keyValuePairs.filter(([key]) => isValidToken(key)))
36
36
  }
37
37
 
38
- export const kzSpacing = filterDenyListValues(heartTheme.spacing)
38
+ export const kzSpacing = filterDenyListValues(tokens.spacing)
@@ -107,7 +107,7 @@ export const kaizenTailwindTheme: KaizenTailwindTheme = {
107
107
  // A mix of layout styles
108
108
  screens: {
109
109
  md: tokens.layout.breakpoints.medium, // => @media (min-width: 768px) { ... }
110
- lg: tokens.layout.breakpoints.large, // => @media (min-width: 1080px) { ... }
110
+ lg: tokens.layout.breakpoints.large, // => @media (min-width: 1024px) { ... }
111
111
  },
112
112
  } as const
113
113