-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9782814
commit 9c27ebc
Showing
14 changed files
with
204 additions
and
6 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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import React from 'react' | ||
|
||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { fn } from '@storybook/test' | ||
import IconButton from '.' | ||
import { CheckIcon, MenuDotsIcon } from '../../icons' | ||
|
||
const meta = { | ||
title: 'Buttons/Icon Button', | ||
component: IconButton, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
tags: ['autodocs'], | ||
args: { onClick: fn() }, | ||
} satisfies Meta<typeof IconButton> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const Default: Story = { | ||
args: { | ||
icon: <MenuDotsIcon />, | ||
}, | ||
} | ||
|
||
export const Disabled: Story = { | ||
args: { | ||
icon: <CheckIcon />, | ||
disabled: true, | ||
}, | ||
} |
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,12 @@ | ||
import { IconButton } from '../..' | ||
import { CheckIcon, InfoIcon, MenuDotsIcon } from '../../icons' | ||
|
||
const IconButtonDemo = () => ( | ||
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px' }}> | ||
<IconButton icon={<MenuDotsIcon />} aria-label='Menu' /> | ||
<IconButton icon={<CheckIcon />} aria-label='Check' /> | ||
<IconButton icon={<InfoIcon />} aria-label='Info' disabled /> | ||
</div> | ||
) | ||
|
||
export default IconButtonDemo |
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,51 @@ | ||
# IconButton | ||
|
||
[Storybook Ref](https://wri.github.io/wri-design-systems/?path=/docs/buttons-icon-button--docs) | ||
|
||
[IconButton](https://github.com/wri/wri-design-systems/blob/main/src/components/Buttons/IconButton/IconButtonDemo.tsx) | ||
|
||
## Import | ||
|
||
```js | ||
import { IconButton } from 'wri-design-systems' | ||
``` | ||
|
||
## Usage | ||
|
||
```html | ||
<IconButton | ||
icon={<MenuDotsIcon />} | ||
aria-label='Menu' | ||
/> | ||
``` | ||
|
||
## Props | ||
|
||
```ts | ||
type IconButtonProps = Omit< | ||
ChakraButtonProps, | ||
'size' | 'variant' | 'colorPalette' | 'children' | '_loading' | ||
> & { | ||
icon: React.ReactNode | ||
disabled?: boolean | ||
} | ||
``` | ||
## Default | ||
```html | ||
<IconButton | ||
icon={<MenuDotsIcon />} | ||
aria-label='Menu' | ||
/> | ||
``` | ||
## Disabled | ||
```html | ||
<IconButton | ||
icon={<InfoIcon />} | ||
aria-label='Info' | ||
disabled | ||
/> | ||
``` |
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,17 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import React from 'react' | ||
|
||
import { StyledIconButton } from './styled' | ||
import { IconButtonProps } from './types' | ||
|
||
const IconButton = ({ icon, disabled, ...rest }: IconButtonProps) => ( | ||
<StyledIconButton | ||
aria-label={rest['aria-label']} | ||
disabled={disabled} | ||
{...rest} | ||
> | ||
{icon} | ||
</StyledIconButton> | ||
) | ||
|
||
export default IconButton |
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,51 @@ | ||
import styled from '@emotion/styled' | ||
import { Button } from '@chakra-ui/react' | ||
import { getThemedColor } from '../../../lib/theme' | ||
|
||
export const StyledIconButton = styled(Button)` | ||
width: 20px !important; | ||
padding: 0 !important; | ||
min-width: 20px !important; | ||
height: 20px; | ||
border-radius: 2px; | ||
background-color: transparent; | ||
svg { | ||
width: 15px; | ||
height: 15px; | ||
path { | ||
fill: ${getThemedColor('neutral', 800)}; | ||
} | ||
} | ||
&:hover { | ||
background-color: color-mix( | ||
in srgb, | ||
${getThemedColor('primary', 500)} 20%, | ||
transparent | ||
); | ||
} | ||
&:active { | ||
background-color: color-mix( | ||
in srgb, | ||
${getThemedColor('primary', 500)} 40%, | ||
transparent | ||
); | ||
} | ||
&:focus-visible { | ||
outline-color: ${getThemedColor('primary', 700)}; | ||
} | ||
&:disabled { | ||
background-color: transparent; | ||
svg { | ||
path { | ||
fill: ${getThemedColor('neutral', 500)}; | ||
} | ||
} | ||
} | ||
` |
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,10 @@ | ||
import React from 'react' | ||
import { ButtonProps as ChakraButtonProps } from '@chakra-ui/react' | ||
|
||
export type IconButtonProps = Omit< | ||
ChakraButtonProps, | ||
'size' | 'variant' | 'colorPalette' | 'children' | '_loading' | ||
> & { | ||
icon: React.ReactNode | ||
disabled?: boolean | ||
} |
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 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import React from 'react' | ||
|
||
import { Icon, IconProps } from '@chakra-ui/react' | ||
|
||
export const MenuDotsIcon = (props: IconProps) => ( | ||
<Icon {...props}> | ||
<svg | ||
width='16' | ||
height='16' | ||
viewBox='0 0 16 16' | ||
fill='none' | ||
xmlns='http://www.w3.org/2000/svg' | ||
> | ||
<path | ||
d='M8 16C7.45 16 6.97917 15.8042 6.5875 15.4125C6.19583 15.0208 6 14.55 6 14C6 13.45 6.19583 12.9792 6.5875 12.5875C6.97917 12.1958 7.45 12 8 12C8.55 12 9.02083 12.1958 9.4125 12.5875C9.80417 12.9792 10 13.45 10 14C10 14.55 9.80417 15.0208 9.4125 15.4125C9.02083 15.8042 8.55 16 8 16ZM8 10C7.45 10 6.97917 9.80417 6.5875 9.4125C6.19583 9.02083 6 8.55 6 8C6 7.45 6.19583 6.97917 6.5875 6.5875C6.97917 6.19583 7.45 6 8 6C8.55 6 9.02083 6.19583 9.4125 6.5875C9.80417 6.97917 10 7.45 10 8C10 8.55 9.80417 9.02083 9.4125 9.4125C9.02083 9.80417 8.55 10 8 10ZM8 4C7.45 4 6.97917 3.80417 6.5875 3.4125C6.19583 3.02083 6 2.55 6 2C6 1.45 6.19583 0.979167 6.5875 0.5875C6.97917 0.195833 7.45 0 8 0C8.55 0 9.02083 0.195833 9.4125 0.5875C9.80417 0.979167 10 1.45 10 2C10 2.55 9.80417 3.02083 9.4125 3.4125C9.02083 3.80417 8.55 4 8 4Z' | ||
fill='currentColor' | ||
/> | ||
</svg> | ||
</Icon> | ||
) |
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