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-1756-migrate-skirt-content-to-kaio-2 #4211

Merged
merged 8 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/tough-beers-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@kaizen/components": minor
---

Migrate Skirt, Content, Container from `kaizen-legacy`
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"react-popper": "^2.3.0",
"react-select": "^5.7.7",
"react-textfit": "^1.1.1",
"resize-observer-polyfill": "^1.5.1",
"tslib": "^2.6.2",
"use-debounce": "^9.0.4",
"uuid": "^9.0.1"
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/Container/Container.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.container {
display: flex;
width: 100%;
justify-content: center;

* {
&,
&::after,
&::before {
box-sizing: border-box;
}
}
}
23 changes: 23 additions & 0 deletions packages/components/src/Container/Container.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react"
import classnames from "classnames"
import { ContentProps } from "~components/Content"
import styles from "./Container.module.scss"

/**
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3086156812/Layout Guidance} |
* {@link https://cultureamp.design/?path=/docs/components-content--docs Storybook}
*/
export const Container = React.forwardRef<HTMLDivElement, ContentProps>(
({ children, style, classNameOverride, ...restProps }, ref) => (
<div
ref={ref}
className={classnames(styles.container, classNameOverride)}
style={style}
{...restProps}
>
{children}
</div>
)
)

Container.displayName = "Container"
32 changes: 32 additions & 0 deletions packages/components/src/Container/_docs/Container.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Canvas, Controls, Meta } from "@storybook/blocks"
import { ResourceLinks, KaioNotification, Installation } from "~storybook/components"
import { LinkTo } from "~storybook/components/LinkTo"
import * as ContainerStories from "./Container.stories"

<Meta of={ContainerStories} />

# Container

gyfchong marked this conversation as resolved.
Show resolved Hide resolved
<ResourceLinks
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Container"
designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3086156812/Layout"
className="!mb-8"
/>

<KaioNotification />

<Installation
installCommand="yarn add @kaizen/components"
importStatement='import { Container } from "@kaizen/components"'
/>

## Overview

Wraps your entire page.

<Canvas of={ContainerStories.Playground} />
<Controls of={ContainerStories.Playground} />

## Use Case
Usually wraps a <LinkTo pageId="components-content">Content</LinkTo> component.
<Canvas of={ContainerStories.Example} />
65 changes: 65 additions & 0 deletions packages/components/src/Container/_docs/Container.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React from "react"
import { Meta, StoryObj } from "@storybook/react"
import { Content } from "~components/Content"
import { Text } from "~components/Text"
import { Container } from "../index"

const meta = {
title: "Pages/Container",
component: Container,
args: {
children: (
<div>
<Text variant="body">
Bacon ipsum dolor amet andouille buffalo beef boudin kielbasa
drumstick fatback cow tongue ground round chicken. Jowl cow short
ribs, ham tongue turducken spare ribs pig drumstick chuck meatball.
Buffalo turducken pancetta tail salami chicken. Bresaola venison
pastrami beef.
</Text>
<Text variant="body">
Porchetta shankle ribeye, ground round beef filet mignon fatback
chislic boudin. Boudin burgdoggen spare ribs, meatloaf pastrami pork
loin meatball short ribs tenderloin ribeye cupim venison short loin
pork chop tongue. Andouille landjaeger bacon, picanha filet mignon
short ribs hamburger shank shoulder porchetta. Pork chop ground round
tenderloin, biltong kevin corned beef chuck frankfurter spare ribs
pork meatball pastrami fatback. Strip steak beef ribs pork loin kevin,
biltong fatback tongue salami brisket capicola flank tenderloin.
</Text>
</div>
),
},
argTypes: {
children: { controls: "disabled" },
},
} satisfies Meta<typeof Container>

export default meta

type Story = StoryObj<typeof meta>

export const Playground: Story = {
parameters: {
docs: {
canvas: {
sourceState: "shown",
},
},
},
}

export const Example: Story = {
render: args => (
<Container>
<Content {...args} />
</Container>
),
parameters: {
docs: {
canvas: {
sourceState: "shown",
},
},
},
}
1 change: 1 addition & 0 deletions packages/components/src/Container/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Container"
12 changes: 12 additions & 0 deletions packages/components/src/Content/Content.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import "~@kaizen/design-tokens/sass/layout";
@import "./variables";

.content {
max-width: $layout-content-max-width;
margin: 0 $layout-content-side-margin;
width: 100%;

@media (max-width: calc(#{$layout-breakpoints-large} - 1px)) {
margin: 0 $content-margin-width-on-medium-and-small;
}
}
52 changes: 52 additions & 0 deletions packages/components/src/Content/Content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { HTMLAttributes } from "react"
import classnames from "classnames"
import { OverrideClassName } from "~types/OverrideClassName"
import styles from "./Content.module.scss"

export type ContentProps = {
children?: React.ReactNode
/**
* Not recommended. A short-circuit for dynamically overriding layout in a pinch
*/
style?: Pick<
React.CSSProperties,
| "bottom"
| "left"
| "margin"
| "marginBottom"
| "marginLeft"
| "marginRight"
| "marginTop"
| "padding"
| "paddingBottom"
| "paddingLeft"
| "paddingRight"
| "paddingTop"
| "position"
| "right"
| "top"
| "transform"
| "transformBox"
| "transformOrigin"
| "transformStyle"
>
} & OverrideClassName<HTMLAttributes<HTMLDivElement>>

/**
* {@link https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3086156812/Layout Guidance} |
* {@link https://cultureamp.design/?path=/docs/components-content--docs Storybook}
*/
export const Content = React.forwardRef<HTMLDivElement, ContentProps>(
({ children, style, classNameOverride, ...restProps }, ref) => (
<div
ref={ref}
className={classnames(styles.content, classNameOverride)}
style={style}
{...restProps}
>
{children}
</div>
)
)

Content.displayName = "Content"
31 changes: 31 additions & 0 deletions packages/components/src/Content/_docs/Content.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Canvas, Meta } from "@storybook/blocks"
import { ResourceLinks, KaioNotification, Installation } from "~storybook/components"
import { LinkTo } from "~storybook/components/LinkTo"
import * as ContentStories from "./Content.stories"

<Meta of={ContentStories} />

# Content

<ResourceLinks
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Content"
designGuidelines="https://cultureamp.atlassian.net/wiki/spaces/DesignSystem/pages/3086156812/Layout"
className="!mb-8"
/>

<KaioNotification />

<Installation
installCommand="yarn add @kaizen/components"
importStatement='import { Content } from "@kaizen/components"'
/>

## Overview

Wraps your content at a **page level** in the standard minimum width and margins.

<Canvas of={ContentStories.Playground} />

## Use Case
Usually wrapped in a <LinkTo pageId="components-container">Container</LinkTo>
<Canvas of={ContentStories.Example} />
63 changes: 63 additions & 0 deletions packages/components/src/Content/_docs/Content.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import React from "react"
import { Meta, StoryObj } from "@storybook/react"
import { Container } from "~components/Container"
import { Text } from "~components/Text"
import { Content } from "../index"

const meta = {
title: "Pages/Content",
component: Content,
args: {
children: (
<>
<Text variant="body">
Bacon ipsum dolor amet andouille buffalo beef boudin kielbasa
drumstick fatback cow tongue ground round chicken. Jowl cow short
ribs, ham tongue turducken spare ribs pig drumstick chuck meatball.
Buffalo turducken pancetta tail salami chicken. Bresaola venison
pastrami beef.
</Text>
<Text variant="body">
Porchetta shankle ribeye, ground round beef filet mignon fatback
chislic boudin. Boudin burgdoggen spare ribs, meatloaf pastrami pork
loin meatball short ribs tenderloin ribeye cupim venison short loin
pork chop tongue. Andouille landjaeger bacon, picanha filet mignon
short ribs hamburger shank shoulder porchetta. Pork chop ground round
tenderloin, biltong kevin corned beef chuck frankfurter spare ribs
pork meatball pastrami fatback. Strip steak beef ribs pork loin kevin,
biltong fatback tongue salami brisket capicola flank tenderloin.
</Text>
</>
),
},
} satisfies Meta<typeof Content>

export default meta

type Story = StoryObj<typeof meta>

export const Playground: Story = {
parameters: {
docs: {
canvas: {
sourceState: "shown",
},
},
},
}

export const Example: Story = {
render: args => (
<Container>
<Content {...args} />
</Container>
),
parameters: {
chromatic: { disable: false },
docs: {
canvas: {
sourceState: "shown",
},
},
},
}
3 changes: 3 additions & 0 deletions packages/components/src/Content/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This replicates the layout max-width logic in
// draft-packages/title-block-zen/KaizenDraft/TitleBlockZen/TitleBlockZen.scss
$content-margin-width-on-medium-and-small: 12px;
1 change: 1 addition & 0 deletions packages/components/src/Content/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Content"
32 changes: 32 additions & 0 deletions packages/components/src/Skirt/Skirt.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@import "~@kaizen/design-tokens/sass/color";

$dt-color-background-color-default: $color-purple-600;
$dt-color-background-color-education: $color-blue-100;

.container {
position: relative;
}

// Actual height is determined in JavaScript
.underlay {
box-sizing: content-box;
position: absolute;
z-index: 1;
top: 0;
left: 0;
right: 0;
height: 100%;
}

.defaultVariant {
background-color: $dt-color-background-color-default;
}

.educationVariant {
background-color: $dt-color-background-color-education;
}

.content {
position: relative;
z-index: 2;
}
Loading