Skip to content

Commit

Permalink
Merge pull request #142 from team-offonoff/feat/topic-create-page
Browse files Browse the repository at this point in the history
Feat/topic create page
  • Loading branch information
chaeyoung103 authored Jan 23, 2024
2 parents c0ec41f + 0d0c015 commit efac491
Show file tree
Hide file tree
Showing 29 changed files with 759 additions and 111 deletions.
4 changes: 4 additions & 0 deletions src/assets/icons/big-down-chevron.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/assets/icons/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions src/assets/icons/down-chevron.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/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AlarmIcon from './alarm-default.svg?react';
import NewAlarmIcon from './alarm-new.svg?react';
import AppleIcon from './apple.svg?react';
import BLogoIcon from './b-logo.svg?react';
import BigDownChevronIcon from './big-down-chevron.svg?react';
import ClockIcon from './clock.svg?react';
import CloseIcon from './close.svg?react';
import CommentIcon from './comment.svg?react';
Expand All @@ -22,6 +23,7 @@ import RefreshIcon from './refresh.svg?react';
import ReportIcon from './report.svg?react';
import RightChevronIcon from './right-chevron.svg?react';
import RightDoubleArrowIcon from './right-double-arrow.svg?react';
import RotateIcon from './rotate.svg?react';
import SizeUpIcon from './size-up.svg?react';
import ThumbsIcon from './thumbs.svg?react';
import TopicCreatBackgrounIcon from './topic-create-background.svg?react';
Expand All @@ -33,6 +35,7 @@ export {
AlarmIcon,
ALogoIcon,
AppleIcon,
BigDownChevronIcon,
BLogoIcon,
ClockIcon,
CloseIcon,
Expand All @@ -51,6 +54,7 @@ export {
ReportIcon,
RightChevronIcon,
RightDoubleArrowIcon,
RotateIcon,
SelectedHomeIcon,
SizeUpIcon,
ThumbsIcon,
Expand Down
6 changes: 4 additions & 2 deletions src/assets/icons/right-chevron.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/rotate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 26 additions & 7 deletions src/assets/styles/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@ import { DefaultTheme } from 'styled-components/dist/types';

export const colors = {
purple: '#A46FF3',
sub_purple: '#624392',
sub_purple2: '#BE28F3',
purple_30: 'rgba(164, 111, 243, 0.30)',
purple_60: 'rgba(164, 111, 243, 0.60)',
purple2: '#BE28F3',
navy: '#242036',
navy_20: 'rgba(36, 32, 54, 0.20)',
navy_40: 'rgba(36, 32, 54, 0.40)',
navy_60: 'rgba(36, 32, 54, 0.60)',
navy_80: 'rgba(36, 32, 54, 0.80)',
navy2: '#4D3B7C',
sub_navy2: '#4D3B7C',
navy2_20: 'rgba(77, 59, 124, 0.20)',
navy2_40: 'rgba(77, 59, 124, 0.40)',
navy2_60: 'rgba(77, 59, 124, 0.60)',
navy2_80: 'rgba(77, 59, 124, 0.80)',
A: '#D04376',
sub_A: '#DF8AA9',
A_20: 'rgba(208, 67, 118, 0.20)',
A_40: 'rgba(208, 67, 118, 0.40)',
A_60: 'rgba(208, 67, 118, 0.60)',
A_80: 'rgba(208, 67, 118, 0.80)',
B: '#1498AA',
B_20: 'rgba(20, 152, 170, 0.20)',
B_40: 'rgba(20, 152, 170, 0.40)',
B_60: 'rgba(20, 152, 170, 0.60)',
B_80: 'rgba(20, 152, 170, 0.80)',
black: '#000000',
white: '#FFFFFF',
white_20: 'rgba(255, 255, 255, 0.20)',
Expand All @@ -20,6 +35,10 @@ export const colors = {
black_60: 'rgba(0, 0, 0, 0.60)',
white_80: 'rgba(255, 255, 255, 0.80)',
black_80: 'rgba(0, 0, 0, 0.80)',
navywhite_20: '#504D5E',
navywhite_40: '#7C7986',
navywhite_60: '#A7A6AF',
navywhite_80: '#D3D2D7',
};

export const zIndex = {
Expand All @@ -43,7 +62,7 @@ export const input = {
backgroundColor: '#342b52',
},
error: {
border: `1px solid ${colors.sub_purple2}`,
border: `1px solid ${colors.purple2}`,
backgroundColor: '#342b52',
},
},
Expand All @@ -54,7 +73,7 @@ export const input = {
lineHeight: '140%',
padding: '0 0 10px 0',
border: 'none',
borderBottom: `1px solid ${colors.sub_navy2}`,
borderBottom: `1px solid ${colors.navy2}`,
backgroundColor: 'transparent',
borderRadius: 0,
outline: 'none',
Expand All @@ -65,7 +84,7 @@ export const input = {
lineHeight: '140%',
padding: '0 0 10px 0',
border: 'none',
borderBottom: `1px solid ${colors.sub_purple2}`,
borderBottom: `1px solid ${colors.purple2}`,
borderRadius: 0,
backgroundColor: 'transparent',
outline: 'none',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/Comment/Comment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Comment = React.memo(({ comment }: CommentProps) => {
{'·'} {distanceText}
</Text>
</Row>
<Text size={14} color={colors.sub_A} weight={600}>
<Text size={14} color={colors.A} weight={600}>
{comment.writersVotedOption}
</Text>
</Col>
Expand Down
11 changes: 7 additions & 4 deletions src/components/Home/TopicSwiper/TopicSwiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import SwiperCore from 'swiper';
import { Navigation } from 'swiper/modules';
import { Swiper, SwiperSlide } from 'swiper/react';

import { colors } from '@styles/theme';

import { RightChevronIcon } from '@icons/index';

SwiperCore.use([Navigation]);
Expand All @@ -27,7 +29,7 @@ const TopicSwiper = ({ children }: TopicSwiperProps) => {
setNextDisabled(false);
}}
>
<RightChevronIcon style={{ transform: 'rotate(180deg)' }} />
<RightChevronIcon style={{ transform: 'rotate(180deg)' }} stroke={colors.white_40} />
</PrevButton>
<Swiper
allowTouchMove={false}
Expand All @@ -51,16 +53,17 @@ const TopicSwiper = ({ children }: TopicSwiperProps) => {
setPrevDisabled(false);
}}
>
<RightChevronIcon />
<RightChevronIcon stroke={colors.white_40} />
</NextButton>
</React.Fragment>
);
};

const SlideButton = styled.button<{ disabled: boolean }>`
z-index: 100;
width: 40px;
height: 40px;
width: 32px;
height: 32px;
padding: 4.8px 10.4px;
cursor: pointer;
background-color: transparent;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/NotificationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const NotificationItem = ({ onClick, notification }: NotificationItem) => {
<Text size={15} weight={500} color={colors.white}>
투표가 마감 되었어요, 지금 바로 결과를 확인해 보세요!
</Text>
<Text size={14} weight={400} color={colors.sub_purple2}>
<Text size={14} weight={400} color={colors.purple2}>
성수 치킨 버거의 종결지는? 성수 치킨 버거의 종결지는?
</Text>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Notifications/TabHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const TabHeader = ({ currentTab, setCurrentTab }: TabHeaderProps) => {
<Text
size={18}
weight={600}
color={tabName === currentTab ? colors.sub_purple2 : colors.white}
color={tabName === currentTab ? colors.purple2 : colors.white}
style={{ position: 'relative', zIndex: 1 }}
>
{tabName}
Expand Down
69 changes: 69 additions & 0 deletions src/components/TopicCreate/TopicCreateTextInput.styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { styled } from 'styled-components';

import { colors } from '@styles/theme';

export const ReplaceButton = styled.div`
display: flex;
flex-direction: row;
gap: 6px;
align-items: center;
justify-content: space-between;
width: 111px;
height: 18px;
`;

export const ReplaceIcon = styled.div`
display: flex;
align-items: center;
justify-content: center;
width: 14px;
height: 14px;
`;

export const TextInputContainer = styled.div`
position: relative;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 57px;
overflow: hidden;
background-color: transparent;
border-radius: 10px;
`;

export const TextInputTextContainer = styled.div`
position: absolute;
top: 50%;
left: 50%;
display: flex;
align-items: center;
justify-content: center;
transform: translate(-50%, -50%);
`;

export const Input = styled.input`
width: 100%;
height: 100%;
padding: 16px;
font-size: 1.8rem;
font-weight: 500;
line-height: 1.4;
color: ${colors.white};
background-color: rgb(77 59 124 / 40%);
border: none;
border-radius: 10px;
outline: none;
&::placeholder {
color: ${colors.purple};
}
`;

export const InputSuffix = styled.div`
position: absolute;
top: 50%;
right: 16px;
transform: translateY(-50%);
`;
91 changes: 91 additions & 0 deletions src/components/TopicCreate/TopicCreateTextInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Register } from '@tanstack/react-query';
import React from 'react';
import { RegisterOptions, useFormContext } from 'react-hook-form';
import { CONFIG, INPUT_TYPE, InputType } from 'src/constants/form';

import { Col, Row } from '@components/commons/Flex/Flex';
import Text from '@components/commons/Text/Text';

import { colors } from '@styles/theme';

import { RotateIcon } from '@icons/index';

import {
Input,
ReplaceButton,
ReplaceIcon,
TextInputContainer,
TextInputTextContainer,
InputSuffix,
} from './TopicCreateTextInput.styles';

interface TopicCreareProps {
topic: 'A' | 'B';
topicContent: string;
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
}

const TopicCreateTextInput = ({ topic, topicContent }: TopicCreareProps) => {
const { register, watch } = useFormContext();
const ATopicProgress = watch(INPUT_TYPE.ATOPIC)
? `${watch(INPUT_TYPE.ATOPIC)?.length}/25`
: '0/25';
const BTopicProgress = watch(INPUT_TYPE.BTOPIC)
? `${watch(INPUT_TYPE.BTOPIC)?.length}/25`
: '0/25';
return (
<Col gap={16}>
<Row gap={83} justifyContent="space-between">
<Text size={16} weight={400} color={colors.white_60} align="start">
어떤 선택지가 있나요?
</Text>
<ReplaceButton>
<ReplaceIcon>
<RotateIcon opacity="0.3" />
</ReplaceIcon>
<Text style={{ opacity: 0.3 }} size={13} weight={400} color={colors.purple} align="start">
AB 선택지 바꾸기
</Text>
</ReplaceButton>
</Row>
<Col gap={8}>
<TextInputContainer>
<TextInputTextContainer>
<Text style={{ opacity: 0.2 }} size={128} weight={900} color={colors.A}>
A
</Text>
</TextInputTextContainer>
<Input
type="text"
{...register(INPUT_TYPE.ATOPIC, CONFIG.ATOPIC.options)}
placeholder="A 선택지를 입력해주세요."
/>
<InputSuffix>
<Text size={15} weight={400} color={colors.purple_60}>
{ATopicProgress}
</Text>
</InputSuffix>
</TextInputContainer>
<TextInputContainer>
<TextInputTextContainer>
<Text style={{ opacity: 0.2 }} size={128} weight={900} color={colors.B}>
B
</Text>
</TextInputTextContainer>
<Input
type="text"
{...register(INPUT_TYPE.BTOPIC, CONFIG.BTOPIC.options)}
placeholder="B 선택지를 입력해주세요."
/>
<InputSuffix>
<Text size={15} weight={400} color={colors.purple_60}>
{BTopicProgress}
</Text>
</InputSuffix>
</TextInputContainer>
</Col>
</Col>
);
};

export default TopicCreateTextInput;
Loading

0 comments on commit efac491

Please sign in to comment.