-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(checkbox): add intermediate state
Add intermediate state to checkbox CTRIB-4794
- Loading branch information
Showing
5 changed files
with
62 additions
and
24 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 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
24 changes: 12 additions & 12 deletions
24
packages/site-demo/content/product/components/checkbox/react/default.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 |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { Checkbox } from '@lumx/react'; | ||
import { Checkbox, CheckboxProps } from '@lumx/react'; | ||
import React, { useState } from 'react'; | ||
|
||
export const App = ({ theme }: any) => { | ||
const [value, setValue] = useState(true); | ||
const [value2, setValue2] = useState(false); | ||
const [value3, setValue3] = useState(false); | ||
const useCheckBoxState = (initial: CheckboxProps['isChecked']) => { | ||
const [isChecked, onChange] = useState(initial); | ||
return { isChecked, onChange }; | ||
}; | ||
|
||
return ( | ||
<> | ||
<Checkbox isChecked={value} label="Checkbox" theme={theme} onChange={setValue} /> | ||
<Checkbox label="Checkbox" {...useCheckBoxState(true)} theme={theme} /> | ||
|
||
<Checkbox | ||
isChecked={value2} | ||
helper="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere faucibus efficitur." | ||
label="Checkbox with help" | ||
helper="Lorem ipsum dolor sit amet, consectetur adipiscing elit." | ||
{...useCheckBoxState(false)} | ||
theme={theme} | ||
onChange={setValue2} | ||
/> | ||
|
||
<Checkbox | ||
isChecked={value3} | ||
helper="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed posuere faucibus efficitur." | ||
label="Disabled checkbox with help" | ||
theme={theme} | ||
helper="Lorem ipsum dolor sit amet, consectetur adipiscing elit." | ||
isDisabled | ||
onChange={setValue3} | ||
theme={theme} | ||
/> | ||
|
||
<Checkbox label="Checkbox intermediate state" {...useCheckBoxState('intermediate')} theme={theme} /> | ||
</> | ||
); | ||
}; |