diff --git a/src/elements/Tag/index.tsx b/src/elements/Tag/index.tsx index c8a99cbb5..6beda628d 100644 --- a/src/elements/Tag/index.tsx +++ b/src/elements/Tag/index.tsx @@ -11,12 +11,14 @@ import type { IconProps } from '../../types' export type TagProps = HTMLAttributes & { Icon?: FunctionComponent | undefined accent?: Accent | undefined + backgroundColor?: string | undefined bullet?: TagBullet | undefined bulletColor?: string | undefined isLight?: boolean | undefined } export function Tag({ accent, + backgroundColor, bullet, bulletColor, children, @@ -41,8 +43,9 @@ export function Tag({ return ( <> - {Icon && } - {bullet === TagBullet.DISK && } + {/* Refactor when bullet will be a real icon */} + {Icon && !bullet && } + {bullet === TagBullet.DISK && !Icon && } {children} @@ -70,16 +73,24 @@ export function Tag({ return default: - return + return } } const Box = styled.span<{ + $backgroundColor?: string | undefined $color?: string | undefined $isLight: boolean }>` - align-items: center; - background-color: ${p => (p.$isLight ? p.theme.color.white : 'transparent')}; + align-items: end; + align-self: flex-start; + background-color: ${p => { + if (p.$backgroundColor) { + return p.$backgroundColor + } + + return p.$isLight ? p.theme.color.white : 'transparent' + }}; border-radius: 11px; color: ${p => (p.$color ? p.$color : p.theme.color.gunMetal)}; display: inline-flex; @@ -111,7 +122,7 @@ export const PrimaryTag = styled(Box)<{ export const SecondaryTag = styled(Box)<{ $isLight: boolean }>` - background-color: ${p => (p.$isLight ? '#f6d012' : '#f6d012')}; + background-color: ${p => (p.$isLight ? p.theme.color.goldenPoppy : p.theme.color.goldenPoppy)}; color: ${p => p.theme.color.gunMetal}; ` diff --git a/stories/elements/Tag.stories.tsx b/stories/elements/Tag.stories.tsx index ae672e817..7b2f8ca16 100644 --- a/stories/elements/Tag.stories.tsx +++ b/stories/elements/Tag.stories.tsx @@ -1,6 +1,8 @@ +import styled from 'styled-components' + import { generateStoryDecorator } from '../../.storybook/components/StoryDecorator' import { getEnumValuesWithUndefined, getUndefinedPropsFromUndefinedStringProps } from '../../.storybook/utils' -import { Accent, Tag, TagBullet } from '../../src' +import { Accent, Icon, THEME, Tag, TagBullet } from '../../src' import type { TagProps } from '../../src' import type { Meta } from '@storybook/react' @@ -25,6 +27,12 @@ const meta: Meta = { }, bulletColor: { control: 'color' + }, + color: { + control: 'color' + }, + backgroundColor: { + control: 'color' } }, @@ -43,8 +51,33 @@ export function _Tag(props: TagProps) { const normalizedProps = getUndefinedPropsFromUndefinedStringProps(props) return ( - <> - - + + + A primary tag + + + A secondary tag + + + A tertiary tag + + + A tag with a green bullet + + + A tag with custom colors and icon + + ) } + +const TagsContainer = styled.div` + display: flex; + flex-direction: column; + gap: 32px; +`