Skip to content

Commit

Permalink
feat: ListComponent 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
Todari committed Aug 5, 2024
1 parent 9876517 commit 41206fd
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HDesign/.storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
/** @jsxImportSource @emotion/react */

import type {Preview} from '@storybook/react';
import {HDesignProvider} from '../src/theme/HDesignProvider';
Expand Down
1 change: 1 addition & 0 deletions HDesign/src/assets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export {default as Buljusa} from '@assets/buljusa.svg';
export {default as Arrow} from '@assets/arrow.svg';
export {default as Error} from '@assets/error.svg';
export {default as Trash} from '@assets/trash.svg';
export {default as RightChevron} from '@assets/rightChevron.svg';
3 changes: 3 additions & 0 deletions HDesign/src/assets/rightChevron.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion HDesign/src/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import {forwardRef} from 'react';

import {IconButtonProps} from '@components/IconButton/IconButton.type';
import {InputDelete, Plus, Buljusa} from '@assets';
import {InputDelete, Plus, Buljusa, RightChevron, Arrow, Trash, Error} from '@assets';

const ICON = {
inputDelete: <InputDelete />,
plus: <Plus />,
buljusa: <Buljusa />,
rightChevron: <RightChevron />,
arrow: <Arrow />,
error: <Error />,
trash: <Trash />,
};

export const IconButton: React.FC<IconButtonProps> = forwardRef<HTMLButtonElement, IconButtonProps>(function Button(
Expand Down
2 changes: 1 addition & 1 deletion HDesign/src/components/IconButton/IconButton.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type IconButtonType = 'inputDelete' | 'plus' | 'buljusa';
type IconButtonType = 'inputDelete' | 'plus' | 'buljusa' | 'rightChevron' | 'arrow' | 'error' | 'trash';

export interface IconButtonStyleProps {}

Expand Down
32 changes: 32 additions & 0 deletions HDesign/src/components/ListButton/ListButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type {Meta, StoryObj} from '@storybook/react';

import ListButton from '@components/ListButton/ListButton';

const meta = {
title: 'Components/ListButton',
component: ListButton,
tags: ['autodocs'],
parameters: {
// layout: 'centered',
},
argTypes: {
prefix: {
description: '',
control: {type: 'text'},
},
suffix: {
description: '',
control: {type: 'text'},
},
},
args: {
prefix: '전체 μ°Έμ—¬μž',
suffix: '7λͺ…',
},
} satisfies Meta<typeof ListButton>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Playground: Story = {};
21 changes: 21 additions & 0 deletions HDesign/src/components/ListButton/ListButton.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @jsxImportSource @emotion/react */
import {css} from '@emotion/react';

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

export const listButtonStyle = (theme: Theme) =>
css({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
width: '100%',
padding: '0.375rem 1rem',
backgroundColor: theme.colors.white,

boxShadow: `0 1px 0 0 ${theme.colors.grayContainer} inset `,
});

export const textStyle = (theme: Theme) =>
css({
color: theme.colors.gray,
});
33 changes: 33 additions & 0 deletions HDesign/src/components/ListButton/ListButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** @jsxImportSource @emotion/react */
import React, {forwardRef} from 'react';

import Text from '@components/Text/Text';
import IconButton from '@components/IconButton/IconButton';
import Flex from '@components/Flex/Flex';

import {useTheme} from '@theme/HDesignProvider';

import {ListButtonProps} from './ListButton.type';
import {listButtonStyle, textStyle} from './ListButton.style';

export const ListButton: React.FC<ListButtonProps> = forwardRef<HTMLButtonElement, ListButtonProps>(function Button(
{prefix, suffix, ...htmlProps}: ListButtonProps,
ref,
) {
const {theme} = useTheme();
return (
<button css={listButtonStyle(theme)} ref={ref} {...htmlProps}>
<Text size="caption" css={textStyle(theme)}>
{prefix}
</Text>
<Flex gap="0.5rem" alignItems="center">
<Text size="caption" css={textStyle(theme)}>
{suffix}
</Text>
<IconButton iconType="rightChevron" />
</Flex>
</button>
);
});

export default ListButton;
10 changes: 10 additions & 0 deletions HDesign/src/components/ListButton/ListButton.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export interface ListButtonStyleProps {}

export interface ListButtonCustomProps {
prefix?: string;
suffix?: string;
}

export type ListButtonOptionProps = ListButtonStyleProps & ListButtonCustomProps;

export type ListButtonProps = React.ComponentProps<'button'> & ListButtonOptionProps;

0 comments on commit 41206fd

Please sign in to comment.