-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KDS-1610 Add new Tag component to KAIO (#3851)
* Add new Tag component to KAIO * Use Icon instead of svg * Use TagIcon in stories * Lint fix * Fix KAIO-staging name * Remove FC * Remove button dep * Remove placeholder * Split RTL stories and lint fix --------- Co-authored-by: jakepitman <jakeseanp@gmail.com>
- Loading branch information
1 parent
eff0c76
commit 00f0d53
Showing
5 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@kaizen/components": minor | ||
--- | ||
|
||
- Added `Tag` component and stories to KAIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { ReactNode, HTMLAttributes } from "react" | ||
import classNames from "classnames" | ||
import { OverrideClassName } from "~types/OverrideClassName" | ||
|
||
export type TagColors = | ||
| "gray" | ||
| "blue" | ||
| "green" | ||
| "yellow" | ||
| "orange" | ||
| "red" | ||
| "purple" | ||
|
||
export interface TagProps | ||
extends OverrideClassName<HTMLAttributes<HTMLSpanElement>> { | ||
children: ReactNode | ||
color?: TagColors | ||
Icon?: React.ReactElement | ||
} | ||
|
||
export const Tag = ({ | ||
children, | ||
classNameOverride, | ||
Icon, | ||
color = "gray", | ||
}: TagProps): JSX.Element => ( | ||
<span | ||
className={classNames( | ||
"inline-flex items-center px-8 py-[5px] gap-4 rounded-[28px] font-family-paragraph text-paragraph-sm font-weight-paragraph leading-paragraph-sm whitespace-nowrap", | ||
{ | ||
["bg-gray-200 text-purple-800"]: color === "gray", | ||
["bg-blue-100 text-blue-700"]: color === "blue", | ||
["bg-green-100 text-green-700"]: color === "green", | ||
["bg-yellow-100 text-yellow-700"]: color === "yellow", | ||
["bg-orange-100 text-orange-700"]: color === "orange", | ||
["bg-red-100 text-red-700"]: color === "red", | ||
["bg-purple-100 text-purple-700"]: color === "purple", | ||
}, | ||
classNameOverride | ||
)} | ||
> | ||
{Icon && ( | ||
<span | ||
className={classNames("inline-flex -my-[1px]", { | ||
["text-blue-500"]: color === "blue", | ||
["text-green-500"]: color === "green", | ||
["text-yellow-500"]: color === "yellow", | ||
["text-orange-500"]: color === "orange", | ||
["text-red-500"]: color === "red", | ||
["text-purple-500"]: color === "purple", | ||
})} | ||
> | ||
{Icon} | ||
</span> | ||
)} | ||
{children} | ||
</span> | ||
) | ||
|
||
Tag.displayName = "Tag" |
94 changes: 94 additions & 0 deletions
94
packages/components/src/__future__/Tag/_docs/Tag.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from "react" | ||
import { Meta, StoryFn } from "@storybook/react" | ||
import { TagIcon } from "~components/Icons" | ||
import { ComponentDocsTemplate } from "~storybook/components/DocsContainer" | ||
import { StickerSheet } from "~storybook/components/StickerSheet" | ||
import { Tag } from ".." | ||
|
||
export default { | ||
tags: ["autodocs"], | ||
title: "KAIO-staging/Tag", | ||
component: Tag, | ||
parameters: { | ||
docs: { | ||
container: ComponentDocsTemplate, | ||
}, | ||
isInKaio: true, | ||
installation: [ | ||
"yarn add @kaizen/components", | ||
"import { Tag } from `@kaizen/components/future`", | ||
], | ||
resourceLinks: { | ||
sourceCode: | ||
"https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/__future__/Tag", | ||
figma: | ||
"https://www.figma.com/file/hANEprZKom5Br1IBXhE8mr/%F0%9F%A7%AA-Kaizen-Labs?type=design&node-id=28588-183332&mode=design&t=VHZDCTJUpaon8PXg-0", | ||
}, | ||
}, | ||
} satisfies Meta<typeof Tag> | ||
|
||
export const Playground: StoryFn<typeof Tag> = args => ( | ||
<Tag {...args}>My tag</Tag> | ||
) | ||
|
||
type ListProps = { | ||
children: React.ReactNode | ||
} | ||
const List = ({ children }: ListProps): JSX.Element => ( | ||
<div className="flex flex-col gap-12 items-start">{children}</div> | ||
) | ||
|
||
const StickerSheetTemplate: StoryFn = () => ( | ||
<StickerSheet heading="Tag"> | ||
<StickerSheet.Header headings={["Label Only", "Icon"]} /> | ||
<StickerSheet.Body> | ||
<StickerSheet.Row> | ||
<List> | ||
<Tag>Gray</Tag> | ||
<Tag color="blue">Blue</Tag> | ||
<Tag color="green">Green</Tag> | ||
<Tag color="yellow">Yellow</Tag> | ||
<Tag color="orange">Orange</Tag> | ||
<Tag color="red">Red</Tag> | ||
<Tag color="purple">Purple</Tag> | ||
</List> | ||
<List> | ||
<Tag Icon={<TagIcon role="presentation" />}>Gray</Tag> | ||
<Tag color="blue" Icon={<TagIcon role="presentation" />}> | ||
Blue | ||
</Tag> | ||
<Tag color="green" Icon={<TagIcon role="presentation" />}> | ||
Green | ||
</Tag> | ||
<Tag color="yellow" Icon={<TagIcon role="presentation" />}> | ||
Yellow | ||
</Tag> | ||
<Tag color="orange" Icon={<TagIcon role="presentation" />}> | ||
Orange | ||
</Tag> | ||
<Tag color="red" Icon={<TagIcon role="presentation" />}> | ||
Red | ||
</Tag> | ||
<Tag color="purple" Icon={<TagIcon role="presentation" />}> | ||
Purple | ||
</Tag> | ||
</List> | ||
</StickerSheet.Row> | ||
</StickerSheet.Body> | ||
</StickerSheet> | ||
) | ||
|
||
export const StickerSheetDefault = StickerSheetTemplate.bind({}) | ||
StickerSheetDefault.storyName = "Sticker Sheet (Default)" | ||
StickerSheetDefault.parameters = { | ||
chromatic: { disable: false }, | ||
controls: { disable: true }, | ||
} | ||
|
||
export const StickerSheetRTL = StickerSheetTemplate.bind({}) | ||
StickerSheetRTL.storyName = "Sticker Sheet (RTL)" | ||
StickerSheetRTL.parameters = { | ||
chromatic: { disable: false }, | ||
controls: { disable: true }, | ||
textDirection: "rtl", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Tag" |