This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Lukebailey/infra 386 create a a11y checkbox #53
Open
lukerohanbailey
wants to merge
32
commits into
main
Choose a base branch
from
lukebailey/infra-386-create-a-a11y-checkbox
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
17cffa8
feat: add react-aria and react-stately
lukerohanbailey 23e5e0d
feat: add simple react-aria checkbox
lukerohanbailey e254aa5
feat: add simple checkbox story
lukerohanbailey 1ce89d5
feat: add disabled and enabled checkbox styles
lukerohanbailey 5c819c1
feat: add state styling to checkbox
lukerohanbailey d86c95d
style: update All Checkbox component name to Checkbox States
lukerohanbailey 59efa9f
fix: update autoFocus attribute element to match the order on figma
lukerohanbailey c66b5cd
chore: move stitches to devdependencies
lukerohanbailey ca95774
fix: add react-aria and react-stately to build-cjs
lukerohanbailey 0a41a35
feat: add aria-label to checkbox
lukerohanbailey 93013ed
chore: add onChange handler to checkbox
lukerohanbailey 177e1c9
build: add gsap to project
lukerohanbailey 4f84d58
feat: add basic gsap setup and microinteraction to checkbox
lukerohanbailey 3c53864
build: add .vscode to .gitignore
lukerohanbailey dac2cfd
fix: remove GSAPTimeline type import
lukerohanbailey 969c328
feat: add animatiable check icon
lukerohanbailey ab4d3dc
feat: animate checkbox check icon based on isSelected state
lukerohanbailey 7bf7cdd
feat: improve checkbox animation timings
lukerohanbailey fc43aa6
Merge branch 'lukebailey/infra-387-explore-and-create-a-micro-interac…
lukerohanbailey 9d2b028
fix: destructure checkbox types from ComponentPropsWithRef, CheckboxP…
lukerohanbailey 6786ee4
fix: invalid styling
lukerohanbailey 661b8d3
Merge branch 'lukebailey/infra-386-create-a-a11y-checkbox' into lukeb…
lukerohanbailey aa97e6c
fix: aria-label console warnings
lukerohanbailey 8b505fa
feat: update checkbox animation timings
lukerohanbailey f4a25d7
Merge branch 'lukebailey/infra-387-explore-and-create-a-micro-interac…
lukerohanbailey 965235e
style: destructure ToggleProps from useToggleState hook
lukerohanbailey 8d2a0f1
fix: move check timeline play call to a useEffect hook
lukerohanbailey 5c060e9
fix: type naming conventions and allow label to accept any ReactNode
lukerohanbailey 55ab973
fix: remove .vscode/ from .gitignore
lukerohanbailey e8cf1a9
feat: replace gsap animations with CSS transitions
lukerohanbailey dce6b65
fix: remove restprops usage
lukerohanbailey 4280b21
fix: prevent pressed stateon disabled checkboxes
lukerohanbailey 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 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,90 @@ | ||
import { useRef } from 'react'; | ||
import { useCheckbox } from 'react-aria'; | ||
import { useToggleState } from 'react-stately'; | ||
import { styled } from '../../stitches.config'; | ||
import { Check16pxIcon } from '../icons'; | ||
|
||
const Label = styled('label', { | ||
'& input:checked:disabled + 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. What are we needing to target specifically with |
||
color: '$gray50', | ||
}, | ||
display: 'block', | ||
position: 'relative', | ||
}); | ||
|
||
const Input = styled('input', { | ||
'&:checked': { | ||
backgroundColor: '$brandYellow', | ||
borderColor: '$brandYellow', | ||
}, | ||
'&:checked&:disabled': { | ||
backgroundColor: '$yellow20', | ||
borderColor: '$yellow20', | ||
}, | ||
'&:disabled': { | ||
borderColor: '$gray30', | ||
}, | ||
'&:focus': { | ||
outline: '2px solid $brandYellow', | ||
outlineOffset: '2px', | ||
}, | ||
'&:indeterminate': { | ||
borderColor: '$brandYellow', | ||
position: 'relative', | ||
}, | ||
'&:indeterminate:after': { | ||
backgroundColor: '$brandYellow', | ||
content: '""', | ||
height: '12px', | ||
left: '50%', | ||
position: 'absolute', | ||
top: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
width: '12px', | ||
}, | ||
'&[aria-invalid="true"]': { | ||
borderColor: '$uiErrorRegular', | ||
}, | ||
appearance: 'none', | ||
backgroundColor: '$brandWhite', | ||
borderColor: '$gray50', | ||
borderRadius: '$4', | ||
borderStyle: '$solid', | ||
borderWidth: '$thin', | ||
height: '24px', | ||
margin: '0', | ||
position: 'relative', | ||
width: '24px', | ||
}); | ||
|
||
const IconContainer = styled('div', { | ||
left: '50%', | ||
position: 'absolute', | ||
top: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
}); | ||
|
||
export const Checkbox = (props: { | ||
autoFocus?: boolean; | ||
children?: string; | ||
defaultSelected?: boolean; | ||
isDisabled?: boolean; | ||
isIndeterminate?: boolean; | ||
validationState?: 'invalid' | 'valid'; | ||
lukerohanbailey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) => { | ||
const state = useToggleState(props); | ||
const ref = useRef<HTMLInputElement>(null); | ||
const { inputProps } = useCheckbox(props, state, ref); | ||
|
||
return ( | ||
<Label> | ||
<Input {...inputProps} ref={ref} /> | ||
{state.isSelected && ( | ||
<IconContainer> | ||
<Check16pxIcon /> | ||
</IconContainer> | ||
)} | ||
{props.children} | ||
</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,26 @@ | ||
import { styled } from '../../../stitches.config'; | ||
import { Checkbox } from '../Checkbox'; | ||
|
||
const Wrapper = styled('div', { | ||
display: 'flex', | ||
flexFlow: 'row wrap', | ||
gap: '$16', | ||
width: '100%', | ||
}); | ||
|
||
export const CheckboxStates = () => ( | ||
<Wrapper> | ||
<Checkbox isDisabled /> | ||
<Checkbox /> | ||
<Checkbox defaultSelected /> | ||
<Checkbox autoFocus defaultSelected /> | ||
<Checkbox defaultSelected isDisabled /> | ||
<Checkbox isIndeterminate /> | ||
<Checkbox validationState="invalid" /> | ||
</Wrapper> | ||
); | ||
|
||
export default { | ||
component: CheckboxStates, | ||
title: 'Checkbox', | ||
}; |
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
Oops, something went wrong.
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.
I see we moved this from dependencies to devDependencies. If we are going to do this, then we need to add
@stitches/react
topeerDependencies
which would constitute a major/breaking change.