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`, outlined: `lsd-tag--outlined`,
filled: `lsd-tag--filled`, filled: `lsd-tag--filled`,
disabled: 'lsd-tag--disabled', disabled: 'lsd-tag--disabled',
small: 'lsd-badge--small',
large: 'lsd-badge--large',
} }

View File

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

View File

@ -4,14 +4,11 @@ import { tagClasses } from './Tag.classes'
export const TagStyles = css` export const TagStyles = css`
.${tagClasses.root} { .${tagClasses.root} {
width: fit-content; width: fit-content;
height: 28px;
padding: 4px 12px;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 12px;
border: 1px solid rgb(var(--lsd-icon-primary)); 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} { .${tagClasses.filled} {
background-color: rgb(var(--lsd-icon-primary)); background-color: rgb(var(--lsd-icon-primary));
color: rgb(var(--lsd-text-secondary)); color: rgb(var(--lsd-text-secondary));

View File

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