-
Notifications
You must be signed in to change notification settings - Fork 30
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
Showing
9 changed files
with
176 additions
and
126 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
packages/react-docs/pages/components/checkbox/accessibility.js
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,13 @@ | ||
import { Checkbox } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => ( | ||
<Checkbox | ||
inputProps={{ | ||
'aria-label': 'Label', | ||
}} | ||
/> | ||
|
||
); | ||
|
||
export default App; |
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 { Checkbox } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => ( | ||
<Checkbox> | ||
Label | ||
</Checkbox> | ||
); | ||
|
||
export default App; |
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,15 @@ | ||
import { Checkbox, Flex } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => ( | ||
<Flex columnGap="6x"> | ||
<Checkbox variantColor="red" defaultChecked> | ||
Label | ||
</Checkbox> | ||
<Checkbox variantColor="green" defaultChecked> | ||
Label | ||
</Checkbox> | ||
</Flex> | ||
); | ||
|
||
export default App; |
23 changes: 23 additions & 0 deletions
23
packages/react-docs/pages/components/checkbox/faq-input-element.js
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,23 @@ | ||
import { Button, Checkbox, Flex } from '@tonic-ui/react'; | ||
import React, { useRef } from 'react'; | ||
|
||
const App = () => { | ||
const inputRef = useRef(); | ||
const handleClick = () => { | ||
inputRef.current.focus(); | ||
console.log(inputRef.current.checked); // => true | ||
}; | ||
|
||
return ( | ||
<Flex alignItems="center" columnGap="6x"> | ||
<Checkbox defaultChecked inputRef={inputRef}> | ||
Label | ||
</Checkbox> | ||
<Button onClick={handleClick}> | ||
Click Me | ||
</Button> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default App; |
23 changes: 23 additions & 0 deletions
23
packages/react-docs/pages/components/checkbox/flex-container.js
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,23 @@ | ||
import { Box, Checkbox, Flex, Text } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => ( | ||
<Flex alignItems="flex-start" columnGap="2x"> | ||
<Box py="1h"> | ||
<Checkbox id="form-control" /> | ||
</Box> | ||
<Box | ||
as="label" | ||
htmlFor="form-control" | ||
sx={{ | ||
cursor: 'pointer', | ||
userSelect: 'none', | ||
}} | ||
> | ||
<Text>Label</Text> | ||
<Text fontSize="xs" lineHeight="xs">Helper text</Text> | ||
</Box> | ||
</Flex> | ||
); | ||
|
||
export default App; |
36 changes: 36 additions & 0 deletions
36
packages/react-docs/pages/components/checkbox/indeterminate.js
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 { Checkbox, Stack } from '@tonic-ui/react'; | ||
import React, { useState } from 'react'; | ||
|
||
const App = () => { | ||
const [checkedItems, setCheckedItems] = useState([true, false]); | ||
const allChecked = checkedItems.every(Boolean); | ||
const isIndeterminate = checkedItems.some(Boolean) && !allChecked; | ||
|
||
return ( | ||
<> | ||
<Checkbox | ||
checked={allChecked} | ||
indeterminate={isIndeterminate} | ||
onChange={e => setCheckedItems([e.target.checked, e.target.checked])} | ||
> | ||
Parent | ||
</Checkbox> | ||
<Stack direction="column" pl="6x" mt="1x" spacing="1x" shouldWrapChildren> | ||
<Checkbox | ||
checked={checkedItems[0]} | ||
onChange={e => setCheckedItems([e.target.checked, checkedItems[1]])} | ||
> | ||
Child 1 | ||
</Checkbox> | ||
<Checkbox | ||
checked={checkedItems[1]} | ||
onChange={e => setCheckedItems([checkedItems[0], e.target.checked])} | ||
> | ||
Child 2 | ||
</Checkbox> | ||
</Stack> | ||
</> | ||
); | ||
}; | ||
|
||
export default App; |
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,18 @@ | ||
import { Checkbox, Flex } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => ( | ||
<Flex columnGap="6x"> | ||
<Checkbox size="sm"> | ||
Label | ||
</Checkbox> | ||
<Checkbox size="md"> | ||
Label | ||
</Checkbox> | ||
<Checkbox size="lg"> | ||
Label | ||
</Checkbox> | ||
</Flex> | ||
); | ||
|
||
export default App; |
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,31 @@ | ||
import { Checkbox, Flex, Stack } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => ( | ||
<Stack spacing="6x"> | ||
<Flex columnGap="6x"> | ||
<Checkbox> | ||
Label | ||
</Checkbox> | ||
<Checkbox indeterminate> | ||
Label | ||
</Checkbox> | ||
<Checkbox defaultChecked> | ||
Label | ||
</Checkbox> | ||
</Flex> | ||
<Flex columnGap="6x"> | ||
<Checkbox disabled> | ||
Label | ||
</Checkbox> | ||
<Checkbox disabled indeterminate> | ||
Label | ||
</Checkbox> | ||
<Checkbox disabled defaultChecked> | ||
Label | ||
</Checkbox> | ||
</Flex> | ||
</Stack> | ||
); | ||
|
||
export default App; |