-
Notifications
You must be signed in to change notification settings - Fork 8
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] feat: IconButton 공통 컴포넌트 만들기(#48) #64
Changes from 6 commits
5590e69
96879aa
255a08b
bf7b620
3fc8dbf
13aa204
dcaab25
e173f08
b62ab6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import GlobalStyles from "../src/styles/globalStyles"; | ||
import { theme } from "../src/styles/theme"; | ||
import type { Preview } from "@storybook/react"; | ||
import React from "react"; | ||
import { ThemeProvider } from "styled-components"; | ||
|
||
const preview: Preview = { | ||
parameters: { | ||
controls: { | ||
matchers: { | ||
color: /(background|color)$/i, | ||
date: /Date$/i, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const decorators = [ | ||
(Story) => ( | ||
<ThemeProvider theme={theme}> | ||
<GlobalStyles /> | ||
<Story /> | ||
</ThemeProvider> | ||
), | ||
]; | ||
export default preview; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import IconButton from "./IconButton"; | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
const meta = { | ||
title: "common/IconButton", | ||
component: IconButton, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: "아이콘 버튼 컴포넌트", | ||
}, | ||
}, | ||
}, | ||
argTypes: { | ||
iconKind: { | ||
description: "아이콘 종류", | ||
control: { type: "select" }, | ||
options: ["person", "link", "calendar"], | ||
}, | ||
text: { | ||
description: "아이콘 버튼 텍스트", | ||
control: { type: "text" }, | ||
}, | ||
}, | ||
} satisfies Meta<typeof IconButton>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
iconKind: "person", | ||
text: "person", | ||
}, | ||
}; | ||
|
||
export const WithoutText: Story = { | ||
args: { | ||
iconKind: "link", | ||
}, | ||
}; | ||
|
||
export const WithDifferentIcon: Story = { | ||
args: { | ||
iconKind: "calendar", | ||
text: "calendar", | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||
import Icon from "../icon/Icon"; | ||||||
import styled from "styled-components"; | ||||||
|
||||||
export const IconButtonContainer = styled.div` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 컴포넌트 이름도 IconButton인 만큼 div 태그보다는 button 태그로 나타내는 건 어떨까요?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 button이라는걸 잘 보여줄 수 있을 것 같네요! 수정하였습니다ㅎㅎ |
||||||
display: flex; | ||||||
flex-direction: column; | ||||||
align-items: center; | ||||||
justify-content: center; | ||||||
`; | ||||||
|
||||||
export const IconButtonImg = styled.div` | ||||||
cursor: pointer; | ||||||
|
||||||
display: flex; | ||||||
align-items: center; | ||||||
justify-content: center; | ||||||
|
||||||
width: 50px; | ||||||
height: 50px; | ||||||
|
||||||
border: 1px solid ${({ theme }) => theme.COLOR.grey1}; | ||||||
border-radius: 15px; | ||||||
box-shadow: 0 4px 4px rgb(0 0 0 / 10%); | ||||||
|
||||||
&:active { | ||||||
position: relative; | ||||||
top: 3px; | ||||||
box-shadow: 0 1px 1px rgb(0 0 0 / 10%); | ||||||
} | ||||||
`; | ||||||
|
||||||
export const StyledIcon = styled(Icon)` | ||||||
width: 30px; | ||||||
height: 30px; | ||||||
`; | ||||||
|
||||||
export const IconButtonText = styled.p` | ||||||
font: ${({ theme }) => theme.TEXT.xSmall}; | ||||||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react"; | ||
import * as S from "@/components/common/iconButton/IconButton.style"; | ||
import IconKind from "@/@types/icon"; | ||
|
||
interface IconButtonProps { | ||
iconKind: IconKind; | ||
text?: string; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IconButtonProps에 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
const IconButton = ({ iconKind, text = "" }: IconButtonProps) => { | ||
return ( | ||
<S.IconButtonContainer> | ||
<S.IconButtonImg> | ||
<S.StyledIcon kind={iconKind} /> | ||
</S.IconButtonImg> | ||
{text !== "" && <S.IconButtonText>{text}</S.IconButtonText>} | ||
</S.IconButtonContainer> | ||
); | ||
}; | ||
|
||
export default IconButton; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 왜 ESM 모듈이 아니라 CJS 모듈 방식을 이용했나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 코드 복붙했습니다.. 수정했습니다 감사합니다!!