diff --git a/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx b/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx index 1597347..e3245dc 100644 --- a/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx +++ b/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx @@ -14,6 +14,7 @@ import { ListBoxStyles } from '../ListBox/ListBox.styles' import { QuoteStyles } from '../Quote/Quote.styles' import { TabItemStyles } from '../TabItem/TabItem.styles' import { TabsStyles } from '../Tabs/Tabs.styles' +import { TagStyles } from '../Tag/Tag.styles' import { TextFieldStyles } from '../TextField/TextField.styles' import { defaultThemes, Theme, withTheme } from '../Theme' import { TypographyStyles } from '../Typography/Typography.styles' @@ -31,6 +32,7 @@ const componentStyles: Array | SerializedStyles> = IconTagStyles, BreadcrumbStyles, BreadcrumbItemStyles, + TagStyles, TextFieldStyles, AutocompleteStyles, QuoteStyles, diff --git a/packages/lsd-react/src/components/Tag/Tag.classes.ts b/packages/lsd-react/src/components/Tag/Tag.classes.ts new file mode 100644 index 0000000..584debb --- /dev/null +++ b/packages/lsd-react/src/components/Tag/Tag.classes.ts @@ -0,0 +1,7 @@ +export const tagClasses = { + root: `lsd-tag`, + + outlined: `lsd-tag--outlined`, + filled: `lsd-tag--filled`, + disabled: 'lsd-tag--disabled', +} diff --git a/packages/lsd-react/src/components/Tag/Tag.stories.tsx b/packages/lsd-react/src/components/Tag/Tag.stories.tsx new file mode 100644 index 0000000..1ea41b0 --- /dev/null +++ b/packages/lsd-react/src/components/Tag/Tag.stories.tsx @@ -0,0 +1,39 @@ +import { Meta, Story } from '@storybook/react' +import { FolderIcon } from '../Icons' +import { Tag, TagProps } from './Tag' + +export default { + title: 'Tag', + component: Tag, + argTypes: { + variant: { + type: { + name: 'enum', + value: ['outlined', 'filled'], + }, + }, + iconDirection: { + type: { + name: 'enum', + value: ['left', 'right', 'none'], + }, + }, + disabled: { + type: { + name: 'boolean', + value: [true, false], + }, + }, + }, +} as Meta + +export const Root: Story = (args) => ( + } /> +) + +Root.args = { + variant: 'outlined', + label: 'Tag', + iconDirection: 'left', + disabled: false, +} diff --git a/packages/lsd-react/src/components/Tag/Tag.styles.ts b/packages/lsd-react/src/components/Tag/Tag.styles.ts new file mode 100644 index 0000000..9683b60 --- /dev/null +++ b/packages/lsd-react/src/components/Tag/Tag.styles.ts @@ -0,0 +1,42 @@ +import { css } from '@emotion/react' +import { tagClasses } from './Tag.classes' + +export const TagStyles = css` + .${tagClasses.root} { + width: fit-content; + height: 28px; + padding: 4px 12px; + + display: flex; + flex-direction: row; + align-items: center; + justify-content: center; + gap: 12px; + + border: 1px solid rgb(var(--lsd-icon-primary)); + + &:hover, + &:focus { + text-decoration: underline; + cursor: pointer; + } + } + + .${tagClasses.filled} { + background-color: rgb(var(--lsd-icon-primary)); + color: rgb(var(--lsd-text-secondary)); + svg { + --lsd-icon-primary: var(--lsd-icon-secondary); + } + } + + .${tagClasses.outlined} { + color: rgb(var(--lsd-text-primary)); + } + + .${tagClasses.disabled} { + opacity: 0.3; + cursor: initial; + pointer-events: none; + } +` diff --git a/packages/lsd-react/src/components/Tag/Tag.tsx b/packages/lsd-react/src/components/Tag/Tag.tsx new file mode 100644 index 0000000..cb38e43 --- /dev/null +++ b/packages/lsd-react/src/components/Tag/Tag.tsx @@ -0,0 +1,49 @@ +import clsx from 'clsx' +import React from 'react' +import { Typography } from '../Typography' +import { tagClasses } from './Tag.classes' + +export type TagProps = React.HTMLAttributes & { + variant?: 'outlined' | 'filled' + label: string + icon?: React.ReactNode + iconDirection?: 'left' | 'right' + disabled?: boolean +} + +export const Tag: React.FC & { + classes: typeof tagClasses +} = ({ + label, + variant = 'outlined', + disabled = 'false', + icon, + iconDirection = 'left', + children, + ...props +}) => { + const renderItems = () => ( + <> + {iconDirection === 'left' && icon} + {label} + {iconDirection === 'right' && icon} + + ) + + return ( +
+ {renderItems()} +
+ ) +} + +Tag.classes = tagClasses diff --git a/packages/lsd-react/src/components/Tag/index.ts b/packages/lsd-react/src/components/Tag/index.ts new file mode 100644 index 0000000..fd1a1e7 --- /dev/null +++ b/packages/lsd-react/src/components/Tag/index.ts @@ -0,0 +1 @@ +export * from './Tag' diff --git a/packages/lsd-react/src/index.ts b/packages/lsd-react/src/index.ts index c947bbf..fdca6d3 100644 --- a/packages/lsd-react/src/index.ts +++ b/packages/lsd-react/src/index.ts @@ -12,4 +12,5 @@ export * from './components/ListBox' export * from './components/Quote' export * from './components/TabItem' export * from './components/Tabs' +export * from './components/Tag' export * from './components/Theme'