Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(preview): click move, set bottom text #20

Merged
merged 1 commit into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/features/preview/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -26,8 +28,8 @@ const Container = () => {
return (
<div className="preview-container">
<ChooseType />
<PreviewImage />
<BottomText />
<PreviewImage curNum={curNum} setCurNum={setCurNum} />
<BottomText curNum={curNum} />
<LabelSender>.</LabelSender>
</div>
);
Expand Down
44 changes: 39 additions & 5 deletions src/features/preview/components/BottomText.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
const BottomText = () => {
import { FunctionComponent } from 'react';

type BottomTextType = {
curNum: number;
};

const BottomText: FunctionComponent<BottomTextType> = ({ 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 (
<div className="preview-bottom-text-container">
<div className="preview-bottom-title-text">My Profile</div>
<div className="preview-bottom-sub-text">
My basic information is displayed.
</div>
{titleList.map((item, idx) => {
if (idx === curNum) {
return (
<div className="preview-bottom-title-text" key={idx}>
{item}
</div>
);
}
})}
{subList.map((item, idx) => {
if (idx === curNum) {
return (
<div className="preview-bottom-sub-text" key={idx}>
{item}
</div>
);
}
})}
</div>
);
};
Expand Down
19 changes: 14 additions & 5 deletions src/features/preview/components/PreviewImage.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
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';
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<number>(0);
type PreviewImageType = {
curNum: number;
setCurNum: Dispatch<number>;
};
const PreviewImage: FunctionComponent<PreviewImageType> = ({
curNum,
setCurNum,
}) => {
const imageList = [
idCardBasic,
idCardMude,
meetingAdd,
meetingCancel,
meeting30,
];
console.log(curNum);
return (
<>
<div className="preview-image-container">
Expand All @@ -29,7 +34,8 @@ const PreviewImage = () => {
showIndicators={false}
autoPlay
infiniteLoop
onChange={(index) => {
selectedItem={curNum}
onChange={(index, _) => {
setCurNum(index);
}}
>
Expand All @@ -51,6 +57,9 @@ const PreviewImage = () => {
? 'preview-carousel-circle-black'
: 'preview-carousel-circle-gray'
}
onClick={() => {
setCurNum(idx);
}}
></div>
);
})}
Expand Down
12 changes: 12 additions & 0 deletions src/features/preview/hooks/usePreview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useState } from 'react';

const usePreview = () => {
const [curNum, setCurNum] = useState<number>(0);

return {
curNum,
setCurNum,
};
};

export default usePreview;