-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67b2ee8
commit 1f9fe9e
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { Badge } from './Badge' | ||
|
||
const meta = { | ||
title: 'UI/Badge', | ||
component: Badge, | ||
tags: ['autodocs'], | ||
argTypes: {}, | ||
} satisfies Meta<typeof Badge> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Normal: Story = { | ||
args: { | ||
variant: 'gradation', | ||
size: 'sm', | ||
children: '거래성사', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as React from 'react' | ||
import { cva, type VariantProps } from 'class-variance-authority' | ||
import { cn } from '@/utils' | ||
|
||
const badgeVariants = cva( | ||
'inline-flex items-center rounded-full px-2 font-medium', | ||
{ | ||
variants: { | ||
variant: { | ||
primary: 'bg-primary-color text-white', | ||
secondary: 'bg-secondary-color text-white', | ||
gradation: 'bg-gradient-primary text-white', | ||
information: 'bg-background-secondary-color text-black', | ||
}, | ||
size: { | ||
sm: 'h-[18px] text-xs', | ||
lg: 'h-6 text-sm', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'information', | ||
size: 'sm', | ||
}, | ||
}, | ||
) | ||
|
||
export interface BadgeProps | ||
extends React.HTMLAttributes<HTMLDivElement>, | ||
VariantProps<typeof badgeVariants> {} | ||
|
||
const Badge = ({ className, variant, size, ...props }: BadgeProps) => { | ||
return ( | ||
<div | ||
className={cn(badgeVariants({ variant, size }), className)} | ||
{...props} | ||
/> | ||
) | ||
} | ||
|
||
Badge.displayName = 'Badge' | ||
|
||
export { Badge, badgeVariants } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Badge } from './Badge' | ||
|
||
export default Badge |