-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: 폴더 구조를 변경합니다. * feat: QuestionnaireCheckListSkeleton를 추가합니다.
- Loading branch information
Showing
20 changed files
with
297 additions
and
48 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
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
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
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,53 @@ | ||
import Svg, { Circle, Rect } from 'react-native-svg'; | ||
|
||
type Props = { | ||
activeColor: string; | ||
inActiveColor: string; | ||
isChecked: boolean; | ||
}; | ||
|
||
function RadioIcon({ activeColor, inActiveColor, isChecked }: Props) { | ||
if (isChecked) { | ||
return ( | ||
<Svg | ||
width='16' | ||
height='17' | ||
viewBox='0 0 16 17' | ||
fill='none'> | ||
<Circle | ||
cx='7.95894' | ||
cy='8.49752' | ||
r='7.29' | ||
stroke={activeColor} | ||
stroke-width='1.215' | ||
/> | ||
<Circle | ||
cx='7.95894' | ||
cy='8.49775' | ||
r='4.05' | ||
fill={activeColor} | ||
/> | ||
</Svg> | ||
); | ||
} else { | ||
return ( | ||
<Svg | ||
width='16' | ||
height='16' | ||
viewBox='0 0 16 16' | ||
fill='none'> | ||
<Rect | ||
x='0.668945' | ||
y='0.807617' | ||
width='14.58' | ||
height='14.58' | ||
rx='7.29' | ||
stroke={inActiveColor} | ||
stroke-width='1.215' | ||
/> | ||
</Svg> | ||
); | ||
} | ||
} | ||
|
||
export default RadioIcon; |
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
80 changes: 80 additions & 0 deletions
80
src/components/questionnaire/QuestionnaireCheckList/index.tsx
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,80 @@ | ||
import type { PropsWithChildren } from 'react'; | ||
import { useContext, useState } from 'react'; | ||
import { createContext } from 'react'; | ||
import { memo } from 'react'; | ||
|
||
import RadioIcon from '@/components/common/icon/radio-icon'; | ||
import Typography from '@/components/common/typography'; | ||
import { color } from '@/styles/theme'; | ||
import type { CategoryType } from '@/types/category'; | ||
|
||
import CategoryChip from '../category-chip'; | ||
import * as S from './style'; | ||
|
||
type ItemProps = { | ||
value: string | number; | ||
}; | ||
|
||
const ListContext = createContext<{ | ||
checkValue: string | null | number; | ||
setCheckValue: (newValue: string | null | number) => void; | ||
}>({ | ||
checkValue: null, | ||
setCheckValue: () => null, | ||
}); | ||
|
||
function Item({ children, value }: PropsWithChildren<ItemProps>) { | ||
const { checkValue, setCheckValue } = useContext(ListContext); | ||
const isChecked = checkValue === value; | ||
return ( | ||
<S.ItemContainer $isChecked={isChecked}> | ||
<S.ItemValue>{children}</S.ItemValue> | ||
<S.RadioButton onPress={() => setCheckValue(value)}> | ||
<RadioIcon | ||
activeColor={color.Primary.Normal} | ||
inActiveColor={color.Line.Normal} | ||
isChecked={isChecked} | ||
/> | ||
</S.RadioButton> | ||
</S.ItemContainer> | ||
); | ||
} | ||
|
||
type QuestionnaireCheckListProps = { | ||
title: string; | ||
category: CategoryType; | ||
initialCheckValue?: string | number; | ||
}; | ||
|
||
function CheckList({ | ||
title, | ||
category, | ||
initialCheckValue, | ||
children, | ||
}: PropsWithChildren<QuestionnaireCheckListProps>) { | ||
const [checkValue, setCheckValue] = useState<null | string | number>(() => | ||
initialCheckValue ? initialCheckValue : null | ||
); | ||
return ( | ||
<ListContext.Provider | ||
value={{ | ||
checkValue, | ||
setCheckValue, | ||
}}> | ||
<S.Container> | ||
<CategoryChip category={category} /> | ||
<Typography | ||
variant='Heading1' | ||
fontWeight='semiBold' | ||
color={color.Label.Normal}> | ||
{title} | ||
</Typography> | ||
<S.ListContainer>{children}</S.ListContainer> | ||
</S.Container> | ||
</ListContext.Provider> | ||
); | ||
} | ||
|
||
const QuestionnaireCheckList = Object.assign(CheckList, { Item: memo(Item) }); | ||
|
||
export default QuestionnaireCheckList; |
49 changes: 49 additions & 0 deletions
49
src/components/questionnaire/QuestionnaireCheckList/style.ts
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,49 @@ | ||
import styled, { css } from '@emotion/native'; | ||
import type { Theme } from '@emotion/react'; | ||
|
||
import { flexDirectionColumn, flexDirectionRowItemsCenter } from '@/styles/common'; | ||
|
||
export const Container = styled.View` | ||
${flexDirectionColumn}; | ||
gap: 20px; | ||
width: 272px; | ||
padding: 28px 16px; | ||
background: ${({ theme }) => theme.color.Background.Normal}; | ||
border-radius: 13px; | ||
`; | ||
|
||
const inActiveStyle = (theme: Theme) => css` | ||
background: ${theme.color.Background.Normal}; | ||
border: 1px solid ${theme.color.Line.Normal}; | ||
`; | ||
|
||
const activeStyle = (theme: Theme) => css` | ||
background: ${theme.color.Blue['95']}; | ||
border: 1px solid ${theme.color.Primary.Normal}; | ||
`; | ||
|
||
export const ItemContainer = styled.View<{ $isChecked: boolean }>` | ||
${flexDirectionRowItemsCenter}; | ||
${({ theme, $isChecked }) => ($isChecked ? activeStyle(theme) : inActiveStyle(theme))}; | ||
justify-content: space-between; | ||
padding: 13px 28px 13px 13px; | ||
border-radius: 7px; | ||
`; | ||
|
||
export const ListContainer = styled.View` | ||
${flexDirectionColumn}; | ||
gap: 8px; | ||
`; | ||
|
||
export const ItemValue = styled.View` | ||
${flexDirectionColumn}; | ||
`; | ||
|
||
export const RadioButton = styled.Pressable` | ||
${flexDirectionRowItemsCenter}; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
height: 100%; | ||
padding: 13px; | ||
`; |
26 changes: 26 additions & 0 deletions
26
...s/questionnaire/QuestionnaireCheckListSkeleton/QuestionnaireCheckListSkeleton.stories.tsx
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,26 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { View } from 'react-native'; | ||
|
||
import { color } from '@/styles/theme'; | ||
|
||
import QuestionnaireCheckListSkeleton from './'; | ||
|
||
const SkeletonMeta: Meta<typeof QuestionnaireCheckListSkeleton> = { | ||
title: 'questionnaire/QuestionnaireCheckListSkeleton', | ||
component: QuestionnaireCheckListSkeleton, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
}; | ||
|
||
export default SkeletonMeta; | ||
|
||
export const Primary: StoryObj<typeof QuestionnaireCheckListSkeleton> = { | ||
render: () => { | ||
return ( | ||
<View style={{ flex: 1, backgroundColor: color.Background.Alternative, padding: 10 }}> | ||
<QuestionnaireCheckListSkeleton /> | ||
</View> | ||
); | ||
}, | ||
}; |
44 changes: 44 additions & 0 deletions
44
src/components/questionnaire/QuestionnaireCheckListSkeleton/index.tsx
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,44 @@ | ||
import Skeleton from '@/components/common/skeleton'; | ||
import QuestionnaireCheckList from '@/components/questionnaire/QuestionnaireCheckList'; | ||
|
||
import * as S from './style'; | ||
|
||
function SkeletonItem() { | ||
return ( | ||
<S.SkeletonBox> | ||
<Skeleton | ||
variant='rounded' | ||
width='60%' | ||
height={14} | ||
/> | ||
<Skeleton | ||
variant='rounded' | ||
width='30%' | ||
height={14} | ||
/> | ||
</S.SkeletonBox> | ||
); | ||
} | ||
|
||
function QuestionnaireCheckListSkeleton() { | ||
return ( | ||
<QuestionnaireCheckList | ||
title='프로님은 회의 중 의견을 나눌때 어땠나요?' | ||
category='기술'> | ||
<QuestionnaireCheckList.Item value={0}> | ||
<SkeletonItem /> | ||
</QuestionnaireCheckList.Item> | ||
<QuestionnaireCheckList.Item value={1}> | ||
<SkeletonItem /> | ||
</QuestionnaireCheckList.Item> | ||
<QuestionnaireCheckList.Item value={2}> | ||
<SkeletonItem /> | ||
</QuestionnaireCheckList.Item> | ||
<QuestionnaireCheckList.Item value={3}> | ||
<SkeletonItem /> | ||
</QuestionnaireCheckList.Item> | ||
</QuestionnaireCheckList> | ||
); | ||
} | ||
|
||
export default QuestionnaireCheckListSkeleton; |
8 changes: 8 additions & 0 deletions
8
src/components/questionnaire/QuestionnaireCheckListSkeleton/style.ts
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,8 @@ | ||
import styled from '@emotion/native'; | ||
|
||
import { flexDirectionColumnCenter } from '@/styles/common'; | ||
|
||
export const SkeletonBox = styled.View` | ||
${flexDirectionColumnCenter}; | ||
gap: 4px; | ||
`; |
4 changes: 2 additions & 2 deletions
4
...on/category-chip/CategoryChip.stories.tsx → ...re/category-chip/CategoryChip.stories.tsx
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
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ents/common/category/Category.stories.tsx → ...estionnaire/category/Category.stories.tsx
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
File renamed without changes.
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
Oops, something went wrong.