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

fix-fe: ProcessColumn QA #428

Merged
merged 5 commits into from
Aug 16, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Meta, StoryObj } from '@storybook/react';
import ProcessDescription from './index';

const meta: Meta<typeof ProcessDescription> = {
title: 'Components/ProcessColumn/ProcessDescription',
component: ProcessDescription,
parameters: {
layout: 'centered',
docs: {
description: {
component: '프로세스의 설명을 렌더링합니다. 더보기 버튼을 클릭하면 설명이 전체로 펼쳐집니다.',
},
},
},
tags: ['autodocs'],
decorators: [
(Child) => (
<div
style={{
width: '25rem',
}}
>
<Child />
</div>
),
],
args: {
description: '프로세스 설명입니다.',
},
};

export default meta;
type Story = StoryObj<typeof ProcessDescription>;

export const Default: 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
export const Default: Story = {};
export const Default: Story = {};
export const LongDescription: Story = {
args: { description: '서류 접수 단계인가요? 아닌가요? 모르겠어요? 궁금해요?' },
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useLayoutEffect, useRef, useState } from 'react';
import S from './style';

interface ProcessDescriptionProps {
description: string;
}

export default function ProcessDescription({ description }: ProcessDescriptionProps) {
const [isOverflow, setOverflow] = useState(false);
const [showMore, setShowMore] = useState(false);

const toggleShowMore = () => setShowMore((prev) => !prev);
Comment on lines +10 to +12
Copy link
Contributor

Choose a reason for hiding this comment

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

"더보기" 버튼 구현을 무척 깔끔하게 잘 해주신 것 같습니다! 👍

image


const descriptionRef = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
if (descriptionRef.current) {
setOverflow(descriptionRef.current.scrollWidth > descriptionRef.current.clientWidth);
}
}, [description]);

return (
<S.Container showMore={showMore}>
<S.Description
ref={descriptionRef}
showMore={showMore}
>
{description}
</S.Description>
{isOverflow && <S.MoreButton onClick={toggleShowMore}>{showMore ? '접기' : '더보기'}</S.MoreButton>}
</S.Container>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { css } from '@emotion/react';
import styled from '@emotion/styled';

const Container = styled.div<{ showMore: boolean }>`
width: 100%;
display: flex;
align-items: baseline;

${({ showMore }) =>
showMore &&
css`
flex-direction: column;
align-items: flex-end;
`}
`;

const Description = styled.p<{ showMore: boolean }>`
width: 100%;

${({ theme }) => theme.typography.common.block};
color: ${({ theme }) => theme.baseColors.grayscale[700]};
margin-bottom: 0;
padding: 0.4rem;

${({ showMore }) =>
!showMore &&
css`
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`}
`;

const MoreButton = styled.button`
${({ theme }) => theme.typography.common.block};
color: ${({ theme }) => theme.baseColors.grayscale[500]};

white-space: nowrap;
margin: 0;
`;

const S = {
Container,
Description,
MoreButton,
};

export default S;
2 changes: 2 additions & 0 deletions frontend/src/components/dashboard/ProcessColumn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useModal } from '@contexts/ModalContext';

import S from './style';
import ApplicantCard from '../ApplicantCard';
import ProcessDescription from './ProcessDescription/index';

interface ProcessColumnProps {
process: Process;
Expand Down Expand Up @@ -38,6 +39,7 @@ export default function ProcessColumn({ process }: ProcessColumnProps) {
<S.ProcessWrapper>
<S.Header>
<S.Title>{process.name}</S.Title>
<ProcessDescription description={process.description} />
</S.Header>
<S.ApplicantList>
{process.applicants.map(
Expand Down
21 changes: 13 additions & 8 deletions frontend/src/components/dashboard/ProcessColumn/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { hideScrollBar } from '@styles/utils';

const ProcessWrapper = styled.section`
width: 100%;
min-width: 25rem;
min-width: 28rem;
max-width: 28rem;

height: 100%;
padding: 20px 12px 12px 12px;
border-radius: 8px;
border: 1px solid ${({ theme }) => theme.baseColors.grayscale[400]};
padding: 1.2rem;
border-radius: 0.8rem;
border: 0.1rem solid ${({ theme }) => theme.baseColors.grayscale[400]};
background-color: ${({ theme }) => theme.baseColors.grayscale[50]};

overflow-y: scroll;
Expand All @@ -17,16 +19,19 @@ const ProcessWrapper = styled.section`

const Header = styled.header`
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: space-between;
gap: 0.8rem;

padding: 8px 4px;
margin-bottom: 20px;
border-bottom: 1px solid ${({ theme }) => theme.baseColors.grayscale[400]};
padding: 0.8rem 0.4rem;
margin-bottom: 2rem;
border-bottom: 0.1rem solid ${({ theme }) => theme.baseColors.grayscale[400]};
`;

const Title = styled.h2`
${({ theme }) => theme.typography.heading[500]};
padding: 4px;
padding: 0.4rem;
`;

const ApplicantList = styled.ul`
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/mocks/processMockData.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
}
],
"name": "지원서",
"description": "지원서를 확인한다."
"description": "지원서를 확인한다.지원서를 확인한다.지원서를 확인한다.지원서를 확인한다.지원서를 확인한다.지원서를 확인한다.지원서를 확인한다."
},
{
"processId": 4,
Expand Down
Loading