-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from woowacourse-teams/fix/553-weird-gap-betw…
…een-buttons 홈 화면의 아이콘 버튼 레이아웃 조정 및 리팩토링
- Loading branch information
Showing
11 changed files
with
157 additions
and
274 deletions.
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 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 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 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,25 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { FaShare } from 'react-icons/fa'; | ||
import IconButton from './IconButton'; | ||
|
||
type Story = StoryObj<typeof IconButton>; | ||
|
||
const meta: Meta<typeof IconButton> = { | ||
title: 'IconButton', | ||
component: IconButton, | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: <FaShare />, | ||
}, | ||
}; | ||
|
||
export const WithLabel: Story = { | ||
args: { | ||
children: <FaShare />, | ||
label: '공유', | ||
}, | ||
}; |
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,36 @@ | ||
import type { ComponentPropsWithoutRef } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
type IconButtonProps = ComponentPropsWithoutRef<'button'> & { | ||
label?: string; | ||
}; | ||
|
||
const IconButton = (props: IconButtonProps) => { | ||
const { label, children, ...restProps } = props; | ||
|
||
return ( | ||
<Container aria-label={label} {...restProps}> | ||
<Icon>{children}</Icon> | ||
|
||
{label && <Label>{label}</Label>} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default IconButton; | ||
|
||
const Container = styled.button` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
`; | ||
|
||
const Icon = styled.div` | ||
font-size: ${({ theme }) => theme.fontSize['4xl']}; | ||
& > * { | ||
display: block; | ||
} | ||
`; | ||
|
||
const Label = styled.span``; |
Oops, something went wrong.