Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chip 컴포넌트 구현 #23

Merged
merged 3 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
@tailwind utilities;

@layer base {
@font-face {
font-family: 'Pretendard';
src: url('https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css');
}

:root {
--bgColor: rgb(255, 255, 255);
--slate9: rgb(16, 23, 41);
Expand Down
6 changes: 1 addition & 5 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { Providers, ThemeButton } from '@/components'
import { cls } from '@/utils'
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import './globals.css'

const inter = Inter({ subsets: ['latin'] })

export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
Expand All @@ -18,7 +14,7 @@ export default function RootLayout({
}) {
return (
<html lang="ko">
<body className={cls('bg-bgColor', inter.className)}>
<body className="bg-bgColor">
<Providers>
<div className="mx-auto w-full max-w-[500px]">{children}</div>
<ThemeButton />
Expand Down
31 changes: 31 additions & 0 deletions src/components/common/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { cls } from '@/utils'
import { COLORS } from './constants'

export type ChipColors =
| 'emerald'
| 'red'
| 'yellow'
| 'blue'
| 'indigo'
| 'purple'
| 'pink'
| 'gray'

export interface ChipProps {
label: string
color?: ChipColors
}

const Chip = ({ label, color = 'emerald' }: ChipProps) => {
return (
<div
className={cls(
'inline-flex rounded-xl px-2.5 py-1 text-center text-xs font-medium',
COLORS[color],
)}>
{label}
</div>
)
}

export default Chip
10 changes: 10 additions & 0 deletions src/components/common/Chip/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const COLORS = {
emerald: 'bg-emerald-200 text-emerald-900',
red: 'bg-red-200 text-red-900',
yellow: 'bg-yellow-200 text-yellow-900',
blue: 'bg-blue-200 text-blue-900',
indigo: 'bg-indigo-200 text-indigo-900',
purple: 'bg-purple-200 text-purple-900',
pink: 'bg-pink-200 text-pink-900',
gray: 'bg-gray-200 text-gray-900',
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as Providers } from './Providers/providers'
export { default as ThemeButton } from './ThemeButton/themeButton'
export { default as Avatar } from './common/Avatar/Avatar'
export { default as AvatarGroup } from './common/AvatarGroup/AvatarGroup'
export { default as Chip } from './common/Chip/Chip'
4 changes: 4 additions & 0 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Config } from 'tailwindcss'
import { fontFamily } from 'tailwindcss/defaultTheme'

const config: Config = {
content: [
Expand Down Expand Up @@ -45,6 +46,9 @@ const config: Config = {
'gradient-conic':
'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',
},
fontFamily: {
sans: ['"Pretendard"', ...fontFamily.sans],
},
},
},
plugins: [],
Expand Down