Skip to content

Commit

Permalink
[#9] 기존 props 삭제 및 size, theme style 추가, 기본 css 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
03hoho03 committed May 11, 2024
1 parent 1700440 commit f5f6d7e
Showing 1 changed file with 65 additions and 7 deletions.
72 changes: 65 additions & 7 deletions src/components/common/Dialog/Description.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,87 @@
'use client'

import { theme } from '@/styles/theme'
import * as DialogPrimitive from '@radix-ui/react-dialog'
import styled from 'styled-components'
import styled, { css } from 'styled-components'

interface DialogDescriptionSize {
[key: string]: {
fontSize: string
padding?: string
}
}
interface DialogDescriptionTheme {
[key: string]: {
color: string
backgroundColor?: string
bolderColor?: string
}
}

/**
* **size**: large, medium, small(default)
*
* **theme**: primary(default), color
*/
interface StyledDescriptionProps {
fontSize?: number
fontWeight?: 300 | 400 | 500 | 600 | 700 | 800
size: string
theme: string
}
interface DialogDescriptionProps
extends DialogPrimitive.DialogDescriptionProps,
StyledDescriptionProps {}

const DialogDescriptionSizes: DialogDescriptionSize = {
small: {
fontSize: '12px',
},
medium: {
fontSize: '14px',
},
large: {
fontSize: '16px',
},
}
const DialogDescriptionThemes: DialogDescriptionTheme = {
primary: {
color: theme.color.black,
},
red: {
color: theme.color.red,
},
}

const sizeStyles = css<StyledDescriptionProps>`
${({ size }) => css`
font-size: ${DialogDescriptionSizes[size].fontSize};
`}
`
const themeStyles = css<StyledDescriptionProps>`
${({ theme }) => css`
color: ${DialogDescriptionThemes[theme].color};
`}
`

const StyledDescription = styled(
DialogPrimitive.Description,
)<StyledDescriptionProps>`
/* 기본값 */
margin: 0;
color: black;
font-size: ${(props) => (props.fontSize ? `${props.fontSize}px` : '14px')};
font-weight: ${(props) => (props.fontWeight ? props.fontWeight : 400)};
line-height: 1.5;
padding: 0 20px;
line-height: 150%;
letter-spacing: -0.05em;
/* size */
${sizeStyles}
/* theme */
${themeStyles}
`

const DialogDescription = ({ children, ...props }: DialogDescriptionProps) => {
return <StyledDescription {...props}>{children}</StyledDescription>
}
DialogDescription.defaultProps = {
size: 'small',
theme: 'primary',
}

export default DialogDescription

0 comments on commit f5f6d7e

Please sign in to comment.