-
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5590e69
chore: 절대경로 플러그인 설치
chlwlstlf 96879aa
fix: 스토리북에서 절대경로 설정
chlwlstlf 255a08b
fix: theme 적용을 위한 decorator 추가
chlwlstlf bf7b620
feat: IconButton 공통 컴포넌트 생성
chlwlstlf 3fc8dbf
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-c…
chlwlstlf 13aa204
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-c…
chlwlstlf dcaab25
Merge branch 'develop' of https://github.com/woowacourse-teams/2024-c…
chlwlstlf e173f08
style: esmodule로 변경
chlwlstlf b62ab6e
feat: IconButton div에서 button으로 변경, aria-label 추가
chlwlstlf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
frontend/src/components/common/iconButton/IconButton.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}; |
40 changes: 40 additions & 0 deletions
40
frontend/src/components/common/iconButton/IconButton.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Icon from "../icon/Icon"; | ||
import styled from "styled-components"; | ||
|
||
export const IconButtonContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const IconButtonBox = styled.button` | ||
cursor: pointer; | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
width: 50px; | ||
height: 50px; | ||
|
||
background-color: transparent; | ||
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}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { ButtonHTMLAttributes } from "react"; | ||
import * as S from "@/components/common/iconButton/IconButton.style"; | ||
import IconKind from "@/@types/icon"; | ||
|
||
interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { | ||
iconKind: IconKind; | ||
text?: string; | ||
} | ||
|
||
const IconButton = ({ iconKind, text = "", ...rest }: IconButtonProps) => { | ||
return ( | ||
<S.IconButtonContainer> | ||
<S.IconButtonBox aria-label="Icon Button" {...rest}> | ||
<S.StyledIcon kind={iconKind} /> | ||
</S.IconButtonBox> | ||
{text !== "" && <S.IconButtonText>{text}</S.IconButtonText>} | ||
</S.IconButtonContainer> | ||
); | ||
}; | ||
|
||
export default IconButton; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
컴포넌트 이름도 IconButton인 만큼 div 태그보다는 button 태그로 나타내는 건 어떨까요?
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.
넵 button이라는걸 잘 보여줄 수 있을 것 같네요! 수정하였습니다ㅎㅎ