@kaizen/tailwind 1.3.10 → 1.3.12
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.
- package/dist/cjs/kz-spacing.cjs +2 -2
- package/dist/cjs/tailwind-presets.cjs +65 -65
- package/dist/esm/kz-spacing.mjs +2 -2
- package/dist/esm/tailwind-presets.mjs +65 -65
- package/dist/types/index.d.ts +1 -1
- package/dist/types/tailwind-presets.d.ts +1 -1
- package/package.json +6 -6
- package/src/_docs/pages/backgrounds/background-color.mdx +2 -2
- package/src/_docs/pages/backgrounds/background-color.stories.tsx +13 -20
- package/src/_docs/pages/borders/border-color.mdx +2 -2
- package/src/_docs/pages/borders/border-color.stories.tsx +14 -20
- package/src/_docs/pages/borders/border-radius.mdx +2 -2
- package/src/_docs/pages/borders/border-radius.stories.tsx +18 -22
- package/src/_docs/pages/borders/border-spacing.mdx +2 -2
- package/src/_docs/pages/borders/border-spacing.stories.tsx +15 -19
- package/src/_docs/pages/borders/border-width.mdx +8 -9
- package/src/_docs/pages/borders/border-width.stories.tsx +18 -22
- package/src/_docs/pages/configuration.mdx +18 -22
- package/src/_docs/pages/contributing.mdx +2 -2
- package/src/_docs/pages/effects/shadow.mdx +2 -2
- package/src/_docs/pages/effects/shadow.stories.tsx +17 -19
- package/src/_docs/pages/getting-started.mdx +9 -9
- package/src/_docs/pages/modifiers/media-queries.mdx +2 -2
- package/src/_docs/pages/modifiers/media-queries.stories.tsx +14 -24
- package/src/_docs/pages/modifiers/pseudo-states.mdx +5 -5
- package/src/_docs/pages/modifiers/pseudo-states.stories.tsx +10 -16
- package/src/_docs/pages/overview.mdx +6 -5
- package/src/_docs/pages/spacing/margin.mdx +7 -7
- package/src/_docs/pages/spacing/margin.stories.tsx +17 -22
- package/src/_docs/pages/spacing/padding.mdx +7 -7
- package/src/_docs/pages/spacing/padding.stories.tsx +17 -24
- package/src/_docs/pages/typography/font-family.mdx +2 -2
- package/src/_docs/pages/typography/font-family.stories.tsx +15 -19
- package/src/_docs/pages/typography/font-size.mdx +2 -2
- package/src/_docs/pages/typography/font-size.stories.tsx +11 -12
- package/src/_docs/pages/typography/font-weight.mdx +2 -2
- package/src/_docs/pages/typography/font-weight.stories.tsx +15 -19
- package/src/_docs/pages/typography/line-height.mdx +2 -2
- package/src/_docs/pages/typography/line-height.stories.tsx +17 -23
- package/src/_docs/pages/typography/max-text-width.mdx +2 -2
- package/src/_docs/pages/typography/max-text-width.stories.tsx +25 -29
- package/src/_docs/pages/typography/text-color.mdx +2 -2
- package/src/_docs/pages/typography/text-color.stories.tsx +16 -17
- package/src/_docs/pages/utility-class-helpers-overview.mdx +24 -23
- package/src/_docs/pages/working-with-tailwind.mdx +11 -7
- package/src/_docs/pages/working-with-tailwind.stories.tsx +12 -21
- package/src/_docs/utils/TailwindStoryTemplate/TailwindStoryTemplate.tsx +52 -42
- package/src/_docs/utils/TailwindStoryTemplate/components/CardContent/CardContent.tsx +5 -8
- package/src/_docs/utils/TailwindStoryTemplate/components/CardContent/index.ts +1 -1
- package/src/_docs/utils/TailwindStoryTemplate/components/CodeSnippet/CodeSnippet.tsx +3 -3
- package/src/_docs/utils/TailwindStoryTemplate/components/CodeSnippet/index.ts +1 -1
- package/src/_docs/utils/TailwindStoryTemplate/index.ts +1 -1
- package/src/_docs/utils/flattenEntries.ts +12 -13
- package/src/_docs/utils/utilityDescription.ts +1 -4
- package/src/index.ts +1 -1
- package/src/kz-height.ts +10 -10
- package/src/kz-spacing.spec.ts +24 -24
- package/src/kz-spacing.ts +21 -22
- package/src/tailwind-presets.ts +68 -68
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Meta, Unstyled } from
|
|
2
|
-
import { LinkTo } from
|
|
3
|
-
import CopyUtilityClass from
|
|
4
|
-
import UtilitySearchResult from
|
|
5
|
-
import { TailwindStoryTemplate } from
|
|
1
|
+
import { Meta, Unstyled } from '@storybook/blocks'
|
|
2
|
+
import { LinkTo } from '~storybook/components/LinkTo'
|
|
3
|
+
import CopyUtilityClass from '~tailwind/_docs/assets/copy-utility-class.gif?url'
|
|
4
|
+
import UtilitySearchResult from '~tailwind/_docs/assets/utility-search-result.png?url'
|
|
5
|
+
import { TailwindStoryTemplate } from '~tailwind/_docs/utils/TailwindStoryTemplate'
|
|
6
6
|
|
|
7
7
|
<Meta title="Guides/Tailwind/Utility Class References/Overview" />
|
|
8
8
|
|
|
@@ -18,26 +18,24 @@ As an example, `borderColor` is listed in this section because we have a custom
|
|
|
18
18
|
- [Structure](#structure)
|
|
19
19
|
- [Example usage](#example-usage)
|
|
20
20
|
|
|
21
|
-
<br/>
|
|
21
|
+
<br />
|
|
22
22
|
|
|
23
23
|
## Structure
|
|
24
24
|
|
|
25
25
|
The references provide the following structure for each utility class:
|
|
26
26
|
|
|
27
27
|
<Unstyled>
|
|
28
|
-
<div className="w-100">
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/>
|
|
36
|
-
</div>
|
|
28
|
+
<div className="w-100">
|
|
29
|
+
<TailwindStoryTemplate
|
|
30
|
+
compiledCssPropertyName="width"
|
|
31
|
+
classKeyValues={[{ utilityClassName: 'text-heading-1', cssProperty: '2.125rem' }]}
|
|
32
|
+
renderExampleComponent={(cssProperty) => <p style={{ fontSize: cssProperty }}>Aa</p>}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
37
35
|
</Unstyled>
|
|
38
36
|
|
|
39
|
-
<br/>
|
|
40
|
-
<br/>
|
|
37
|
+
<br />
|
|
38
|
+
<br />
|
|
41
39
|
|
|
42
40
|
### Utility Class
|
|
43
41
|
|
|
@@ -51,7 +49,7 @@ Represents the CSS property that Tailwind will compile for you when it recognize
|
|
|
51
49
|
|
|
52
50
|
A visual representation of the CSS generated by the utility class. You can inspect this element in the DOM to see the utility class in action.
|
|
53
51
|
|
|
54
|
-
<br/>
|
|
52
|
+
<br />
|
|
55
53
|
|
|
56
54
|
## Example usage
|
|
57
55
|
|
|
@@ -69,18 +67,21 @@ A visual representation of the CSS generated by the utility class. You can inspe
|
|
|
69
67
|
<img src={UtilitySearchResult} alt="Utility class search result" />
|
|
70
68
|
</div>
|
|
71
69
|
|
|
72
|
-
<p>
|
|
70
|
+
<p>
|
|
71
|
+
Can't find it here? That means we don't have a custom preset for it, and the utility
|
|
72
|
+
class you need will be unchanged from the Tailwind Default.
|
|
73
|
+
</p>
|
|
73
74
|
<p>Search in the [Tailwind docs](https://tailwindcss.com/docs/installation) instead.</p>
|
|
74
75
|
|
|
75
|
-
<br/>
|
|
76
|
-
<br/>
|
|
76
|
+
<br />
|
|
77
|
+
<br />
|
|
77
78
|
|
|
78
79
|
### 2. Find the utility class that compiles to the desired CSS, and copy it
|
|
79
80
|
|
|
80
81
|
<img src={CopyUtilityClass} alt="Copy utility class" />
|
|
81
82
|
|
|
82
|
-
<br/>
|
|
83
|
-
<br/>
|
|
83
|
+
<br />
|
|
84
|
+
<br />
|
|
84
85
|
|
|
85
86
|
### 3. Add the utility class to the element
|
|
86
87
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Canvas, Meta } from
|
|
2
|
-
import * as Examples from
|
|
1
|
+
import { Canvas, Meta } from '@storybook/blocks'
|
|
2
|
+
import * as Examples from './working-with-tailwind.stories'
|
|
3
3
|
|
|
4
4
|
<Meta of={Examples} />
|
|
5
5
|
|
|
@@ -12,7 +12,7 @@ This page describes and demonstrates the main intended use cases for this packag
|
|
|
12
12
|
- [Creating bespoke components](#creating-bespoke-components)
|
|
13
13
|
- [Recommended escape hatch](#recommended-escape-hatch)
|
|
14
14
|
|
|
15
|
-
<br/>
|
|
15
|
+
<br />
|
|
16
16
|
|
|
17
17
|
## Spacing and layouts
|
|
18
18
|
|
|
@@ -33,7 +33,7 @@ Here's a more complex example, where some `<Card>` components and text have been
|
|
|
33
33
|
|
|
34
34
|
<Canvas of={Examples.TailwindExampleSpacingAndLayoutsComplex} />
|
|
35
35
|
|
|
36
|
-
<br/>
|
|
36
|
+
<br />
|
|
37
37
|
|
|
38
38
|
## Altering Kaizen components with classNameOverride
|
|
39
39
|
|
|
@@ -48,18 +48,20 @@ In this example, a Tailwind css rule is being applied to a Kaizen `<Heading />`
|
|
|
48
48
|
|
|
49
49
|
- first-letter:capitalize: Adds text-transform: capitalize on the first-letter pseudo selector
|
|
50
50
|
|
|
51
|
-
<br/>
|
|
51
|
+
<br />
|
|
52
52
|
|
|
53
53
|
## Creating bespoke components
|
|
54
|
+
|
|
54
55
|
Occasionally snowflakes need to be created. This package provides common utilities based on our design tokens, such as color, border-radius, and font-family. Ideally, as much styling of bespoke components should be handled with Tailwind, but keep in mind that scss can still be used when necessary.
|
|
55
56
|
|
|
56
57
|
Here is an example of our TW package being used to create a bespoke, non-Kaizen component:
|
|
57
58
|
|
|
58
59
|
<Canvas of={Examples.TailwindExampleSnowflake} />
|
|
59
60
|
|
|
60
|
-
<br/>
|
|
61
|
+
<br />
|
|
61
62
|
|
|
62
63
|
### The container div
|
|
64
|
+
|
|
63
65
|
- `w-[250px]`: Adds `width: 250px`. This is an example of an arbitrary value being used to inject a custom suffix
|
|
64
66
|
- `rounded`: Adds `border-radius: 7px`. This is one of our custom preset values
|
|
65
67
|
- `border-dashed`: Adds `border-style: dashed`
|
|
@@ -68,18 +70,20 @@ Here is an example of our TW package being used to create a bespoke, non-Kaizen
|
|
|
68
70
|
- `text-center`: Adds `text-align: center`
|
|
69
71
|
|
|
70
72
|
### The p tag
|
|
73
|
+
|
|
71
74
|
- `m-0`: Adds `margin: 0`
|
|
72
75
|
- `p-12`: Adds `padding: .75rem` (12px = 0.75rem)
|
|
73
76
|
- `pl-16`: Adds `padding-left: 1rem` (16px = 1rem)
|
|
74
77
|
- `font-family-paragraph`: Adds `font-family: "Inter", "Noto Sans", ...`
|
|
75
78
|
- `text-blue-500`: Adds `color: #0168b3` (our blue-500 design token)
|
|
76
79
|
|
|
77
|
-
<br/>
|
|
80
|
+
<br />
|
|
78
81
|
|
|
79
82
|
## Recommended Escape Hatch
|
|
80
83
|
|
|
81
84
|
If you find yourself needing to add styles in a way that is unsupported or otherwise difficult in Tailwind, the recommended alternative is CSS. CSS classes can be added alongside Tailwind utility classes without trouble, and the Tailwind docs recommend some useful post-css plugins [here](https://tailwindcss.com/docs/using-with-preprocessors#using-sass-less-or-stylus).
|
|
82
85
|
|
|
83
86
|
### Why not SCSS?
|
|
87
|
+
|
|
84
88
|
- SCSS is currently a contained option, so writing new SCSS in our codebases is discouraged.
|
|
85
89
|
- The Tailwind docs explicitly recommend <em>not</em> using Tailwind with preprocessors, as it leads to all sorts of quirks and work-arounds. Read more [here](https://tailwindcss.com/docs/using-with-preprocessors#using-sass-less-or-stylus).
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { StoryFn } from
|
|
3
|
-
import { Card } from
|
|
4
|
-
import { Heading } from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from
|
|
9
|
-
import { Skirt } from "~components/Skirt"
|
|
10
|
-
import { Button } from "~components/__actions__/v2"
|
|
11
|
-
import { TailwindStoryTemplate } from "../utils/TailwindStoryTemplate"
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { StoryFn } from '@storybook/react'
|
|
3
|
+
import { Card } from '~components/Card'
|
|
4
|
+
import { Heading } from '~components/Heading'
|
|
5
|
+
import { CustomSurvey, CustomUnattributedSurvey } from '~components/Illustration'
|
|
6
|
+
import { Skirt } from '~components/Skirt'
|
|
7
|
+
import { Button } from '~components/__actions__/v2'
|
|
8
|
+
import { TailwindStoryTemplate } from '../utils/TailwindStoryTemplate'
|
|
12
9
|
|
|
13
10
|
export default {
|
|
14
|
-
title:
|
|
11
|
+
title: 'Guides/Tailwind/Working with Tailwind',
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
export const TailwindExampleSpacingAndLayouts: StoryFn = () => (
|
|
@@ -47,12 +44,8 @@ export const TailwindExampleSpacingAndLayoutsComplex: StoryFn = () => (
|
|
|
47
44
|
</p>
|
|
48
45
|
{/* Adds margin-top, flex, and a height of 200px */}
|
|
49
46
|
<div className="mt-64 flex h-[200px]">
|
|
50
|
-
{[0, 1, 2, 3].map(index => (
|
|
51
|
-
<Card
|
|
52
|
-
key={index}
|
|
53
|
-
variant="informative"
|
|
54
|
-
classNameOverride="mr-24 last:mr-0 w-full"
|
|
55
|
-
>
|
|
47
|
+
{[0, 1, 2, 3].map((index) => (
|
|
48
|
+
<Card key={index} variant="informative" classNameOverride="mr-24 last:mr-0 w-full">
|
|
56
49
|
{/* Adds height and width of 100% */}
|
|
57
50
|
<div className="w-full h-100" />
|
|
58
51
|
</Card>
|
|
@@ -75,9 +68,7 @@ export const TailwindExampleClassNameOverrideMargin: StoryFn = () => (
|
|
|
75
68
|
<Card>
|
|
76
69
|
<TailwindStoryTemplate.CardContent
|
|
77
70
|
title="Card 2"
|
|
78
|
-
illustration={
|
|
79
|
-
<CustomUnattributedSurvey alt="custom-unattributed-survey" />
|
|
80
|
-
}
|
|
71
|
+
illustration={<CustomUnattributedSurvey alt="custom-unattributed-survey" />}
|
|
81
72
|
/>
|
|
82
73
|
</Card>
|
|
83
74
|
</div>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CardContent } from
|
|
5
|
-
import { CodeSnippet } from
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Heading } from '~components/Heading'
|
|
3
|
+
import { InlineNotification } from '~components/Notification'
|
|
4
|
+
import { CardContent } from './components/CardContent'
|
|
5
|
+
import { CodeSnippet } from './components/CodeSnippet'
|
|
6
6
|
|
|
7
7
|
type Props = {
|
|
8
8
|
compiledCssPropertyName: string
|
|
9
|
-
classKeyValues:
|
|
9
|
+
classKeyValues: { utilityClassName: string; cssProperty: string }[]
|
|
10
10
|
renderExampleComponent: (utilityClass: string) => React.ReactElement
|
|
11
11
|
isReversed?: boolean
|
|
12
12
|
}
|
|
@@ -15,48 +15,58 @@ export const TailwindStoryTemplate = ({
|
|
|
15
15
|
compiledCssPropertyName,
|
|
16
16
|
classKeyValues,
|
|
17
17
|
renderExampleComponent,
|
|
18
|
-
isReversed = false,
|
|
19
18
|
}: Props): React.ReactElement => {
|
|
20
19
|
const [copiedText, setCopiedText] = useState<null | string>(null)
|
|
21
20
|
|
|
22
21
|
return (
|
|
23
22
|
<div className="w-full">
|
|
24
|
-
<
|
|
25
|
-
className="
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
<table className="border-collapse w-full font-family-paragraph">
|
|
24
|
+
<thead className="text-left">
|
|
25
|
+
<tr className="border-b border-gray-400">
|
|
26
|
+
<th className="p-12">
|
|
27
|
+
<Heading variant="heading-5" tag="span">
|
|
28
|
+
Utility Class
|
|
29
|
+
</Heading>
|
|
30
|
+
</th>
|
|
31
|
+
<th className="p-12">
|
|
32
|
+
<Heading variant="heading-5" tag="span">
|
|
33
|
+
Compiled CSS
|
|
34
|
+
</Heading>
|
|
35
|
+
</th>
|
|
36
|
+
<th className="p-12">
|
|
37
|
+
<Heading variant="heading-5" tag="span">
|
|
38
|
+
Example
|
|
39
|
+
</Heading>
|
|
40
|
+
</th>
|
|
41
|
+
</tr>
|
|
42
|
+
</thead>
|
|
43
|
+
<tbody>
|
|
44
|
+
{classKeyValues.map((presetData, index) => {
|
|
36
45
|
const { utilityClassName, cssProperty } = presetData
|
|
37
46
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
</
|
|
52
|
-
<
|
|
53
|
-
{renderExampleComponent(utilityClassName)}
|
|
54
|
-
</
|
|
55
|
-
</
|
|
47
|
+
<tr key={index} className="border-b-1 border-gray-400">
|
|
48
|
+
<td className="p-12">
|
|
49
|
+
<div className="mr-32 min-w-max max-w-[300px]">
|
|
50
|
+
<CodeSnippet
|
|
51
|
+
text={utilityClassName.replace('-DEFAULT', '')}
|
|
52
|
+
onCopy={(text: string): void => setCopiedText(text)}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
</td>
|
|
56
|
+
<td className="p-12">
|
|
57
|
+
<p className="mr-32 w-max">
|
|
58
|
+
{compiledCssPropertyName}: {cssProperty}
|
|
59
|
+
</p>
|
|
60
|
+
</td>
|
|
61
|
+
<td className="p-12">
|
|
62
|
+
<div>{renderExampleComponent(utilityClassName)}</div>
|
|
63
|
+
</td>
|
|
64
|
+
</tr>
|
|
56
65
|
)
|
|
57
66
|
})}
|
|
58
|
-
</
|
|
59
|
-
</
|
|
67
|
+
</tbody>
|
|
68
|
+
</table>
|
|
69
|
+
|
|
60
70
|
<div className="fixed top-[10px] left-[10px]">
|
|
61
71
|
{copiedText && (
|
|
62
72
|
<InlineNotification
|
|
@@ -64,8 +74,8 @@ export const TailwindStoryTemplate = ({
|
|
|
64
74
|
hideCloseIcon
|
|
65
75
|
onHide={(): void => setCopiedText(null)}
|
|
66
76
|
headingProps={{
|
|
67
|
-
children:
|
|
68
|
-
variant:
|
|
77
|
+
children: 'Copied to clipboard: ',
|
|
78
|
+
variant: 'heading-6',
|
|
69
79
|
}}
|
|
70
80
|
>
|
|
71
81
|
{copiedText}
|
|
@@ -78,4 +88,4 @@ export const TailwindStoryTemplate = ({
|
|
|
78
88
|
|
|
79
89
|
TailwindStoryTemplate.CardContent = CardContent
|
|
80
90
|
|
|
81
|
-
TailwindStoryTemplate.displayName =
|
|
91
|
+
TailwindStoryTemplate.displayName = 'TailwindStoryTemplate'
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Heading } from
|
|
3
|
-
import { Button } from
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Heading } from '~components/Heading'
|
|
3
|
+
import { Button } from '~components/__actions__/v2'
|
|
4
4
|
|
|
5
5
|
type CardContentProps = {
|
|
6
6
|
title: string
|
|
7
7
|
illustration: React.ReactElement
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const CardContent = ({
|
|
11
|
-
title,
|
|
12
|
-
illustration,
|
|
13
|
-
}: CardContentProps): React.ReactElement => (
|
|
10
|
+
export const CardContent = ({ title, illustration }: CardContentProps): React.ReactElement => (
|
|
14
11
|
<div className="flex w-[400px] flex-col items-center p-24 pt-48">
|
|
15
12
|
<Heading variant="heading-3">{title}</Heading>
|
|
16
13
|
<p className="pt-12 pb-24 text-center font-family-paragraph text-heading-6 font-weight-paragraph text-purple-800">
|
|
@@ -23,4 +20,4 @@ export const CardContent = ({
|
|
|
23
20
|
</div>
|
|
24
21
|
)
|
|
25
22
|
|
|
26
|
-
CardContent.displayName =
|
|
23
|
+
CardContent.displayName = 'CardContent'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './CardContent'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import { Icon } from
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Icon } from '~components/__future__'
|
|
3
3
|
|
|
4
4
|
type Props = {
|
|
5
5
|
text: string
|
|
@@ -11,7 +11,7 @@ export const CodeSnippet = ({ text, onCopy }: Props): React.ReactElement => {
|
|
|
11
11
|
const handleCopy = (utilityClassNameName: string): void => {
|
|
12
12
|
navigator.clipboard.writeText(text)
|
|
13
13
|
setCopyIconIsChecked(true)
|
|
14
|
-
onCopy
|
|
14
|
+
onCopy?.(utilityClassNameName)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return (
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './CodeSnippet'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './TailwindStoryTemplate'
|
|
@@ -6,30 +6,29 @@ type ResolvableTo<T> = T | ((utils: any) => T)
|
|
|
6
6
|
|
|
7
7
|
export const flattenEntries = (
|
|
8
8
|
prefix: string,
|
|
9
|
-
themeObj: ResolvableTo<RecursiveKeyValuePair<string, string
|
|
10
|
-
):
|
|
9
|
+
themeObj: ResolvableTo<RecursiveKeyValuePair<string, string>>,
|
|
10
|
+
): {
|
|
11
11
|
utilityClassName: string
|
|
12
12
|
cssProperty: string
|
|
13
|
-
}
|
|
13
|
+
}[] => {
|
|
14
14
|
const classKeyVal: string[][] = Object.entries(themeObj || [])
|
|
15
|
-
const flattenedEntries:
|
|
15
|
+
const flattenedEntries: {
|
|
16
16
|
utilityClassName: string
|
|
17
17
|
cssProperty: string
|
|
18
|
-
}
|
|
19
|
-
classKeyVal.forEach(colorGroup => {
|
|
18
|
+
}[] = []
|
|
19
|
+
classKeyVal.forEach((colorGroup) => {
|
|
20
20
|
const [classModifier, cssProperty] = colorGroup
|
|
21
|
-
if (typeof cssProperty ===
|
|
21
|
+
if (typeof cssProperty === 'string') {
|
|
22
22
|
flattenedEntries.push({
|
|
23
23
|
utilityClassName: `${prefix}${classModifier}`,
|
|
24
24
|
cssProperty,
|
|
25
25
|
})
|
|
26
26
|
} else {
|
|
27
|
-
Object.entries(cssProperty as Record<string, string>).forEach(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
27
|
+
Object.entries(cssProperty as Record<string, string>).forEach((classNamePair) =>
|
|
28
|
+
flattenedEntries.push({
|
|
29
|
+
utilityClassName: `${prefix}${classModifier}-${classNamePair[0]}`,
|
|
30
|
+
cssProperty: classNamePair[1],
|
|
31
|
+
}),
|
|
33
32
|
)
|
|
34
33
|
}
|
|
35
34
|
})
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './tailwind-presets'
|
package/src/kz-height.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const kzHeight = {
|
|
2
|
-
0:
|
|
3
|
-
25:
|
|
4
|
-
33:
|
|
5
|
-
50:
|
|
6
|
-
75:
|
|
7
|
-
100:
|
|
8
|
-
auto:
|
|
9
|
-
min:
|
|
10
|
-
max:
|
|
11
|
-
fit:
|
|
2
|
+
0: '0',
|
|
3
|
+
25: '25%',
|
|
4
|
+
33: '33.333333%',
|
|
5
|
+
50: '50%',
|
|
6
|
+
75: '75%',
|
|
7
|
+
100: '100%',
|
|
8
|
+
auto: 'auto',
|
|
9
|
+
min: 'min-content',
|
|
10
|
+
max: 'max-content',
|
|
11
|
+
fit: 'fit-content',
|
|
12
12
|
}
|
package/src/kz-spacing.spec.ts
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { filterDenyListValues } from
|
|
1
|
+
import { filterDenyListValues } from './kz-spacing'
|
|
2
2
|
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
3
|
+
describe('filterDenyListValues', () => {
|
|
4
|
+
it('Keeps all numeric keys', () => {
|
|
5
5
|
const result = filterDenyListValues({
|
|
6
|
-
0:
|
|
7
|
-
xs:
|
|
8
|
-
1:
|
|
9
|
-
sm:
|
|
10
|
-
2:
|
|
6
|
+
0: '0',
|
|
7
|
+
xs: '0.375rem',
|
|
8
|
+
1: '.0625rem',
|
|
9
|
+
sm: '0.75rem',
|
|
10
|
+
2: '.125rem',
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
expect(result).toEqual({
|
|
14
|
-
0:
|
|
15
|
-
1:
|
|
16
|
-
2:
|
|
14
|
+
0: '0',
|
|
15
|
+
1: '.0625rem',
|
|
16
|
+
2: '.125rem',
|
|
17
17
|
})
|
|
18
18
|
})
|
|
19
|
-
it(
|
|
19
|
+
it('Keeps valid tailwind defaults', () => {
|
|
20
20
|
const result = filterDenyListValues({
|
|
21
|
-
0:
|
|
22
|
-
xs:
|
|
23
|
-
1:
|
|
24
|
-
sm:
|
|
25
|
-
2:
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
0: '0',
|
|
22
|
+
'xs': '0.375rem',
|
|
23
|
+
1: '.0625rem',
|
|
24
|
+
'sm': '0.75rem',
|
|
25
|
+
2: '.125rem',
|
|
26
|
+
'w-1/2': '50%',
|
|
27
|
+
'w-full': '100%',
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
expect(result).toEqual({
|
|
31
|
-
0:
|
|
32
|
-
1:
|
|
33
|
-
2:
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
0: '0',
|
|
32
|
+
1: '.0625rem',
|
|
33
|
+
2: '.125rem',
|
|
34
|
+
'w-1/2': '50%',
|
|
35
|
+
'w-full': '100%',
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
})
|
package/src/kz-spacing.ts
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
|
-
import { heartTheme } from
|
|
1
|
+
import { heartTheme } from '@kaizen/design-tokens'
|
|
2
2
|
|
|
3
3
|
const tokenDenyList: string[] = [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
'xs',
|
|
5
|
+
'sm',
|
|
6
|
+
'md',
|
|
7
|
+
'lg',
|
|
8
|
+
'xl',
|
|
9
|
+
'xxl',
|
|
10
|
+
'xxxl',
|
|
11
|
+
'xxxxl',
|
|
12
|
+
'xxxxxl',
|
|
13
|
+
'xs-id',
|
|
14
|
+
'sm-id',
|
|
15
|
+
'md-id',
|
|
16
|
+
'lg-id',
|
|
17
|
+
'xl-id',
|
|
18
|
+
'xxl-id',
|
|
19
|
+
'xxxl-id',
|
|
20
|
+
'xxxxl-id',
|
|
21
|
+
'xxxxxl-id',
|
|
22
22
|
]
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* checks if a key from design tokens should be filtered from tailwind
|
|
26
26
|
*/
|
|
27
|
-
const isValidToken = (key: string | number): boolean =>
|
|
28
|
-
tokenDenyList.indexOf(`${key}`) < 0
|
|
27
|
+
const isValidToken = (key: string | number): boolean => !tokenDenyList.includes(`${key}`)
|
|
29
28
|
|
|
30
29
|
// Filters out non-pixel-based spacing tokens, such as shirt sizes
|
|
31
30
|
export const filterDenyListValues = (
|
|
32
|
-
spacingTokensObject: Record<string, string
|
|
31
|
+
spacingTokensObject: Record<string, string>,
|
|
33
32
|
): Record<string, string> => {
|
|
34
33
|
const keyValuePairs = Object.entries(spacingTokensObject)
|
|
35
34
|
|