style: implement tag size property

This commit is contained in:
jinhojang6 2023-04-05 02:07:05 +09:00 committed by jeangovil
parent a1b4cfcd91
commit dc277c503e
4 changed files with 32 additions and 4 deletions

View File

@ -4,4 +4,7 @@ export const tagClasses = {
outlined: `lsd-tag--outlined`,
filled: `lsd-tag--filled`,
disabled: 'lsd-tag--disabled',
small: 'lsd-badge--small',
large: 'lsd-badge--large',
}

View File

@ -18,6 +18,13 @@ export default {
value: ['left', 'right', 'none'],
},
},
size: {
type: {
name: 'enum',
value: ['large', 'small'],
},
defaultValue: 'large',
},
disabled: {
type: {
name: 'boolean',
@ -36,4 +43,5 @@ Root.args = {
label: 'Tag',
iconDirection: 'left',
disabled: false,
size: 'large',
}

View File

@ -4,14 +4,11 @@ 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));
@ -22,6 +19,18 @@ export const TagStyles = css`
}
}
.${tagClasses.large} {
padding: 4px 12px;
gap: 12px;
height: 28px;
}
.${tagClasses.small} {
padding: 4px 8px;
gap: 8px;
height: 24px;
}
.${tagClasses.filled} {
background-color: rgb(var(--lsd-icon-primary));
color: rgb(var(--lsd-text-secondary));

View File

@ -9,6 +9,7 @@ export type TagProps = React.HTMLAttributes<HTMLDivElement> & {
icon?: React.ReactNode
iconDirection?: 'left' | 'right'
disabled?: boolean
size?: 'large' | 'small'
}
export const Tag: React.FC<TagProps> & {
@ -20,12 +21,18 @@ export const Tag: React.FC<TagProps> & {
icon,
iconDirection = 'left',
children,
size = 'large',
...props
}) => {
const renderItems = () => (
<>
{iconDirection === 'left' && icon}
<Typography className={tagClasses[variant]}>{label}</Typography>
<Typography
variant={size === 'small' ? 'label2' : 'label1'}
className={tagClasses[variant]}
>
{label}
</Typography>
{iconDirection === 'right' && icon}
</>
)
@ -39,6 +46,7 @@ export const Tag: React.FC<TagProps> & {
tagClasses.root,
tagClasses[variant],
disabled && tagClasses.disabled,
tagClasses[size],
)}
>
{renderItems()}