Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kds 1611 fix border config #4256

Merged
merged 48 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4966081
Add DEFAULT styles to TW preset
JakePitman Oct 31, 2023
b108d8e
Add @kaizen/reset package
JakePitman Nov 2, 2023
b0942eb
Update docs
JakePitman Nov 2, 2023
d63ab97
Add changeset
JakePitman Nov 2, 2023
c2d72a6
Fix export issue
JakePitman Nov 2, 2023
b77851c
Merge branch 'main' into KDS-1611-fix-border-config
JakePitman Nov 2, 2023
e28ec3f
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 2, 2023
f80ee52
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 2, 2023
c2ec958
cleanup + docs
Nov 2, 2023
401ac81
Merge branch 'KDS-1611-fix-border-config' of github.com:cultureamp/ka…
Nov 2, 2023
8206278
cleanup package.json
Nov 2, 2023
344fdeb
remove version
Nov 2, 2023
9607a00
add changeset
Nov 2, 2023
fd15566
add changeset
Nov 2, 2023
de7d0ec
fix changesets
Nov 2, 2023
9165ea5
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 3, 2023
ed2ffb2
remove '-default' utility classes + replace defaultTheme usage in tw …
Nov 3, 2023
a5d0353
Merge branch 'KDS-1611-fix-border-config' of github.com:cultureamp/ka…
Nov 3, 2023
de175f7
bring back default
Nov 3, 2023
47360e2
upgrade tailwind design token dep
Nov 3, 2023
31cb5f1
change to peerDep
Nov 3, 2023
c775121
revert token changes
Nov 3, 2023
76ceb66
revert design-tokens peerDep
Nov 3, 2023
140da55
fix up tailwind docs
Nov 5, 2023
e8dc54b
revert token source for less noisy PR
Nov 5, 2023
b7f7f50
cleanup
Nov 5, 2023
ec3af02
update changeset
Nov 5, 2023
71da0fb
Merge branch 'main' into KDS-1611-fix-border-config
Nov 5, 2023
40bb8a9
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 6, 2023
c7e5380
fix tailwind docs styles
Nov 6, 2023
00122f2
fix missing borders
Nov 6, 2023
6191154
Merge branch 'KDS-1611-fix-border-config' of github.com:cultureamp/ka…
Nov 6, 2023
d6433f2
update tw preset to a major + disclaimer
Nov 6, 2023
80469dd
darkened border examples
Nov 6, 2023
370db36
fix border styling
Nov 6, 2023
3045909
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 6, 2023
14eb6a6
fix missing borders
Nov 6, 2023
4549f01
Merge branch 'KDS-1611-fix-border-config' of github.com:cultureamp/ka…
Nov 6, 2023
101035e
fix lint
Nov 6, 2023
fbb2255
fix stories
Nov 6, 2023
fb630b2
lint
Nov 6, 2023
cf2eba6
remove unuseful script
Nov 8, 2023
2fdf4ad
update changeset
Nov 8, 2023
06352ee
cleanup
Nov 8, 2023
07ff877
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 8, 2023
7e2722f
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 8, 2023
bb34d2e
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 8, 2023
30a1ac1
Merge branch 'main' into KDS-1611-fix-border-config
gyfchong Nov 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/gold-carrots-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
"@kaizen/tailwind": major
mcwinter07 marked this conversation as resolved.
Show resolved Hide resolved
---

Fix long utility strings for borders in Tailwind (in combination with the introduction of `@kaizen/reset.css`)

**note: these utilities will not work without installing `@kaizen/reset.css`**

- Adds DEFAULT values to `borderWidth` and `borderColor` in the Tailwind preset, so these don't need to be written with utility classes.

These changes mean that border styles require much less utility classes to be written.
For example, to add a border-bottom to an element, we would previously need to write:
```
className="border-b-default border-l-none border-r-none border-t-none border-solid border-purple-800"
```
We can now achieve the same css by simply writing:
```
className="border-b"
```
5 changes: 5 additions & 0 deletions .changeset/quiet-poems-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kaizen/reset.css": major
mcwinter07 marked this conversation as resolved.
Show resolved Hide resolved
---

Initialising this package with a reset to the border properties to support Tailwind's border default settings.
16 changes: 10 additions & 6 deletions docs/Systems/Tailwind/components/CodeSnippet.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useState } from "react"
import { ClosedIcon, SurveysIcon } from "~components/Icon"

type Props = {
text: string
onCopy?: (text: string) => void
}

export const CodeSnippet = ({ text, onCopy }: Props): React.ReactElement => {
const [_, setCopyIconIsChecked] = useState(false)
const [copyIconIsChecked, setCopyIconIsChecked] = useState(false)
const handleCopy = (utilityClassNameName: string): void => {
navigator.clipboard.writeText(text)
setCopyIconIsChecked(true)
Expand All @@ -16,16 +17,19 @@ export const CodeSnippet = ({ text, onCopy }: Props): React.ReactElement => {
return (
<button
type="button"
className="bg-[#00182e] h-min rounded-default px-12 border-none cursor-pointer w-full"
className="bg-[#00182e] h-min rounded px-12 border-none cursor-pointer w-full"
onClick={(): void => handleCopy(text)}
onBlur={(): void => setCopyIconIsChecked(false)}
>
<p className="font-family-paragraph text-white flex justify-between items-center">
<span>{text}</span>
{/* Replace with Icons */}
{/* <span className="text-underline">
{copyIconIsChecked ? "copied" : "copy"}
</span> */}
<span className="text-underline text-white">
{copyIconIsChecked ? (
<ClosedIcon role="img" aria-label="copied" />
) : (
<SurveysIcon role="img" aria-label="copy" />
)}
</span>
</p>
</button>
)
Expand Down
2 changes: 1 addition & 1 deletion docs/Systems/Tailwind/components/DemoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ type Props = {

const DemoBox = ({ classnameOverride }: Props): React.ReactElement => (
<div
className={`h-100 w-full rounded-default bg-blue-200 ${
className={`h-100 w-full rounded bg-blue-200 ${
classnameOverride ? classnameOverride : ""
}`}
/>
Expand Down
7 changes: 3 additions & 4 deletions docs/Systems/Tailwind/components/UtilityClassTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,21 @@ export const UtilityClassTemplate = ({
rules="rows"
>
<StickerSheet.Header
className="text-left border-transparent border-solid border-b-gray-400"
className="text-left border-b border-gray-400"
headings={["Utility Class", "Compiled CSS", "Example"]}
/>
<StickerSheet.Body>
{classKeyValues.map((presetData, _index) => {
const { utilityClassName, cssProperty } = presetData

return (
<StickerSheet.Row
key={_index}
rowTitle=""
className="border-gray-400"
className="border-b-1 border-gray-400"
>
<div className="mr-32 min-w-max max-w-[300px]">
<CodeSnippet
text={utilityClassName}
text={utilityClassName.replace("-DEFAULT", "")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the -DEFAULT postfix on the utility class showing up in the code snippets on the docs.

onCopy={(text: string): void => setCopiedText(text)}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/Systems/Tailwind/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ For more information, see [here](https://tailwindcss.com/docs/functions-and-dire

### Tailwind Play

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/RAS26OUabN)
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)

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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export const BackgroundColor: StoryFn<{ isReversed: boolean }> = ({
renderExampleComponent={(utilityClass): React.ReactElement => (
<div
className={classnames(
"w-[100px] h-[100px] border-solid",
"rounded-default",
"w-[100px] h-[100px] border border-purple-500 rounded",
utilityClass
)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const BorderColor: StoryFn<{ isReversed: boolean }> = ({
renderExampleComponent={(utilityClass): React.ReactElement => (
<div
className={classnames(
"rounded-default w-[100px] h-[100px] border-solid",
utilityClass
"rounded w-[100px] h-[100px] border",
utilityClass.replace("-DEFAULT", "")
)}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
docsLayout: "fullPage",
docs: {
description: {
component: utilityDescription(prefix, classEntries[0].utilityClassName),
component: utilityDescription(prefix, classEntries[3].utilityClassName),
},
},
},
Expand All @@ -36,7 +36,10 @@ export const BorderRadius: StoryFn<{ isReversed: boolean }> = ({
classKeyValues={classEntries}
renderExampleComponent={(utilityClass): React.ReactElement => (
<div
className={classnames("w-[100px] h-[100px] border-solid", utilityClass)}
className={classnames(
"w-[100px] h-[100px] border border-purple-500",
utilityClass.replace("-DEFAULT", "")
)}
/>
)}
isReversed={isReversed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
docsLayout: "fullPage",
docs: {
description: {
component: utilityDescription(prefix, classEntries[0].utilityClassName),
component: utilityDescription(prefix, classEntries[1].utilityClassName),
},
},
},
Expand All @@ -37,8 +37,8 @@ export const BorderWidth: StoryFn<{ isReversed: boolean }> = ({
renderExampleComponent={(utilityClass): React.ReactElement => (
<div
className={classnames(
"w-[100px] h-[100px] border-solid border-[black] border-default",
utilityClass
"w-[100px] h-[100px] border rounded",
!utilityClass.includes("-DEFAULT") && utilityClass
)}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export const MediaQueries: StoryFn = () => (
that bg-blue-400 will be applied when the screen gets <em>wider</em>.
</Heading>
<QueryInfo selector="md" selectorValue="768px">
<div className="border-solid md:bg-blue-400 h-[50px] w-full rounded-default" />
<div className="border-solid md:bg-blue-400 h-[50px] w-full rounded" />
</QueryInfo>
<QueryInfo selector="lg" selectorValue="1080px">
<div className="border-solid lg:bg-blue-400 h-[50px] w-full rounded-default" />
<div className="border-solid lg:bg-blue-400 h-[50px] w-full rounded" />
</QueryInfo>
</div>
)
Expand All @@ -71,7 +71,7 @@ export const ArbitraryMediaQueries: StoryFn = () => (
<Paragraph variant="body">
In this example: min-[500px]:bg-blue-400
</Paragraph>
<div className="border-solid min-[500px]:bg-blue-400 h-[50px] w-full rounded-default" />
<div className="border-solid min-[500px]:bg-blue-400 h-[50px] w-full rounded" />
</div>

<Paragraph variant="body">
Expand All @@ -81,6 +81,6 @@ export const ArbitraryMediaQueries: StoryFn = () => (
<Paragraph variant="body">
In this example: max-[500px]:bg-blue-400
</Paragraph>
<div className="border-solid max-[500px]:bg-blue-400 h-[50px] w-full rounded-default" />
<div className="border-solid max-[500px]:bg-blue-400 h-[50px] w-full rounded" />
</div>
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const PseudoSelectors: StoryFn<{ isReversed: boolean }> = ({
<p className="font-family-paragraph">background-color: #bde2f5</p>
<button
type="button"
className="border-solid bg-white border-[black] font-family-paragraph w-[150px] rounded-default hover:bg-blue-200 py-16 px-12 text-center"
className="border-solid bg-white border-[black] font-family-paragraph w-[150px] rounded hover:bg-blue-200 py-16 px-12 text-center"
>
Hover me
</button>
Expand All @@ -40,7 +40,7 @@ export const PseudoSelectors: StoryFn<{ isReversed: boolean }> = ({
<button
type="button"
tabIndex={0}
className="border-solid bg-white border-[black] font-family-paragraph w-[150px] rounded-default focus:bg-blue-200 py-16 px-12 text-center"
className="border-solid bg-white border-[black] font-family-paragraph w-[150px] rounded focus:bg-blue-200 py-16 px-12 text-center"
>
Focus me
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ A visual representation of the CSS generated by the utility class. You can inspe

### 3. Add the utility class to the element
```tsx
<div className="rounded-default ...">...</div>
<div className="rounded ...">...</div>
```
<Canvas>
<div className="rounded-default border-solid w-max border-blue-500 bg-blue-100 px-12">
<div className="rounded border-solid w-max border-blue-500 bg-blue-100 px-12">
<p className="font-family-paragraph text-blue-700">Example</p>
</div>
</Canvas>
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export const Margin: StoryFn<{ isReversed: boolean }> = ({ isReversed }) => (
compiledCssPropertyName="margin"
classKeyValues={classEntries}
renderExampleComponent={(utilityClass): React.ReactElement => (
<div className="w-min border-solid rounded-default">
<div className="w-min border rounded">
<p
className={classnames(
"p-4 border-dashed w-min rounded-default bg-blue-100",
"p-4 border border-dashed w-min rounded bg-blue-100",
utilityClass
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const Padding: StoryFn<{ isReversed: boolean }> = ({ isReversed }) => (
renderExampleComponent={(utilityClass): React.ReactElement => (
<p
className={classnames(
"border-solid w-min rounded-default bg-blue-100",
"border border-purple-500 w-min rounded bg-blue-100",
utilityClass
)}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export const TextColor: StoryFn<{ isReversed: boolean }> = ({ isReversed }) => (
<div className="flex items-center h-100">
<p
className={classnames(
"font-family-paragraph p-8 rounded-default font-weight-display text-heading-3 m-0 mr-16",
"font-family-paragraph p-8 rounded font-weight-display text-heading-3 m-0 mr-16",
utilityClass
)}
>
Light bg
</p>
<p
className={classnames(
"font-family-paragraph p-8 bg-[black] rounded-default font-weight-display text-heading-3 m-0",
"font-family-paragraph p-8 bg-[black] rounded font-weight-display text-heading-3 m-0",
utilityClass
)}
>
Expand Down
2 changes: 1 addition & 1 deletion docs/Systems/Tailwind/working-with-tailwind.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Here is an example of our TW package being used to create a bespoke, non-Kaizen

### The container div
- `w-[250px]`: Adds `width: 250px`. This is an example of an arbitrary value being used to inject a custom suffix
- `rounded-default`: Adds `border-radius: 7px`. This is one of our custom preset values, defined here
- `rounded`: Adds `border-radius: 7px`. This is one of our custom preset values, defined here
gyfchong marked this conversation as resolved.
Show resolved Hide resolved
- `border-dashed`: Adds `border-style: dashed`
- `border-red-500`: Adds `border-color: #c93b55` (our red-500 design token)
- `bg-blue-100`: Adds `background: #e6f6ff` (our blue-100 design token)
Expand Down
2 changes: 1 addition & 1 deletion docs/Systems/Tailwind/working-with-tailwind.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const TailwindExampleClassNameOverrideHeading: StoryFn = () => (

export const TailwindExampleSnowflake: StoryFn = () => (
<div className="flex justify-center">
<div className="w-[250px] rounded-default border-dashed border-red-500 bg-blue-100">
<div className="w-[250px] rounded border-dashed border-red-500 bg-blue-100">
<p className="m-0 p-12 pl-16 font-family-paragraph text-blue-500 text-center">
Not a Kaizen Component
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,44 @@ For full installation instructions, see the <LinkTo pageId="systems-tailwind-get

Whether or not you are already familiar with Tailwind, you'll want to take a look at our <LinkTo pageId="systems-tailwind-utility-class-references-overview">Utility Class References</LinkTo>, as we have made distinct modifications to vanilla Tailwind to suit our design system.

## 4. Add the Kaizen global CSS
## 3. Add Kaizen's global CSS stylesheets
mcwinter07 marked this conversation as resolved.
Show resolved Hide resolved

For the convenience of your app, we've compiled all the necessary styles for our components into a single stylesheet to make it easy to set and forget.
There are 2 CSS stylesheets to import:
- reset: which handles any global styles that need to be applied
- components: which has all the styles for Kaizen's component library

### Important to note
The order of these CSS stylesheets is **very important**:
1. Normalize
2. Kaizen Reset
3. Kaizen Components
4. Tailwind (ie. your product CSS)

mcwinter07 marked this conversation as resolved.
Show resolved Hide resolved
No matter how you choose to import the following, this order must be upheld.

### Reset

Kaizen's CSS reset aims to add any global default styles such as typography or base styles which enable Tailwind utilities (you can think of this as Kaizen's own Preflight).
mcwinter07 marked this conversation as resolved.
Show resolved Hide resolved

Note: this is different from a Normalize which aims to create uniformity in basic elements across the multiple browsers. (eg. Corrects bugs and common browser inconsistencies).

Add the following import to the top of your `tailwind.css` file:
You can either import this via JS or CSS, just make sure it is placed _after normalize_ but _before_ any custom CSS:
```js
import "normalize.css"
import "@kaizen/reset.css" // <- Right here!
import "../src/tailwind.css"
```

You can also import this into your CSS files if your project perfers, however you must preserve the above order.

### Components

For the convenience of your app, we've compiled all the necessary styles for our components into a single stylesheet to make it easy to set and forget.

We've especially accounted for using Tailwind's de-duping process for any Tailwind within our components:
```css
@import "../node_modules/@kaizen/components/dist/styles.css";
// tailwind.css
@import "@kaizen/components/dist/styles.css";
@tailwind base;
@tailwind components;
@tailwind utilities;
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
"commit": "yarn changeset",
"plop": "plop",
"pkg:aio": "yarn workspace @kaizen/components",
"pkg:reset": "yarn workspace @kaizen/reset",
gyfchong marked this conversation as resolved.
Show resolved Hide resolved
"ci:version": "yarn turbo prepublishOnly && yarn changeset version",
"ci:publish": "yarn turbo prepublishOnly && yarn changeset publish",
"update-icons": "yarn pkg:aio update-icons"
},
"dependencies": {
"@kaizen/design-tokens": "*",
"@kaizen/reset.css": "*",
"@kaizen/tailwind": "*",
"@storybook/addons": "^7.5.2",
"@storybook/api": "^7.5.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const meta = {
<>
<Label htmlFor="id--field-1">Email</Label>
<input
className="ms-6"
className="ms-6 border"
placeholder="Native text input..."
type="text"
id="id--field-1"
Expand Down Expand Up @@ -41,7 +41,7 @@ export const Inline: Story = {
<FieldGroup classNameOverride="mr-6" inline>
<Label htmlFor="id--field-1">Email</Label>
<input
className="ms-6"
className="ms-6 border"
placeholder="Native text input..."
type="text"
id="id--field-2"
Expand All @@ -50,7 +50,7 @@ export const Inline: Story = {
<FieldGroup inline>
<Label htmlFor="id--field-1">Username</Label>
<input
className="ms-6"
className="ms-6 border"
placeholder="Native text input..."
type="text"
id="id--field-2"
Expand All @@ -66,7 +66,7 @@ export const Default: Story = {
<FieldGroup>
<Label htmlFor="id--field-1">Email</Label>
<input
className="ms-6"
className="ms-6 border"
placeholder="Native text input..."
type="text"
id="id--field-2"
Expand All @@ -75,7 +75,7 @@ export const Default: Story = {
<FieldGroup>
<Label htmlFor="id--field-1">Username</Label>
<input
className="ms-6"
className="ms-6 border"
placeholder="Native text input..."
type="text"
id="id--field-2"
Expand Down
Loading