Skip to content

Commit

Permalink
Merge pull request #28 from whatever-mentoring/feature/onboarding
Browse files Browse the repository at this point in the history
feat: ์˜จ๋ณด๋”ฉ ํŽ˜์ด์ง€ ์ƒ์„ฑ
  • Loading branch information
chaeyeonan authored Sep 24, 2023
2 parents 231e790 + e16b02c commit 8a664d4
Show file tree
Hide file tree
Showing 19 changed files with 284 additions and 12 deletions.
9 changes: 9 additions & 0 deletions public/img/Onboarding/CardIndex1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/img/Onboarding/CardIndex2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/img/Onboarding/CardIndex3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/img/Onboarding/main1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/img/Onboarding/main2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ import TermsOfService from 'pages/Signup/TermsOfService';
import SignupSuccess from 'pages/Signup/SignupSuccess';
import { RecoilRoot } from 'recoil';
import Answer from 'pages/Answer';
import { Onboarding } from 'pages/Onboarding';

function App() {
return (
<RecoilRoot>
<BrowserRouter>
<Routes>
{/* OnboardingPage */}
<Route path="/onBoarding" element={<Onboarding />} />

{/* MainPage */}
<Route path="/" element={<Main />} />
<Route path="/post/:idx" element={<PostDetail />} />
Expand Down
5 changes: 5 additions & 0 deletions src/assets/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ export const StyledLink = styled(Link)<{ color?: string }>`
text-decoration: none;
color: ${({ color }) => (color ? color : Palette.Black)};
`;

export const Img = styled.img`
width: 100%;
height: 100%;
`;
Empty file.
2 changes: 1 addition & 1 deletion src/components/PostDetail/CommentInputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useState, useEffect, useRef } from 'react';
import closure from 'store/closure';
import { editCommentApi, postCommentApi } from 'network/apis/commentApi';
import { useRecoilState, useResetRecoilState } from 'recoil';
import { editCommentState } from 'recoil/atom';
import { editCommentState } from 'store/recoil/atom';

const CommentInputBox = ({ idx }: { idx: number }) => {
const userType = closure.getUserType();
Expand Down
2 changes: 1 addition & 1 deletion src/components/PostDetail/CommentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import edit from 'assets/icons/edit.svg';
import deleteComment from 'assets/icons/delete-comment.svg';
import report from 'assets/icons/report.svg';
import { useRecoilState } from 'recoil';
import { editCommentState } from 'recoil/atom';
import { editCommentState } from 'store/recoil/atom';
import { commentType } from 'types';
import { deleteCommentApi } from 'network/apis/commentApi';

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import closure from 'store/closure';
import { questionType } from 'types';
import { Ref, forwardRef } from 'react';
import { useRecoilValue, useRecoilState, useSetRecoilState } from 'recoil';
import { questionState } from 'recoil/atom';
import { questionState } from 'store/recoil/atom';

interface cardProps {
category?: string;
Expand Down
8 changes: 4 additions & 4 deletions src/components/common/WriteConfirmBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import { useLocation } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { writeState } from 'recoil/atom';
import { postQuestionApi } from 'network/question';
import { postAnswerApi } from 'network/answerApi';
import { writeState } from 'store/recoil/atom';
import { postQuestionApi } from 'network/apis/question';
import { postAnswerApi } from 'network/apis/answerApi';

const WriteConfirmBar = ({ postIdx }: { postIdx?: number }) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -59,7 +59,7 @@ const WriteConfirmBar = ({ postIdx }: { postIdx?: number }) => {

return (
<Container>
<BtnDib
<BtnDib
color={Palette.Gray05}
borderClr={Palette.Gray2}
onClick={onClickCancel}
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/WriteInputBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import { useSetRecoilState } from 'recoil';
import { writeState } from 'recoil/atom';
import { writeState } from 'store/recoil/atom';

interface inputboxProps {
placeholder: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { publicInstance } from './config';
import { publicInstance } from '../config';

export const postAnswerApi = async ({
postIdx,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { publicInstance } from './config';
import { publicInstance } from '../config';

export const postQuestionApi = async ({
title,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Answer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CategoryBar from 'components/Category/CategoryBar';
import { useEffect, useState } from 'react';
import { questionType } from 'types';
import { useInView } from 'react-intersection-observer';
import { getQuestionApi } from 'network/question';
import { getQuestionApi } from 'network/apis/question';
import { AnsButtonCard } from 'components/common/Card';

const Answer = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Ask/WriteQuestion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import styled from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import { useSetRecoilState } from 'recoil';
import { writeState } from 'recoil/atom';
import { writeState } from 'store/recoil/atom';

const WriteQuestion = () => {
const [selectedCtg, setSelectedCtg] = useState<string>('DAILY');
Expand Down
218 changes: 218 additions & 0 deletions src/pages/Onboarding/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import { Column, Img, StyledLink } from 'assets/common';
import { styled } from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import Slider, { Settings } from 'react-slick';
import { useRef, useState } from 'react';

interface cardComponentsInterface {
img: string;
text: React.ReactNode;
}

const cardComponents: cardComponentsInterface[] = [
{
img: 'CardIndex1',
text: (
<>
Juitcy๋Š” ์ต๋ช…์˜ ์‹œ๋‹ˆ์–ด <span style={{ color: Palette.Blue }}>์‹œ๋‹ˆ</span>
์™€,
<br />
์ต๋ช…์˜ ์ฃผ๋‹ˆ์–ด <span style={{ color: Palette.Orange }}>์ฅฌ๋‹ˆ</span>๋ฅผ
์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค.
</>
),
},
{
img: 'CardIndex2',
text: (
<>
<span style={{ color: Palette.Orange }}>์ฅฌ๋‹ˆ</span>๋Š” ์‚ถ์˜ ๊ณ ๋ฏผ์„ ํ„ธ์–ด
๋†“๊ณ ,
</>
),
},
{
img: 'CardIndex3',
text: (
<>
<span style={{ color: Palette.Blue }}>์‹œ๋‹ˆ</span>๋Š” ์‚ถ์˜ ์ง€ํ˜œ๊ฐ€ ๋‹ด๊ธด
๋‹ต๋ณ€์„ ๋‚จ๊น๋‹ˆ๋‹ค.
</>
),
},
];

export const Onboarding = () => {
const [currentSlide, setCurrentSlide] = useState(0);
const sliderRef = useRef<Slider>(null);

// ๋‹ค์Œ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ์Šฌ๋ผ์ด๋“œ๋ฅผ ๋„˜๊น€
const handleNextSlide = () => {
if (sliderRef.current) {
sliderRef.current.slickNext();
}
if (currentSlide === 2) setCurrentSlide(3);
else if (currentSlide === 3) setCurrentSlide(4);
};

const settings: Settings = {
dots: true,
fade: true,
infinite: false,
speed: 1000,
slidesToShow: 1,
slidesToScroll: 1,
afterChange: (index: number) => {
setCurrentSlide(index);
},
};

return (
<Container>
{/* ์นด๋“œ ์Šฌ๋ผ์ด๋“œ์žˆ๋Š” ์˜จ๋ณด๋”ฉ */}
<WithCard index={currentSlide}>
<Column gap={15}>
<Typo.h2>์ฅฌ๋‹ˆ์–ด์™€ ์‹œ๋‹ˆ์–ด๋ฅผ ์ž‡๋‹ค</Typo.h2>
<div className="img-container">
<img src="/img/logo-text.svg" />
</div>
</Column>
<div className="slider-container">
<StyledSlider {...settings} ref={sliderRef}>
{cardComponents.map(
(card: cardComponentsInterface, index: number) => (
<div key={index} style={{ gap: '30px' }}>
<Column gap={30}>
<div className="card-img-container">
<img src={`/img/Onboarding/${card.img}.svg`} />
</div>
<Typo.b4>{card.text}</Typo.b4>
</Column>
</div>
),
)}
</StyledSlider>
</div>
</WithCard>
{/* ์นด๋“œ์Šฌ๋ผ์ด๋“œ ์—†๋Š” ์˜จ๋ณด๋”ฉ */}
<WithoutCard index={currentSlide}>
<div className="main1">
<div className="main-img-container">
<Img src="/img/Onboarding/main1.svg" />
</div>
</div>
<div className="main2">
<div className="main2-container">
<div style={{ textAlign: 'center' }}>
<Typo.h3>
์กด์žฌ๋งŒ์œผ๋กœ ์„œ๋กœ์˜ ์‚ถ์— ์˜จ๊ธฐ๋ฅผ ๋”ํ•˜๋Š” ์„ธ๋Œ€ ๊ณต๊ฐ ๋ฌธ๋‹ต ์ปค๋ฎค๋‹ˆํ‹ฐ,
์ฅฌ์ž‡์”จ
</Typo.h3>
</div>
<div className="main-img-container">
<Img src="/img/Onboarding/main2.svg" />
</div>
</div>
</div>
</WithoutCard>
<TextContainer>
<StyledLink to={currentSlide === 4 ? '/signup' : ''}>
<StyledButton onClick={handleNextSlide}>
<Typo.h5>{currentSlide === 4 ? '์‹œ์ž‘' : '๋‹ค์Œ'}</Typo.h5>
</StyledButton>
</StyledLink>
<Typo.b3 color={Palette.Gray5}>๋ฐ”๋กœ ๋กœ๊ทธ์ธํ•˜๊ธฐ</Typo.b3>
</TextContainer>
</Container>
);
};

const Container = styled.div`
width: 100%;
padding: 79px 30px 42px 30px;
display: flex;
flex-direction: column;
justify-content: space-between;
.img-container {
width: 121px;
margin: 0 0 30px 0;
}
.slider-container {
height: 100%;
}
`;
const StyledButton = styled.div`
width: 100%;
background: ${Palette.Orange};
color: ${Palette.White};
padding: 10px 0;
text-align: center;
border-radius: 10px;
`;

const StyledSlider = styled(Slider)`
width: 100%;
height: fit-contents;
border-radius: 10px;
background: ${Palette.White};
box-shadow: 1px 1px 10px 1px rgba(0, 0, 0, 0.1);
padding: 40px 0 30px 0;
text-align: center;
margin-bottom: 30px;
.slick-dots {
bottom: -40px;
}
.card-img-container {
width: 100%;
display: flex;
justify-content: center;
}
`;

const TextContainer = styled.div`
text-align: center;
display: flex;
flex-direction: column;
gap: 20px;
//์นด๋“œ ํ…์ŠคํŠธ
.bevrNG {
text-decoration-color: ${Palette.Gray5};
text-decoration: underline;
}
`;

const WithCard = styled.div<{ index?: number }>`
display: ${({ index }) => (index === 3 || index === 4 ? 'none' : 'block')};
height: 510px;
`;
const WithoutCard = styled.div<{ index?: number }>`
display: ${({ index }) =>
index === 0 || index === 1 || index === 2 ? 'none' : 'block'};
height: 510px;
.main-img-container {
height: 80%;
width: 80%;
}
.main1 {
display: ${({ index }) => (index !== 3 ? 'none' : 'block')};
}
.main2 {
display: ${({ index }) => (index !== 4 ? 'none' : 'block')};
}
.main2-container {
display: flex;
flex-direction: column;
gap: 30px;
align-items: center;
padding: 50px 0 0 0;
}
`;
File renamed without changes.

0 comments on commit 8a664d4

Please sign in to comment.