Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/TargetPage' into TargetP…
Browse files Browse the repository at this point in the history
…age/#145-targetpage-refactor
  • Loading branch information
jungwoo3490 committed Jan 17, 2024
2 parents 681ec1b + 1ef1d30 commit 5bafcc6
Show file tree
Hide file tree
Showing 12 changed files with 149 additions and 94 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@sentry/vite-plugin": "^2.10.2",
"axios": "^1.6.5",
"eslint-plugin-react": "^7.33.2",
"grapheme-splitter": "^1.0.4",
"lottie-react": "^2.4.0",
"postcss": "^8.4.33",
"postcss-styled-syntax": "^0.6.3",
Expand Down
9 changes: 7 additions & 2 deletions src/CreateBook/components/CompleteButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import * as S from './CompleteButton.style';
interface CompleteButtonProps {
isActive: boolean;
onClick: () => void;
backgroundColor: string;
}

function CompleteButton({ isActive, onClick }: CompleteButtonProps) {
function CompleteButton({
isActive,
onClick,
backgroundColor,
}: CompleteButtonProps) {
return (
<S.CompleteButtonWrapper>
<Button variant="complete" disabled={!isActive} onClick={onClick}>
<Button variant="complete" disabled={!isActive} onClick={onClick} backgroundColor={backgroundColor}>
완료
</Button>
</S.CompleteButtonWrapper>
Expand Down
4 changes: 2 additions & 2 deletions src/CreateBook/components/SelectColor/SelectColor.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ export const Wrapper = styled.article`
gap: 1.6rem;
flex-direction: column;
`;
export const Category = styled.p`
export const Category = styled.p<{ variant: boolean }>`
display: flex;
${({ theme }) => theme.colors.BG};
color: ${({ theme, variant }) => (variant ? theme.colors.white : theme.colors.BG)};
${({ theme }) => theme.fonts.Title1_SB_16};
`;
4 changes: 3 additions & 1 deletion src/CreateBook/components/SelectColor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ function SelectColor({
}: SelectColorProps) {
return (
<S.Wrapper>
<S.Category>레큐북 배경색</S.Category>
<S.Category variant={backgroundColor === '#191919'}>
레큐북 배경색
</S.Category>
<ShowColorChart
backgroundColor={backgroundColor}
handleFn={(backgroundColor: string) =>
Expand Down
12 changes: 6 additions & 6 deletions src/CreateBook/components/ShowColorChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ function ShowColorChart({ backgroundColor, handleFn }: ShowColorChartProps) {
<S.ColorWrapper>
<S.Color
type="button"
$colorCode={'#191919'}
onClick={() => handleFn('#191919')}
variant={backgroundColor === '#191919'}
$colorCode={'#F5F5F5'}
onClick={() => handleFn('#F5F5F5')}
variant={backgroundColor === '#F5F5F5'}
></S.Color>
</S.ColorWrapper>
<S.ColorWrapper>
<S.Color
type="button"
$colorCode={'#F5F5F5'}
onClick={() => handleFn('#F5F5F5')}
variant={backgroundColor === '#F5F5F5'}
$colorCode={'#191919'}
onClick={() => handleFn('#191919')}
variant={backgroundColor === '#191919'}
></S.Color>
</S.ColorWrapper>
</S.Wrapper>
Expand Down
9 changes: 6 additions & 3 deletions src/CreateBook/page/CreateBook.style.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import styled from '@emotion/styled';

export const CreateBookWrapper = styled.section`
export const CreateBookWrapper = styled.section<{ $backgroundColor: string }>`
display: flex;
flex-direction: column;
width: 100vw;
height: 100dvh;
background-color: ${({ $backgroundColor }) => $backgroundColor};
`;

export const CreateBookBodyWrapper = styled.div`
Expand All @@ -23,8 +25,9 @@ export const InputWrapper = styled.div`
width: 100%;
`;

export const SectionTitle = styled.p`
color: ${({ theme }) => theme.colors.BG};
export const SectionTitle = styled.p<{ variant: boolean }>`
color: ${({ theme, variant }) =>
variant ? theme.colors.white : theme.colors.BG};
${({ theme }) => theme.fonts.Head2_SB_18};
`;
Expand Down
9 changes: 5 additions & 4 deletions src/CreateBook/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as S from './CreateBook.style';
function CreateBook() {
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
const [backgroundColor, setBackgroundColor] = useState('#191919');
const [backgroundColor, setBackgroundColor] = useState('#F5F5F5');
const location = useLocation();
const navigate = useNavigate();
const { presignedFileName, name } = location.state || {};
Expand All @@ -31,16 +31,16 @@ function CreateBook() {
};

return (
<S.CreateBookWrapper>
<S.CreateBookWrapper $backgroundColor={backgroundColor}>
<Header headerTitle="레큐북 만들기" />
<S.CreateBookBodyWrapper>
<S.InputWrapper>
<S.BookInputWrapper>
<S.SectionTitle>레큐북 제목</S.SectionTitle>
<S.SectionTitle variant={backgroundColor==="#191919"}>레큐북 제목</S.SectionTitle>
<BookInput title={title} changeTitle={(title) => setTitle(title)} />
</S.BookInputWrapper>
<S.BookInfoTextareaWrapper>
<S.SectionTitle>레큐북 소개</S.SectionTitle>
<S.SectionTitle variant={backgroundColor==="#191919"}>레큐북 소개</S.SectionTitle>
<BookInfoTextarea
description={description}
changeDescription={(description) => setDescription(description)}
Expand All @@ -54,6 +54,7 @@ function CreateBook() {
/>
</S.InputWrapper>
<CompleteButton
backgroundColor={backgroundColor}
isActive={title.length !== 0 && description.length !== 0}
onClick={handleClickCompleteButton}
/>
Expand Down
5 changes: 4 additions & 1 deletion src/LecueNote/components/WriteNote/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import GraphemeSplitter from 'grapheme-splitter';
import { useEffect, useState } from 'react';

import { WriteNoteProps } from '../../type/lecueNoteType';
Expand All @@ -13,6 +14,8 @@ function WriteNote({
}: WriteNoteProps) {
const nickname = '와라라라랄라';

// 이모지 글자 수 세기 관련 라이브러리
const split = new GraphemeSplitter();
const today = new Date();
const [dateArr, setDateArr] = useState([0, 0, 0]);

Expand All @@ -33,7 +36,7 @@ function WriteNote({
<S.Date>
{dateArr[0]}.{dateArr[1]}.{dateArr[2]}
</S.Date>
<S.Counter>({contents.length}/1000)</S.Counter>
<S.Counter>({split.splitGraphemes(contents).length}/1000)</S.Counter>
</S.BottomContentsWrapper>
</S.LecueNote>
<S.Notice>*욕설/비속어는 자동 필터링됩니다.</S.Notice>
Expand Down
11 changes: 8 additions & 3 deletions src/components/common/Button/Button.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import styled from '@emotion/styled';

export type ButtonStyle = 'choose' | 'complete';

export const CustomButton = styled.button<{ variant: ButtonStyle }>`
export const CustomButton = styled.button<{
variant: ButtonStyle;
$bookBackgroundColor?: string;
}>`
width: 100%;
height: 6rem;
border-radius: 0.625rem;
background-color: ${({ theme, variant }) =>
variant === 'choose' ? theme.colors.key : theme.colors.BG};
background-color: ${({ theme, variant, $bookBackgroundColor }) =>
variant === 'choose' || $bookBackgroundColor === '#191919'
? theme.colors.key
: theme.colors.BG};
color: ${({ theme }) => theme.colors.white};
${({ theme }) => theme.fonts.Head2_SB_18};
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ export interface ButtonProps
'type' | 'disabled' | 'onClick'
> {
variant: S.ButtonStyle;
backgroundColor?: string;
children: ReactNode;
}

function Button(props: ButtonProps) {
const { children, onClick, disabled, variant } = props;
const { children, onClick, disabled, variant, backgroundColor } = props;
return (
<S.CustomButton
type="button"
onClick={onClick}
disabled={disabled}
variant={variant}
$bookBackgroundColor={backgroundColor}
>
{children}
</S.CustomButton>
Expand Down
30 changes: 29 additions & 1 deletion src/components/common/Modal/CommonModalForm/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { MODAL_CONTETNS } from '../constants/ModalContents';
import * as S from './CommonModalForm.style';
Expand All @@ -9,7 +10,30 @@ interface CommonModalFormProps {
}

function CommonModalForm({ onClose, category }: CommonModalFormProps) {
const navigate = useNavigate();
const [idx, setIdx] = useState(0);

const handleClickRightBtn = () => {
onClose();
switch (category) {
case 'note_complete':
break;
case 'note_escape':
break;
case 'book_escape':
break;
case 'book_create':
break;
case 'book_delete':
break;
case 'login':
navigate('/login');
break;
default:
break;
}
};

useEffect(() => {
switch (category) {
case 'note_complete':
Expand Down Expand Up @@ -47,7 +71,11 @@ function CommonModalForm({ onClose, category }: CommonModalFormProps) {
</S.Button>
)}

<S.Button type="button" variant="continue" onClick={onClose}>
<S.Button
type="button"
variant="continue"
onClick={handleClickRightBtn}
>
{MODAL_CONTETNS[idx].rightBtn}
</S.Button>
</S.BtnWrapper>
Expand Down
Loading

0 comments on commit 5bafcc6

Please sign in to comment.