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: 질문하기 페이지 UI 제작 #15

Merged
merged 8 commits into from
Sep 19, 2023
6 changes: 6 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { MyScrap } from 'pages/Mypage/MyScrap';
import { Provision } from 'pages/Mypage/Provision';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import WriteAnswer from 'pages/Answer/WriteAnswer';
import Ask from 'pages/Ask';
import WriteQuestion from 'pages/Ask/WriteQuestion';

function App() {
return (
Expand All @@ -24,6 +26,10 @@ function App() {
<Route path="/answer" element={<Answer />} />
<Route path="/answer/:id" element={<WriteAnswer />} />

{/* AskPage */}
<Route path="/ask" element={<Ask />} />
<Route path="/ask/write" element={<WriteQuestion />} />

{/* MyPage */}
<Route path="/myPage" element={<Mypage />} />
<Route path="/myPage/myQna" element={<MyQna />} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Answer/AnswersContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Column } from 'assets/common';
import { AnsButtonCard } from 'components/Card';
import { AnsButtonCard } from 'components/common/Card';

const AnswersContainer = () => {
return (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@ import { useState } from 'react';
import { Column, Row } from 'assets/common';
import Typo from 'styles/Typo';

const CategoryBar = () => {
const CategoryBar = ({ ctgAll }: { ctgAll: boolean }) => {
return (
<Container>
<Typo.s1>카테고리</Typo.s1>
<Categories></Categories>
<Title></Title>
<Categories ctgAll={ctgAll}></Categories>
</Container>
);
};

export const Categories = () => {
const [categories, setCategories] = useState([
{ id: 1, name: '전체', selected: true },
{ id: 2, name: '일상', selected: false },
{ id: 3, name: '인간관계', selected: false },
{ id: 4, name: '사회생활', selected: false },
{ id: 5, name: '기타', selected: false },
]);
const Categories = ({ ctgAll }: { ctgAll: boolean }) => {
const ctgArr = ctgAll
? [
{ id: 1, name: '전체', selected: true },
{ id: 2, name: '일상', selected: false },
{ id: 3, name: '인간관계', selected: false },
{ id: 4, name: '사회생활', selected: false },
{ id: 5, name: '기타', selected: false },
]
: [
{ id: 2, name: '일상', selected: false },
{ id: 3, name: '인간관계', selected: false },
{ id: 4, name: '사회생활', selected: false },
{ id: 5, name: '기타', selected: false },
];

const [categories, setCategories] = useState(ctgArr);
const handleClick = (id: number) => {
const updatedCategories = categories.map((category) => {
if (category.id === id) {
Expand All @@ -45,14 +54,20 @@ export const Categories = () => {
</CtgWrapper>
);
};

export default CategoryBar;

export const Container = styled(Column)`
const Container = styled(Column)`
width: 100%;
gap: 6px;
padding: 10px 30px;
`;
const Title = () => {
return <Typo.s1>카테고리</Typo.s1>;
};

CategoryBar.container = Container;
CategoryBar.ctgs = Categories;
CategoryBar.text = Title;
export default CategoryBar;

const CtgWrapper = styled(Row)`
flex-wrap: wrap;
gap: 8px;
Expand Down
31 changes: 17 additions & 14 deletions src/components/Main/CallToAction.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import { Column, Row, StyledLink } from 'assets/common';
import { CTABtn } from 'components/Button';
import { CTABtn } from 'components/common/Button';
import styled from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';

const CallToAction = () => {
return (
<StyledLink to="/question">
<Container>
<Column>
<Row>
<Typo.h1 color={Palette.Main}>경험 많은</Typo.h1>
<Typo.h1>&nbsp;시니어 분들에게</Typo.h1>
</Row>
<Typo.h1>질문해보세요.✍🏻</Typo.h1>
</Column>
<CTABtn>질문하러 가기</CTABtn>
<Img src="img/smile-face.svg"></Img>
</Container>
</StyledLink>
<Container>
<CTAText />
<CTABtn to="/ask">질문하러 가기</CTABtn>
<Img src="img/smile-face.svg"></Img>
</Container>
);
};

export const CTAText = () => {
return (
<Column>
<Row>
<Typo.h1 color={Palette.Main}>경험 많은</Typo.h1>
<Typo.h1>&nbsp;시니어 분들에게</Typo.h1>
</Row>
<Typo.h1>질문해보세요.✍🏻</Typo.h1>
</Column>
);
};
export default CallToAction;

const Container = styled(Column)`
Expand Down
2 changes: 1 addition & 1 deletion src/components/Mypage/MyQnaListBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { styled } from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import { MyPageBoxContainer, Row } from 'assets/common';
import { CategoryLabel } from 'components/CategoryLabel';
import { CategoryLabel } from 'components/Category/CategoryLabel';

interface qnaBoxInterface {
children: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Mypage/ScrapListBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import { MyPageBoxContainer, Row, TextContainer } from 'assets/common';
import { CategoryLabel } from 'components/CategoryLabel';
import { CategoryLabel } from 'components/Category/CategoryLabel';

interface ScrapBoxInterface {
children: string;
Expand Down
4 changes: 3 additions & 1 deletion src/components/Search/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from 'styled-components';
import back from 'assets/icons/back.svg';
import searchButton from 'assets/icons/search-button.svg';
import { Palette } from 'styles/Palette';
import { useNavigate } from 'react-router';

interface searchBarProps {
text: string;
Expand All @@ -17,6 +18,7 @@ const SearchBar = ({
setIsSearched,
setSearchText,
}: searchBarProps) => {
const navigate = useNavigate();
const toggleSearched = () => {
setIsSearched(true);
setSearchText(text);
Expand All @@ -33,7 +35,7 @@ const SearchBar = ({

return (
<Container>
<img src={back} />
<img src={back} onClick={() => navigate(-1)} />
<SearchInputWrapper>
<SearchInput
type="text"
Expand Down
15 changes: 12 additions & 3 deletions src/components/Search/SearchResult.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { Column, Row } from 'assets/common';
import CardSlider from 'components/Main/CardSlider';
import CardSlider from 'components/common/CardSlider';
import styled from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import { QTitleCard, QContentCard, AnsCard } from 'components/common/Card';

const SearchResult = ({ text }: { text: string }) => {
let resultNum = 23;
const cards = [
<QTitleCard></QTitleCard>,
<QContentCard></QContentCard>,
<AnsCard></AnsCard>,
<AnsCard></AnsCard>,
<AnsCard></AnsCard>,
];

return (
<Column gap={30}>
<Row>
Expand All @@ -15,8 +24,8 @@ const SearchResult = ({ text }: { text: string }) => {
<Typo.b4>개</Typo.b4>
</Row>
<ResultContainer>
<CardSlider></CardSlider>
<CardSlider></CardSlider>
<CardSlider cards={cards}></CardSlider>
<CardSlider cards={cards}></CardSlider>
</ResultContainer>
</Column>
);
Expand Down
21 changes: 14 additions & 7 deletions src/components/Button.tsx → src/components/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,38 @@ import styled from 'styled-components';
import { Palette } from 'styles/Palette';
import Typo from 'styles/Typo';
import ctaArrow from 'assets/icons/cta-arrow.svg';
import { Link } from 'react-router-dom';

export const LongBtn = ({ children }: { children: string }) => {
interface buttonProps {
children: string;
to: string;
}
export const LongBtn = ({ children, to }: buttonProps) => {
return (
<Container width={330}>
<Container to={to}>
<Typo.h5 color={Palette.White}>{children}</Typo.h5>
</Container>
);
};

export const ShortBtn = ({ children }: { children: string }) => {
export const ShortBtn = ({ children, to }: buttonProps) => {
return (
<Container>
<Container to={to}>
<Typo.b4 color={Palette.White}>{children}</Typo.b4>
</Container>
);
};

export const CTABtn = ({ children }: { children: string }) => {
export const CTABtn = ({ children, to }: buttonProps) => {
return (
<CTABtnContainer>
<CTABtnContainer to={to}>
<Typo.b3 color={Palette.White}>{children}</Typo.b3>
<img src={ctaArrow}></img>
</CTABtnContainer>
);
};

const Container = styled.button<{ width?: number }>`
const Container = styled(Link)<{ width?: number }>`
width: ${({ width }) => (width ? `${width}px` : '100%')};
height: 50px;

Expand All @@ -39,6 +44,8 @@ const Container = styled.button<{ width?: number }>`
border: none;
border-radius: 10px;
background: ${Palette.Main};

text-decoration: none;
cursor: pointer;
`;
const CTABtnContainer = styled(Container)`
Expand Down
6 changes: 2 additions & 4 deletions src/components/Card.tsx → src/components/common/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import defaultTag from '@assets/icons/default-tag.svg';
import Typo from 'styles/Typo';
import { Column, Row, StyledLink } from 'assets/common';
import { ShortBtn } from './Button';
import { CategoryLabel } from 'components/CategoryLabel';
import { CategoryLabel } from 'components/Category/CategoryLabel';

/* Card components */

Expand Down Expand Up @@ -85,9 +85,7 @@ export const AnsButtonCard = () => {
<Date>2023.09.11</Date>
</Column>

<StyledLink to="/answer/1">
<ShortBtn>답변하기</ShortBtn>
</StyledLink>
<ShortBtn to="/answer/1">답변하기</ShortBtn>
</ABContainer>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Column, Row } from 'assets/common';
import { AnsCard, QContentCard, QTitleCard } from 'components/Card';
import { AnsCard, QContentCard, QTitleCard } from 'components/common/Card';
import { useState } from 'react';
import Slider from 'react-slick';
import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import { styled } from 'styled-components';
import { Palette } from 'styles/Palette';
import PageIndicator, { Dot } from './PageIndicator';
import PageIndicator, { Dot } from '../Main/PageIndicator';

const CardSlider = () => {
const CardSlider = ({ cards }: { cards: React.ReactNode[] }) => {
const [currentSlide, setCurrentSlide] = useState<number>(0);
const settings = {
dots: false,
Expand All @@ -21,13 +20,6 @@ const CardSlider = () => {
setCurrentSlide(current);
},
};
const cards = [
<QTitleCard></QTitleCard>,
<QContentCard></QContentCard>,
<AnsCard></AnsCard>,
<AnsCard></AnsCard>,
<AnsCard></AnsCard>,
];

return (
<Wrapper>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const WriteConfirmBar = ({ userType }: { userType: number }) => {
const onClickWrite = () => {
const result = window.confirm('답변을 등록하겠습니까?');
if (result) {
alert('답변이 등록되었습니다.');
userType === 1 ? navigate('/answer') : navigate('/ask');
} else {
}
};
const onClickCancle = () => {
const result = window.confirm('작성을 취소하시겠습니까?');
if (result) {
userType === 1 ? navigate('/answer') : navigate('/question');
userType === 1 ? navigate('/answer') : navigate('/ask');
} else {
}
};
Expand Down
Loading