Skip to content

Commit

Permalink
[#20] 아이디어 유형 선택 그룹 컴포넌트
Browse files Browse the repository at this point in the history
  • Loading branch information
03hoho03 committed May 12, 2024
1 parent 1a516d6 commit d836ddd
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/components/IdeaTypeGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use client'

import React from 'react'
import { ToggleGroupItem, ToggleGroupRoot } from './common/ToggleGroup'
import { typeDatas } from '@/constants/idea'
import styled from 'styled-components'
import { theme } from '@/styles/theme'
import { useAtom } from 'jotai'
import { selectedIdeaTypeAtom } from '@/store/atoms/idea'

const StyledToggleGroupRoot = styled(ToggleGroupRoot)`
display: grid;
grid-template-columns: repeat(5, 60px);
row-gap: 4px;
column-gap: 4px;
justify-content: center;
`
const StyledToggleGroupItem = styled(ToggleGroupItem)`
/* 기본 스타일 */
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 60px;
height: 24px;
font-size: 0.8125rem;
font-weight: ${theme.fontWeight.bold};
color: #767676;
background-color: ${theme.color.white};
border: 1px solid ${theme.color.grey500};
border-radius: 12px;
cursor: pointer;
/* 선택 시 스타일 */
&[data-state='on'] {
background-color: ${theme.color.purple700};
color: ${theme.color.white};
border: none;
}
`

/**
*
* @returns
*/
const IdeaTypeGroup = () => {
const [value, setValue] = useAtom(selectedIdeaTypeAtom)

return (
<StyledToggleGroupRoot
type="single"
value={value}
onValueChange={(value) => {
if (value) setValue(value)
}}
>
{typeDatas.map((content, idx) => (
<StyledToggleGroupItem key={`${content}-${idx}`} value={content}>
{content}
</StyledToggleGroupItem>
))}
</StyledToggleGroupRoot>
)
}

export default IdeaTypeGroup

0 comments on commit d836ddd

Please sign in to comment.