-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #198 from team-offonoff/feat/b-side-page
feat: B 사이드 토픽 홈 화면 구현
- Loading branch information
Showing
12 changed files
with
283 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { styled } from 'styled-components'; | ||
|
||
const CardContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
background-color: ${({ theme }) => theme.colors.navy2_60}; | ||
backdrop-filter: blur(1.5px); | ||
border-radius: 10px; | ||
`; | ||
|
||
const CardFooter = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 9px 22px; | ||
background-color: rgb(100 81 155 / 60%); | ||
border-bottom-right-radius: 10px; | ||
border-bottom-left-radius: 10px; | ||
`; | ||
|
||
export { CardContainer, CardFooter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import React from 'react'; | ||
|
||
import CommentChip from '@components/commons/Chip/CommentChip'; | ||
import { Col, Row } from '@components/commons/Flex/Flex'; | ||
import Text from '@components/commons/Text/Text'; | ||
import { TopicResponse } from '@interfaces/api/topic'; | ||
|
||
import { colors } from '@styles/theme'; | ||
|
||
import { getDateDiff } from '@utils/date'; | ||
|
||
import { CardContainer, CardFooter } from './BTopicCard.styles'; | ||
import BTopicChoice from './BTopicChoice'; | ||
|
||
interface BTopicCardProps { | ||
topic: TopicResponse; | ||
} | ||
|
||
const BTopicCard = ({ topic }: BTopicCardProps) => { | ||
return ( | ||
<> | ||
<CardContainer> | ||
<Col padding={'12px 22px 20px'}> | ||
<Row justifyContent={'space-between'} alignItems={'center'} style={{ marginBottom: 2 }}> | ||
<Row gap={10}> | ||
<Text size={13} color={colors.purple}> | ||
{topic.keyword?.keywordName} | ||
</Text> | ||
<Text size={13} color={colors.white_40}> | ||
{getDateDiff(topic.createdAt)} 전 | ||
</Text> | ||
</Row> | ||
{topic.selectedOption && ( | ||
<Text | ||
size={13} | ||
weight={600} | ||
color={colors.purple} | ||
noWrap | ||
style={{ | ||
borderRadius: 30, | ||
padding: '2px 12px', | ||
backgroundColor: colors.purple_30, | ||
}} | ||
> | ||
선택완료 | ||
</Text> | ||
)} | ||
</Row> | ||
<Row justifyContent={'space-between'} alignItems={'center'} style={{ marginBottom: 17 }}> | ||
<Text size={18} weight={600} color={colors.white}> | ||
{topic.topicTitle} | ||
</Text> | ||
<button>-</button> | ||
</Row> | ||
<Row gap={5}> | ||
<BTopicChoice | ||
side={topic.choices[0].choiceOption} | ||
content={topic.choices[0].content.text || ''} | ||
/> | ||
<BTopicChoice | ||
side={topic.choices[1].choiceOption} | ||
content={topic.choices[1].content.text || ''} | ||
/> | ||
</Row> | ||
</Col> | ||
<CardFooter> | ||
<Row gap={5}> | ||
<Text size={13} weight={600} color={colors.white_80}> | ||
선택 | ||
</Text> | ||
<Text size={13} weight={600} color={colors.white_40}> | ||
{topic.voteCount.toLocaleString()} 명 | ||
</Text> | ||
</Row> | ||
<CommentChip | ||
count={topic.commentCount} | ||
backgroundColor={colors.black_20} | ||
onClick={function (): void { | ||
throw new Error('Function not implemented.'); | ||
}} | ||
/> | ||
</CardFooter> | ||
</CardContainer> | ||
</> | ||
); | ||
}; | ||
|
||
export default BTopicCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
import Text from '@components/commons/Text/Text'; | ||
|
||
import { colors } from '@styles/theme'; | ||
|
||
interface BTopicChoiceProps { | ||
side: 'CHOICE_A' | 'CHOICE_B'; | ||
content: string; | ||
} | ||
|
||
const BTopicChoice = ({ side, content }: BTopicChoiceProps) => { | ||
return ( | ||
<ChoiceContainer> | ||
<Text size={13} weight={600} color={colors.white_40} align={'center'}> | ||
{content} | ||
</Text> | ||
<Text | ||
size={20} | ||
weight={900} | ||
color={side === 'CHOICE_A' ? colors.A_60 : colors.B_60} | ||
style={{ position: 'absolute', top: 0, left: 6 }} | ||
> | ||
{side === 'CHOICE_A' ? 'A' : 'B'} | ||
</Text> | ||
</ChoiceContainer> | ||
); | ||
}; | ||
|
||
const ChoiceContainer = styled.div` | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 72px; | ||
padding: 0 20px; | ||
background-color: ${({ theme }) => theme.colors.navy2}; | ||
border-radius: 10px; | ||
`; | ||
|
||
export default BTopicChoice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { styled } from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
height: 100%; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React, { ChangeEvent, useLayoutEffect, useState } from 'react'; | ||
|
||
import useTopics from '@apis/topic/useTopics'; | ||
import BTopicCard from '@components/B/BTopicCard'; | ||
import { Row, Col } from '@components/commons/Flex/Flex'; | ||
import Layout from '@components/commons/Layout/Layout'; | ||
import Text from '@components/commons/Text/Text'; | ||
import ToggleSwitch from '@components/commons/ToggleSwitch/ToggleSwitch'; | ||
|
||
import { colors } from '@styles/theme'; | ||
|
||
import { BFillLogoIcon, UpDownChevronIcon } from '@icons/index'; | ||
|
||
import { Container } from './BTopics.styles'; | ||
|
||
const BTopics = () => { | ||
const { data } = useTopics({ side: 'TOPIC_B', sort: 'createdAt,DESC' }); | ||
const [topicFilter, setTopicFilter] = useState('진행중'); | ||
const [isMineOnly, setIsMineOnly] = useState(false); | ||
const [isLatest, setIsLatest] = useState(true); | ||
|
||
const topics = data?.pages.flatMap((page) => page.data); | ||
|
||
const handleTopicStatusChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
setTopicFilter(e.target.value); | ||
}; | ||
|
||
/** | ||
* set body background color to dark and restore it on cleanup | ||
*/ | ||
useLayoutEffect(() => { | ||
const prevColor = document.body.style.backgroundColor; | ||
document.body.style.backgroundColor = '#0e0d16'; | ||
|
||
return () => { | ||
document.body.style.backgroundColor = prevColor; | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<Layout | ||
hasBottomNavigation | ||
HeaderLeft={<BFillLogoIcon width={30} height={30} fill={colors.white} />} | ||
HeaderCenter={ | ||
<ToggleSwitch value={topicFilter} onChange={handleTopicStatusChange}> | ||
<ToggleSwitch.Option value={'진행중'}> | ||
<Text size={15} weight={500} color={'inherit'}> | ||
진행중 | ||
</Text> | ||
</ToggleSwitch.Option> | ||
<ToggleSwitch.Option value={'종료된'}> | ||
<Text size={15} weight={500} color={'inherit'}> | ||
종료된 | ||
</Text> | ||
</ToggleSwitch.Option> | ||
</ToggleSwitch> | ||
} | ||
> | ||
<Container> | ||
<Row justifyContent={'flex-end'} gap={12} padding="15px 20px"> | ||
<button onClick={() => setIsMineOnly((prev) => !prev)}> | ||
<Row alignItems="center" gap={6}> | ||
<div | ||
style={{ | ||
width: '14px', | ||
height: '14px', | ||
borderRadius: '50%', | ||
border: '1px solid', | ||
borderColor: isMineOnly ? colors.white : colors.white_40, | ||
}} | ||
/> | ||
<Text size={13} color={isMineOnly ? colors.white : colors.white_40}> | ||
내 토픽만 | ||
</Text> | ||
</Row> | ||
</button> | ||
<button onClick={() => setIsLatest((prev) => !prev)}> | ||
<Row alignItems="center" gap={6}> | ||
<UpDownChevronIcon stroke={isLatest ? colors.white : colors.white_40} /> | ||
<Text size={13} color={isLatest ? colors.white : colors.white_40}> | ||
최신순 | ||
</Text> | ||
</Row> | ||
</button> | ||
</Row> | ||
<Col padding={'0 20px 100px'} gap={30}> | ||
{topics?.map((topic) => <BTopicCard key={topic.topicId} topic={topic} />)} | ||
</Col> | ||
</Container> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default BTopics; |
Oops, something went wrong.