Skip to content

Commit

Permalink
Feature/#81 커리큘럼 구현 (#96)
Browse files Browse the repository at this point in the history
* design: 작물 이미지 추가

#81

* feat: mocks data추가

#81

* feat: 커리큘럼 카드 구현

#81
  • Loading branch information
pipisebastian authored Feb 22, 2024
1 parent c93a580 commit 9b24050
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 0 deletions.
Binary file added public/images/curriculumCrops/carrot_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions src/components/CurriculumCard/CurriculumItem/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client';

import { Box, Checkbox, Flex, Text } from '@chakra-ui/react';
import { useState } from 'react';

import { CurriculumItemProps } from '../types';

const CurriculumItem = ({ id, name, itemOrder, isCompleted }: CurriculumItemProps) => {
const [checked, setChecked] = useState(isCompleted);

const handleCheckboxChange = () => {
setChecked(!checked);
};

return (
<Flex key={id.toString()} align="center" gap="4" px="4">
<Text color={checked ? 'orange' : 'orange_light'} fontSize="xl" fontWeight="bold">
{itemOrder.toString().padStart(2, '0')}
</Text>

<Box w="100%" px="3" py="1.5" color="white" fontSize="lg" bg={checked ? 'orange' : 'orange_light'} rounded="3xl">
<Text pr="10" fontSize="xl">
{name}
</Text>
</Box>
<Checkbox
borderColor={checked ? 'orange' : 'orange_light'}
bgColor="white"
colorScheme="white"
defaultChecked={checked}
iconColor="orange"
onChange={handleCheckboxChange}
size="lg"
/>
</Flex>
);
};

export default CurriculumItem;
47 changes: 47 additions & 0 deletions src/components/CurriculumCard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Flex, Image, Card } from '@chakra-ui/react';

import CurriculumCardData from '@/mocks/curriculum';

import CurriculumItem from './CurriculumItem';

const CurriculumCard = () => {
return (
<Flex h="300px">
<Image
w="300px"
borderTopRightRadius="0"
borderTopLeftRadius="2xl"
borderBottomLeftRadius="2xl"
borderBottomRightRadius="0"
alt="curriculum card"
src="/images/curriculumCrops/carrot_5.png"
/>
<Card
direction="row"
w="70%"
py="4"
pr="1"
borderTopRightRadius="2xl"
borderTopLeftRadius="0"
borderBottomLeftRadius="0"
borderBottomRightRadius="2xl"
>
<Flex direction="column" gap="3" overflowY="auto" w="100%">
{CurriculumCardData.map((data) => {
return (
<CurriculumItem
key={data.id}
id={data.id}
name={data.name}
itemOrder={data.itemOrder}
isCompleted={data.isCompleted}
/>
);
})}
</Flex>
</Card>
</Flex>
);
};

export default CurriculumCard;
6 changes: 6 additions & 0 deletions src/components/CurriculumCard/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface CurriculumItemProps {
id: number;
name: string;
itemOrder: number;
isCompleted: boolean;
}
42 changes: 42 additions & 0 deletions src/mocks/curriculum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { CurriculumItemProps } from '@/components/CurriculumCard/types';

const CurriculumCardData: CurriculumItemProps[] = [
{
id: 1,
name: '커리큘럼1',
itemOrder: 1,
isCompleted: true,
},
{
id: 2,
name: '커리큘럼2',
itemOrder: 2,
isCompleted: false,
},
{
id: 3,
name: '커리큘럼3',
itemOrder: 3,
isCompleted: true,
},
{
id: 4,
name: '커리큘럼4',
itemOrder: 4,
isCompleted: false,
},
{
id: 5,
name: '커리큘럼5',
itemOrder: 5,
isCompleted: false,
},
{
id: 6,
name: '커리큘럼6',
itemOrder: 6,
isCompleted: true,
},
];

export default CurriculumCardData;

0 comments on commit 9b24050

Please sign in to comment.