diff --git a/src/features/preview/Container.tsx b/src/features/preview/Container.tsx index 015862a..5e02f58 100644 --- a/src/features/preview/Container.tsx +++ b/src/features/preview/Container.tsx @@ -9,10 +9,12 @@ import BottomText from './components/BottomText'; import LabelSender from './components/LabelSender'; import ChooseType from './components/ChooseType'; import PreviewImage from './components/PreviewImage'; +import usePreview from './hooks/usePreview'; const Container = () => { const [, setTitle] = useAtom(titleAtom); const [, setBottomBtn] = useAtom(bottomBtnAtom); + const { curNum, setCurNum } = usePreview(); useLayoutEffect(() => { setTitle({ title: 'CardMe Preview', back: true }); setBottomBtn({ text: 'Modification' }); @@ -26,8 +28,8 @@ const Container = () => { return (
- - + + .
); diff --git a/src/features/preview/components/BottomText.tsx b/src/features/preview/components/BottomText.tsx index 465178b..1f848ea 100644 --- a/src/features/preview/components/BottomText.tsx +++ b/src/features/preview/components/BottomText.tsx @@ -1,10 +1,44 @@ -const BottomText = () => { +import { FunctionComponent } from 'react'; + +type BottomTextType = { + curNum: number; +}; + +const BottomText: FunctionComponent = ({ curNum }) => { + const titleList = [ + 'My Profile', + 'Active Mood', + 'Creating a Schedule', + 'Cancellation', + 'Schedule Notification', + ]; + const subList = [ + 'My basic information is displayed.', + 'Express your day in various ways with text and stickers!', + 'Sends an alert to the ID Card when you create a schedule.', + 'Send a notification to the ID Card when the schedule is canceled.', + 'Sends a notification to the ID Card when the schedule is imminent.', + ]; return (
-
My Profile
-
- My basic information is displayed. -
+ {titleList.map((item, idx) => { + if (idx === curNum) { + return ( +
+ {item} +
+ ); + } + })} + {subList.map((item, idx) => { + if (idx === curNum) { + return ( +
+ {item} +
+ ); + } + })}
); }; diff --git a/src/features/preview/components/PreviewImage.tsx b/src/features/preview/components/PreviewImage.tsx index 8fe9318..72c7aa1 100644 --- a/src/features/preview/components/PreviewImage.tsx +++ b/src/features/preview/components/PreviewImage.tsx @@ -1,6 +1,6 @@ import 'react-responsive-carousel/lib/styles/carousel.min.css'; import { Carousel } from 'react-responsive-carousel'; -import { useState } from 'react'; +import { Dispatch, FunctionComponent } from 'react'; import idCardBasic from '/svg/idcard_basic.svg'; import idCardMude from '/svg/idcard_mude.svg'; @@ -8,8 +8,14 @@ import meetingAdd from '/svg/meeting_add.svg'; import meetingCancel from '/svg/meeting_cancel.svg'; import meeting30 from '/svg/meeting_30.svg'; -const PreviewImage = () => { - const [curNum, setCurNum] = useState(0); +type PreviewImageType = { + curNum: number; + setCurNum: Dispatch; +}; +const PreviewImage: FunctionComponent = ({ + curNum, + setCurNum, +}) => { const imageList = [ idCardBasic, idCardMude, @@ -17,7 +23,6 @@ const PreviewImage = () => { meetingCancel, meeting30, ]; - console.log(curNum); return ( <>
@@ -29,7 +34,8 @@ const PreviewImage = () => { showIndicators={false} autoPlay infiniteLoop - onChange={(index) => { + selectedItem={curNum} + onChange={(index, _) => { setCurNum(index); }} > @@ -51,6 +57,9 @@ const PreviewImage = () => { ? 'preview-carousel-circle-black' : 'preview-carousel-circle-gray' } + onClick={() => { + setCurNum(idx); + }} >
); })} diff --git a/src/features/preview/hooks/usePreview.ts b/src/features/preview/hooks/usePreview.ts new file mode 100644 index 0000000..8d7ba1c --- /dev/null +++ b/src/features/preview/hooks/usePreview.ts @@ -0,0 +1,12 @@ +import { useState } from 'react'; + +const usePreview = () => { + const [curNum, setCurNum] = useState(0); + + return { + curNum, + setCurNum, + }; +}; + +export default usePreview;