summaryrefslogtreecommitdiff
path: root/src/components/StyleGuide.js
diff options
context:
space:
mode:
authorHaishan <[email protected]>2020-03-01 17:34:05 +0800
committerHaishan <[email protected]>2020-03-01 17:34:05 +0800
commit21653c415602ddb0ebb59f800bf14b9f1310578d (patch)
treed86204088d35b4955ab23521734e88304f65a9f6 /src/components/StyleGuide.js
parent5b86e7bf0ff1b232c66e056f36a5c07263677bfc (diff)
chore: use react-switch for better a11y
Diffstat (limited to 'src/components/StyleGuide.js')
-rw-r--r--src/components/StyleGuide.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/components/StyleGuide.js b/src/components/StyleGuide.js
index 02bff7c..4cb473d 100644
--- a/src/components/StyleGuide.js
+++ b/src/components/StyleGuide.js
@@ -2,9 +2,9 @@ import React, { PureComponent } from 'react';
import { Zap } from 'react-feather';
+import SwitchThemed from './SwitchThemed';
import ToggleSwitch from './ToggleSwitch';
import Input from './Input';
-import Switch from './Switch';
import Button from './Button';
import { LoadingDot } from './shared/Basic';
@@ -31,12 +31,25 @@ const Pane = ({ children, style }) => (
<div style={{ ...paneStyle, ...style }}>{children}</div>
);
+function useToggle(initialState = false) {
+ const [onoff, setonoff] = React.useState(initialState);
+ const handleChange = React.useCallback(() => {
+ setonoff(x => !x);
+ }, []);
+ return [onoff, handleChange];
+}
+
+function SwitchExample() {
+ const [checked, handleChange] = useToggle(false);
+ return <SwitchThemed checked={checked} onChange={handleChange} />;
+}
+
class StyleGuide extends PureComponent {
render() {
return (
<div>
<Pane>
- <Switch />
+ <SwitchExample />
</Pane>
<Pane>
<Input />