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] 참여자 입금 상태, 참여자 이름 Chip 컴포넌트 구현 #570

Merged
merged 6 commits into from
Sep 21, 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
3 changes: 3 additions & 0 deletions client/src/assets/image/check.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 client/src/assets/image/x.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type {Meta, StoryObj} from '@storybook/react';

import DepositCheck from '@HDcomponents/DepositCheck/DepositCheck';

const meta = {
title: 'Components/DepositCheck',
component: DepositCheck,
tags: ['autodocs'],
parameters: {
layout: 'centered',
},
argTypes: {
isDeposited: {
description: '',
control: {type: 'boolean'},
},
},
args: {
isDeposited: false,
},
} satisfies Meta<typeof DepositCheck>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Playground: Story = {};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {css} from '@emotion/react';

import {WithTheme} from '@components/Design/type/withTheme';
Copy link
Contributor

Choose a reason for hiding this comment

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

활용해주어서 고마어용~~

사실은 이런 타입 만든게 반복되니까 하나로 뭉쳐서 쓰자가 목적이었는데요. 이번에 용어 정리를 하면서 eventId -> eventToken으로 바뀌게 되었어요. 그리고 이 eventId라는 프로퍼티도 WIthEventId라는 타입으로 WithEvent와 동일한 형태로 사용할 수 있었는데요. 한번에 바꿀 수 있다는 점에서 유용함을 느꼈씁니다.!!

Copy link
Contributor

Choose a reason for hiding this comment

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

오..! 이런 것도 있었구나. 모르고 있었는데 활용하면 너무 좋을 것 같아요!


import {DepositCheckStyleProps} from './DepositCheck.type';

export const DepositCheckStyle = ({theme, isDeposited}: WithTheme<DepositCheckStyleProps>) =>
css({
display: 'flex',
alignItems: 'center',
gap: '0.125rem',
border: `1px solid ${isDeposited ? theme.colors.primary : theme.colors.gray}`,
borderRadius: '0.5rem',
padding: '0.25rem 0.375rem',
height: '1.25rem',

'.deposit-check-text': {
color: isDeposited ? theme.colors.primary : theme.colors.gray,
paddingTop: '0.0625rem',
},
Comment on lines +17 to +20
Copy link
Contributor

Choose a reason for hiding this comment

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

이런 식으로도 스타일을 적용할 수 있군요! NEW지식 습득.. 그런데 혹시 클래스로 스타일을 적용한 이유가 있을까요 ?! 제 추측으로는 하나의 css로 자식에 있는 Text까지 스타일을 적용하려고 해서 나눠진 것 같은데욧. color는 Text 컴포넌트에 준비되어있는 컬러 props를 사용하는 건 어떨지 제안드려봅니다!~ 굳이 싶다면 pass~~~!!

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @jsxImportSource @emotion/react */
import {useTheme} from '@components/Design';

import Icon from '../Icon/Icon';
import Text from '../Text/Text';

import {DepositCheckStyle} from './DepositCheck.style';
import {DepositCheckProps} from './DepositCheck.type';

const DepositCheck: React.FC<DepositCheckProps> = ({isDeposited = false}: DepositCheckProps) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

꼼꼼한 default ~~ 👍

const {theme} = useTheme();
return (
<div css={DepositCheckStyle({theme, isDeposited})}>
<Text size="tiny" className="deposit-check-text">
입금
</Text>
<Icon iconType={isDeposited ? 'check' : 'x'}></Icon>
</div>
);
};
export default DepositCheck;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface DepositCheckStyleProps {
isDeposited: boolean;
}

export interface DepositCheckCustomProps {
isDeposited: boolean;
}

export type DepositCheckOptionProps = DepositCheckStyleProps & DepositCheckCustomProps;
Comment on lines +1 to +9
Copy link
Contributor

Choose a reason for hiding this comment

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

isDeposited 프로퍼티가 DepositCheckStyleProps와 DepositCheckCustomProps에도 존재하는데 둘을 다시 &로 얽는게 혼란스러울 수도 있을 것 같은데요.

다른 방법을 생각해보자면 style에도 필요하고 이 컴포넌트가 받는 props에도 필요하다면 With~처럼 타입을 만들어서 사용해도 좋을 것 같구요.


export type DepositCheckProps = React.ComponentProps<'div'> & DepositCheckOptionProps;
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const meta = {
iconType: {
description: '',
control: {type: 'select'},
options: ['inputDelete', 'buljusa', 'rightChevron', 'search', 'confirm', 'error', 'trash'],
options: ['inputDelete', 'buljusa', 'rightChevron', 'search', 'confirm', 'error', 'trash', 'check', 'x'],
Copy link
Contributor

Choose a reason for hiding this comment

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

'x'가 정말 직관적이네요. ㅋㅋㅋ 👍

image

Copy link
Contributor

Choose a reason for hiding this comment

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

나중의 일이지만 사용하지 않는 아이콘 정리해봐도 좋을 것 같아요!

},
},
args: {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/Design/components/Icon/Icon.style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {css} from '@emotion/react';

import {Theme} from '@theme/theme.type';
import {ColorKeys} from '@token/colors';

import {IconColor, IconStylePropsWithTheme, IconType} from './Icon.type';
Expand All @@ -13,6 +12,8 @@ const ICON_DEFAULT_COLOR: Record<IconType, IconColor> = {
confirm: 'complete',
error: 'warn',
trash: 'white',
check: 'primary',
x: 'gray',
toss: 'white',
meatballs: 'black',
};
Expand Down
4 changes: 4 additions & 0 deletions client/src/components/Design/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import Confirm from '@assets/image/confirm.svg';
import Trash from '@assets/image/trash.svg';
import Search from '@assets/image/search.svg';
import RightChevron from '@assets/image/rightChevron.svg';
import Check from '@assets/image/check.svg';
import X from '@assets/image/x.svg';
import Meatballs from '@assets/image/meatballs.svg';
import {IconProps} from '@HDcomponents/Icon/Icon.type';
import {useTheme} from '@theme/HDesignProvider';
Expand All @@ -22,6 +24,8 @@ const ICON = {
error: <Error />,
confirm: <Confirm />,
trash: <Trash />,
check: <Check />,
x: <X />,
toss: <img src={Toss} width="24" height="24" alt="toss icon" />,
meatballs: <Meatballs />,
};
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Design/components/Icon/Icon.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type IconType =
| 'error'
| 'confirm'
| 'trash'
| 'check'
| 'x'
| 'toss'
| 'meatballs';

Expand Down
Loading