-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement
:focus-visible
for the Switch component with target…
…ed focus style for non-pointer devices
- Loading branch information
Showing
10 changed files
with
364 additions
and
274 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,12 @@ | ||
import { Switch } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<Switch> | ||
Label | ||
</Switch> | ||
); | ||
}; | ||
|
||
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,17 @@ | ||
import { Flex, Switch } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<Flex columnGap="6x"> | ||
<Switch variantColor="red" defaultChecked> | ||
Label | ||
</Switch> | ||
<Switch variantColor="green" defaultChecked> | ||
Label | ||
</Switch> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default App; |
27 changes: 27 additions & 0 deletions
27
packages/react-docs/pages/components/switch/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,27 @@ | ||
import { Button, Flex, Switch } from '@tonic-ui/react'; | ||
import React, { useRef } from 'react'; | ||
|
||
const App = () => { | ||
const inputRef = useRef(); | ||
|
||
const handleClick = () => { | ||
const inputEl = inputRef?.current; | ||
if (inputEl) { | ||
inputEl.focus(); | ||
window.alert('The switch toggle is ' + (inputEl.checked ? 'on' : 'off')); | ||
} | ||
}; | ||
|
||
return ( | ||
<Flex alignItems="center" columnGap="6x"> | ||
<Switch defaultChecked inputRef={inputRef}> | ||
Label | ||
</Switch> | ||
<Button onClick={handleClick}> | ||
Click Me | ||
</Button> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default App; |
24 changes: 24 additions & 0 deletions
24
packages/react-docs/pages/components/switch/flex-layout.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,24 @@ | ||
import { Box, Flex, Switch, Text } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<Flex alignItems="flex-start" columnGap="2x"> | ||
<Switch id="form-control" /> | ||
<Box | ||
as="label" | ||
htmlFor="form-control" | ||
sx={{ | ||
cursor: 'pointer', | ||
pt: '1x', | ||
userSelect: 'none', | ||
}} | ||
> | ||
<Text>Label</Text> | ||
<Text fontSize="xs" lineHeight="xs">Helper text</Text> | ||
</Box> | ||
</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
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,20 @@ | ||
import { Flex, Switch } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<Flex columnGap="6x"> | ||
<Switch size="sm"> | ||
Label | ||
</Switch> | ||
<Switch size="md"> | ||
Label | ||
</Switch> | ||
<Switch size="lg"> | ||
Label | ||
</Switch> | ||
</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,27 @@ | ||
import { Flex, Stack, Switch } from '@tonic-ui/react'; | ||
import React from 'react'; | ||
|
||
const App = () => { | ||
return ( | ||
<Stack spacing="6x"> | ||
<Flex columnGap="6x"> | ||
<Switch checked={false}> | ||
Label | ||
</Switch> | ||
<Switch checked={true}> | ||
Label | ||
</Switch> | ||
</Flex> | ||
<Flex columnGap="6x"> | ||
<Switch checked={false} disabled> | ||
Label | ||
</Switch> | ||
<Switch checked={true} disabled> | ||
Label | ||
</Switch> | ||
</Flex> | ||
</Stack> | ||
); | ||
}; | ||
|
||
export default App; |
Oops, something went wrong.