-
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
e16ac52
commit c1e86fc
Showing
6 changed files
with
152 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { StoryObj, Meta } from '@storybook/react'; | ||
import { Box, Checkbox, CheckboxProps, Text } from '@ignite-ui/react'; | ||
import { StoryFnReactReturnType } from '@storybook/react/dist/ts3.9/client/preview/types'; | ||
|
||
export default { | ||
title: 'Form/Checkbox', | ||
component: Checkbox, | ||
args: {}, | ||
decorators: [ | ||
(Story: () => StoryFnReactReturnType) => { | ||
return ( | ||
<Box | ||
as="label" | ||
css={{ display: 'flex', flexDirection: 'row', gap: '$2' }} | ||
> | ||
{Story()} | ||
<Text size="sm">Accept terms of use</Text> | ||
</Box> | ||
); | ||
}, | ||
], | ||
} as Meta<CheckboxProps>; | ||
|
||
export const Primary: StoryObj<CheckboxProps> = {}; |
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,16 @@ | ||
import { Check } from 'phosphor-react'; | ||
import { ComponentProps } from 'react'; | ||
import { CheckboxContainer, CheckboxIndicator } from './styles'; | ||
|
||
export function Checkbox() { | ||
return ( | ||
<CheckboxContainer> | ||
<CheckboxIndicator asChild> | ||
<Check weight="bold" /> | ||
</CheckboxIndicator> | ||
</CheckboxContainer> | ||
); | ||
} | ||
|
||
export interface CheckboxProps | ||
extends ComponentProps<typeof CheckboxContainer> {} |
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,56 @@ | ||
import * as Checkbox from '@radix-ui/react-checkbox'; | ||
import { styled, keyframes } from '../../styles'; | ||
|
||
export const CheckboxContainer = styled(Checkbox.Root, { | ||
all: 'unset', | ||
height: '$6', | ||
width: '$6', | ||
borderRadius: '$xs', | ||
backgroundColor: '$gray900', | ||
cursor: 'pointer', | ||
overflow: 'hidden', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
border: '2px solid $gray900', | ||
|
||
'&:focus': { | ||
border: '2px solid $ignite300', | ||
}, | ||
|
||
'&[data-state="checked"]': { | ||
backgroundColor: '$ignite300', | ||
}, | ||
}); | ||
|
||
const slidIn = keyframes({ | ||
from: { | ||
transform: 'translateY(-100%)', | ||
}, | ||
to: { | ||
transform: 'translateY(0)', | ||
}, | ||
}); | ||
|
||
const slidOut = keyframes({ | ||
from: { | ||
transform: 'translateY(0)', | ||
}, | ||
to: { | ||
transform: 'translateY(-100%)', | ||
}, | ||
}); | ||
|
||
export const CheckboxIndicator = styled(Checkbox.CheckboxIndicator, { | ||
color: '$white', | ||
height: '$4', | ||
width: '$4', | ||
|
||
'&[data-state="checked"]': { | ||
animation: `${slidIn} 200ms ease-out`, | ||
}, | ||
|
||
'&[data-state="unchecked"]': { | ||
animation: `${slidOut} 200ms ease-out`, | ||
}, | ||
}); |
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