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

[FE] 스토리북의 버그를 고치고, 관련 컴포넌트를 일부 수정한다. #768

Merged
merged 17 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stories


private*
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
test-results/
playwright-report/
blob-report/
playwright/.cache/
4 changes: 3 additions & 1 deletion frontend/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const decorator = Story => (
<Global
styles={css`
${normalize}
font-size: 10px;
html {
font-size: 62.5%;
}
`}
/>
<ThemeProvider theme={theme}>
Expand Down
68 changes: 0 additions & 68 deletions frontend/playwright-report/index.html

This file was deleted.

4 changes: 2 additions & 2 deletions frontend/src/apis/checklist.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetcher from '@/apis/fetcher';
import { BASE_URL, ENDPOINT } from '@/apis/url';
import { ChecklistCustom, ChecklistInfo, ChecklistPostForm } from '@/types/checklist';
import { ChecklistInfo, ChecklistPostForm, ChecklistSelectedQuestions } from '@/types/checklist';
import { mapObjNullToUndefined, mapObjUndefinedToNull } from '@/utils/typeFunctions';

export const getChecklistQuestions = async () => {
Expand Down Expand Up @@ -46,7 +46,7 @@ export const deleteChecklist = async (id: number) => {
return response;
};

export const putCustomChecklist = async (questionIds: ChecklistCustom) => {
export const putCustomChecklist = async (questionIds: ChecklistSelectedQuestions) => {
const response = await fetcher.put({ url: BASE_URL + ENDPOINT.CHECKLIST_CUSTOM, body: questionIds });

return response;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Answer/AnswerIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const AnswerColor: Record<AnswerType, { selected: string; notSelected?: string }
},
NONE: {
selected: theme.palette.grey300,
notSelected: theme.palette.grey300,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const S = {
flex-direction: row;
align-items: center;
box-sizing: border-box;
border-bottom: 0.1rem solid ${({ theme }) => theme.palette.grey200};
`,
Title: styled.div`
display: flex;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import Tabs from '@/components/_common/Tabs/Tabs';
import { findCategoryClassNameByName } from '@/constants/category';
import useChecklistQuestionSelectStore from '@/store/useChecklistQuestionSelectStore';

export const ChecklistCustomTabs = () => {
export const ChecklistQuestionSelectTabs = () => {
const { validCategory: validCategoryEditMode } = useChecklistQuestionSelectStore();

const checklistCustomTabs = validCategoryEditMode.map(category => ({
const checklistQuestionSelectTabs = validCategoryEditMode.map(category => ({
id: category.categoryId,
name: category.categoryName as string,
className: findCategoryClassNameByName(category.categoryName),
}));

return <Tabs tabList={checklistCustomTabs} />;
return <Tabs tabList={checklistQuestionSelectTabs} />;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react';

import QuestionCardList from '@/components/ChecklistCustom/QuestionCardList/QuestionCardList';
import QuestionCardList from '@/components/ChecklistQuestionSelect/QuestionCardList/QuestionCardList';
import theme from '@/styles/theme';

import mobileDecorator from '../../../../.storybook/common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from '@emotion/styled';

import Divider from '@/components/_common/Divider/Divider';
import QuestionSelectCard from '@/components/ChecklistCustom/QuestionSelectCard/QuestionSelectCard';
import QuestionSelectCard from '@/components/ChecklistQuestionSelect/QuestionSelectCard/QuestionSelectCard';
import { ChecklistQuestionWithIsSelected } from '@/types/checklist';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from '@emotion/styled';

import CounterBox from '@/components/_common/CounterBox/CounterBox';
import { useTabContext } from '@/components/_common/Tabs/TabContext';
import QuestionCardList from '@/components/ChecklistCustom/QuestionCardList/QuestionCardList';
import QuestionCardList from '@/components/ChecklistQuestionSelect/QuestionCardList/QuestionCardList';
import useChecklistQuestionSelectStore from '@/store/useChecklistQuestionSelectStore';

const QuestionListTemplate = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from '@emotion/styled';

import Checkbox from '@/components/_common/Checkbox/Checkbox';
import FlexBox from '@/components/_common/FlexBox/FlexBox';
import { useTabContext } from '@/components/_common/Tabs/TabContext';
import useChecklistQuestionSelect from '@/hooks/useChecklistQuestionSelect';
import { flexCenter } from '@/styles/common';
Expand All @@ -18,18 +19,13 @@ const QuestionSelectCard = ({ question }: { question: ChecklistQuestionWithIsSel
return (
<S.Container isChecked={isSelected} onClick={handleCheckQuestion}>
<S.FlexColumn>
<S.FlexRow>
<FlexBox.Vertical>
<S.Title>{title}</S.Title>
</S.FlexRow>
{subtitle && <S.Subtitle>{subtitle}</S.Subtitle>}
{subtitle && <S.Subtitle>{subtitle}</S.Subtitle>}
</FlexBox.Vertical>
</S.FlexColumn>
<S.CheckBoxContainer>
<Checkbox
iconType="plus"
isChecked={isSelected}
setIsChecked={handleCheckQuestion}
onClick={handleCheckQuestion}
/>
<Checkbox iconType="plus" isChecked={isSelected} onClick={handleCheckQuestion} />
</S.CheckBoxContainer>
</S.Container>
);
Expand Down Expand Up @@ -66,8 +62,6 @@ const S = {
gap: 1rem;
`,
Subtitle: styled.div`
padding-left: 2rem;

color: ${({ theme }) => theme.palette.grey500};
font-size: ${({ theme }) => theme.text.size.small};
word-break: keep-all;
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/components/NewChecklist/NewRoomInfoForm/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import styled from '@emotion/styled';
import Button from '@/components/_common/Button/Button';
import FormField from '@/components/_common/FormField/FormField';
import Header from '@/components/_common/Header/Header';
import RadioGroup from '@/components/_common/RadioGroup/RadioGroup';
import { flexCenter, title4 } from '@/styles/common';

const FormStyled = {
Expand Down Expand Up @@ -56,14 +55,5 @@ const FormStyled = {
${title4}
white-space: pre;
`,

RadioGroup: styled(RadioGroup)<{ width?: string }>`
${({ width }) => (width ? `width:${width};` : '')}
flex: 1 0 auto;

${flexCenter}
font-size: ${({ theme }) => theme.text.size.xSmall};
column-gap: 0.7rem;
`,
};
export default FormStyled;
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const OptionAllSelectBox = () => {
{/*전체 선택 버튼*/}
<Checkbox
isChecked={selectedOptionActions.isAllSelected()}
setIsChecked={handleToggleAllSelect}
onClick={handleToggleAllSelect}
color={theme.palette.yellow500}
hoverColor={theme.palette.yellow600}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import styled from '@emotion/styled';
import type { Meta, StoryObj } from '@storybook/react';

import OptionButton from '@/components/NewChecklist/Option/OptionButton/OptionButton';
Expand All @@ -7,38 +6,22 @@ import { OPTIONS } from '@/constants/options';
const meta = {
title: 'components/OptionButton',
component: OptionButton,
parameters: {
docs: {
description: {
component: 'Option버튼은 체크리스트의 다양한 옵션 아이템들을 선택할 수 있는 컴포넌트입니다.',
},
},
args: {
size: '8rem',
},
argTypes: {
option: { control: { disable: true } },
},
} satisfies Meta<typeof OptionButton>;
export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: { option: OPTIONS[0], isSelected: true },
decorators: [
Story => (
<S.Wrapper>
<div style={{ width: '80px', height: '80px' }}>
<Story />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div style={{ width: '80px', height: '80px' }}>
<div style={{ width: '8rem', height: '8rem' }}>

</S.Wrapper>
</div>
),
],
};
} satisfies Meta<typeof OptionButton>;

export default meta;

type Story = StoryObj<typeof meta>;

const S = {
Wrapper: styled.div`
display: flex;
width: 8rem;
height: 8rem;
align-items: center;
justify-content: center;
`,
export const Good: Story = {
args: { option: OPTIONS[1], isSelected: true },
};
25 changes: 19 additions & 6 deletions frontend/src/components/_common/Accordion/Accordion.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import styled from '@emotion/styled';
import type { Meta, StoryObj } from '@storybook/react';

import Accordion from '@/components/_common/Accordion/Accordion';
import { flexSpaceBetween, title4 } from '@/styles/common';
import theme from '@/styles/theme';

/**
Expand Down Expand Up @@ -29,16 +31,27 @@ export const Default: Story = {
render: () => {
return (
<Accordion totalCount={1}>
<Accordion.header id={1} text="청결도" />
<Accordion.header id={1} text="제목" />
<Accordion.body id={1}>
<ul>
<li>list 1</li>
<li>list 2</li>
<li>list 3</li>
</ul>
<S.Content>카테고리의 내용이 있습니다.</S.Content>
</Accordion.body>
</Accordion>
);
},
args: { totalCount: 1 },
};

const S = {
Content: styled.div`
${flexSpaceBetween}
width: 100%;
padding: 1rem;
gap: 1rem;

${title4}
background-color: ${({ theme }) => theme.palette.white};
flex-direction: row;
align-items: center;
box-sizing: border-box;
`,
};
31 changes: 20 additions & 11 deletions frontend/src/components/_common/Accordion/AccordionBody.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from '@emotion/styled';
import { useRef } from 'react';
import { useEffect, useRef, useState } from 'react';

import { useAccordionContext } from '@/components/_common/Accordion/AccordionContext';

Expand All @@ -9,29 +9,38 @@ interface Props {
}

const AccordionBody = ({ children, id }: Props) => {
const bodyRef = useRef(null);
const bodyRef = useRef<HTMLDivElement>(null);
const { isAccordionOpen } = useAccordionContext();

const isCurrentAccordionOpen = isAccordionOpen(id);
const [maxHeight, setMaxHeight] = useState(0);

useEffect(() => {
if (bodyRef.current) {
if (isCurrentAccordionOpen) {
setMaxHeight(bodyRef.current.scrollHeight);
} else {
setMaxHeight(0);
}
}
}, [isCurrentAccordionOpen]);

return (
<S.Container ref={bodyRef} isOpen={isCurrentAccordionOpen}>
<S.Container ref={bodyRef} isOpen={isCurrentAccordionOpen} maxHeight={maxHeight}>
{children}
</S.Container>
);
};

export default AccordionBody;

const S = {
Container: styled.div<{ isOpen: boolean }>`
display: ${({ isOpen }) => (isOpen ? 'block' : 'none')};
Container: styled.div<{ isOpen: boolean; maxHeight: number }>`
overflow: hidden;
margin-top: 1rem;
max-height: ${({ maxHeight }) => maxHeight}px;
transition: max-height 0.4s cubic-bezier(0.15, 0.1, 0.25, 1);
border-radius: 1.2rem;

background-color: ${({ theme }) => theme.palette.white};
max-height: ${({ isOpen }) => (isOpen ? '100rem' : '0')};
transition: max-height 0.2s cubic-bezier(0.15, 0.1, 0.25, 1);
border-radius: 1.2rem;
`,
};

export default AccordionBody;
12 changes: 5 additions & 7 deletions frontend/src/components/_common/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ export default meta;
type Story = StoryObj<typeof meta>;

export const UnChecked: Story = {
args: {
isChecked: true,
},

render: () => {
const [isChecked, setIsChecked] = useState(false);
return (
<Checkbox
isChecked={isChecked}
onClick={() => setIsChecked(isChecked => !isChecked)}
setIsChecked={() => setIsChecked(isChecked => !isChecked)}
/>
);
return <Checkbox isChecked={isChecked} onClick={() => setIsChecked(isChecked => !isChecked)} />;
},
};

Expand Down
Loading
Loading