diff --git a/components/Common/Badge/index.module.scss b/components/Common/Badge/index.module.scss new file mode 100644 index 000000000000..a47525132874 --- /dev/null +++ b/components/Common/Badge/index.module.scss @@ -0,0 +1,63 @@ +.wrapper { + @apply border rounded-full flex items-center w-fit py-1 pl-1 pr-2.5 text-sm font-medium; + + .icon { + @apply w-4 h-4; + } + + .badge { + @apply rounded-full border px-2.5 py-0.5 mr-2 text-white; + } + + .message { + @apply mr-1; + } + + &.default { + @apply border-green-200 bg-green-100 dark:border-green-700 dark:bg-neutral-900; + + .icon { + @apply text-green-500 dark:text-green-300; + } + + .badge { + @apply border-green-200 dark:border-green-600 bg-green-600; + } + + .message { + @apply text-green-700 dark:text-green-300; + } + } + + &.error { + @apply border-danger-200 dark:border-danger-700 bg-danger-100 dark:bg-neutral-900; + + .icon { + @apply text-danger-500 dark:text-danger-300; + } + + .badge { + @apply border-danger-200 dark:border-danger-600 bg-danger-600; + } + + .message { + @apply text-danger-700 dark:text-danger-300; + } + } + + &.warning { + @apply border-warning-200 dark:border-warning-700 bg-warning-100 dark:bg-neutral-900; + + .icon { + @apply text-warning-500 dark:text-warning-300; + } + + .badge { + @apply border-warning-200 dark:border-warning-600 bg-warning-600; + } + + .message { + @apply text-warning-700 dark:text-warning-300; + } + } +} diff --git a/components/Common/Badge/index.stories.tsx b/components/Common/Badge/index.stories.tsx new file mode 100644 index 000000000000..25b819437ae6 --- /dev/null +++ b/components/Common/Badge/index.stories.tsx @@ -0,0 +1,34 @@ +import Badge from './'; +import type { Meta as MetaObj, StoryObj } from '@storybook/react'; + +type Story = StoryObj; +type Meta = MetaObj; + +export const Default: Story = { + args: { + href: '/', + children: 'OpenJS Foundation Certification 2023', + kind: 'default', + badgeText: 'New', + }, +}; + +export const Error: Story = { + args: { + href: '/', + children: 'OpenJS Foundation Certification 2023', + kind: 'error', + badgeText: 'New', + }, +}; + +export const Warning: Story = { + args: { + href: '/', + children: 'OpenJS Foundation Certification 2023', + kind: 'warning', + badgeText: 'New', + }, +}; + +export default { component: Badge } as Meta; diff --git a/components/Common/Badge/index.tsx b/components/Common/Badge/index.tsx new file mode 100644 index 000000000000..8c80e89fd3fb --- /dev/null +++ b/components/Common/Badge/index.tsx @@ -0,0 +1,26 @@ +import ArrowRightIcon from '@heroicons/react/24/solid/ArrowRightIcon'; +import LocalizedLink from '@/components/LocalizedLink'; +import type { ComponentProps, FC, PropsWithChildren } from 'react'; +import type Link from 'next/link'; + +import styles from './index.module.scss'; + +type BadgeProps = { + kind?: 'default' | 'warning' | 'error'; + badgeText?: string; +} & ComponentProps; + +const Badge: FC> = ({ + kind = 'default', + badgeText, + children, + ...args +}) => ( + + {badgeText && {badgeText}} + {children} + + +); + +export default Badge;