Skip to content

Commit

Permalink
[Playground] EuiSwitch (#3959)
Browse files Browse the repository at this point in the history
* [Playground]   EuiFieldText,
  EuiFieldSearch,
  EuiFieldNumber,
  EuiFieldPassword,

* removed unnecessary import

* EuiTextArea,
  EuiCheckbox,
  EuiRadio

* Update src-docs/src/views/form_controls/playground.js

Co-authored-by: Greg Thompson <[email protected]>

* Update src-docs/src/views/form_controls/playground.js

Co-authored-by: Greg Thompson <[email protected]>

* Updated type prop for EuiFieldPassword

* type type

* props for type are now correct [EuiFieldPassword]

* [Playground] EuiSwitch

* fixed switch

Co-authored-by: Greg Thompson <[email protected]>
  • Loading branch information
anishagg17 and thompsongl authored Aug 25, 2020
1 parent e1072f9 commit fe2ee56
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
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}
className="euiSwitch__button"
role="switch"
type={type}
Expand Down

0 comments on commit fe2ee56

Please sign in to comment.