Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Playground] EuiSwitch #3959

Merged
merged 14 commits into from
Aug 25, 2020
Merged
40 changes: 40 additions & 0 deletions src-docs/src/views/form_controls/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
EuiTextArea,
EuiCheckbox,
EuiRadio,
EuiSwitch,
} from '../../../../src/components/';
import { PropTypes } from 'react-view';

Expand Down Expand Up @@ -318,6 +319,44 @@ export const radioConfig = () => {
};
};

const switchConfig = () => {
const docgenInfo = Array.isArray(EuiSwitch.__docgenInfo)
? EuiSwitch.__docgenInfo[0]
: EuiSwitch.__docgenInfo;
const propsToUse = propUtilityForPlayground(docgenInfo.props);

propsToUse.label = {
...propsToUse.label,
type: PropTypes.String,
value: 'Label',
};

propsToUse.checked = {
...propsToUse.checked,
value: true,
};

propsToUse.onChange = simulateFunction(propsToUse.onChange);

return {
config: {
componentName: 'EuiSwitch',
props: propsToUse,
scope: {
EuiSwitch,
},
imports: {
'@elastic/eui': {
named: ['EuiSwitch'],
},
},
customProps: {
onChange: dummyFunction,
},
},
};
};

export default [
fieldTextConfig,
fieldSearchConfig,
Expand All @@ -326,4 +365,5 @@ export default [
textAreaConfig,
checkboxConfig,
radioConfig,
switchConfig,
];
2 changes: 1 addition & 1 deletion src/components/form/switch/switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const EuiSwitch: FunctionComponent<EuiSwitchProps> = ({
<div className={classes}>
<button
id={switchId}
aria-checked={checked}
aria-checked={checked || false}
anishagg17 marked this conversation as resolved.
Show resolved Hide resolved
className="euiSwitch__button"
role="switch"
type={type}
Expand Down