2020-06-22 14:00:51 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
import * as System from '~/components/system';
|
|
|
|
|
|
|
|
import SystemPage from '~/components/system/SystemPage';
|
2020-06-22 14:15:04 +03:00
|
|
|
import ViewSourceLink from '~/components/system/ViewSourceLink';
|
2020-06-22 14:00:51 +03:00
|
|
|
|
|
|
|
export default class SystemPageToggles extends React.Component {
|
|
|
|
state = {
|
|
|
|
three: true,
|
|
|
|
four: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-07-01 10:31:55 +03:00
|
|
|
<SystemPage title="SDS: Toggles" description="..." url="https://fps.onrender.com/toggles">
|
2020-06-22 14:15:04 +03:00
|
|
|
<System.H1>
|
2020-07-01 10:31:55 +03:00
|
|
|
Toggles <ViewSourceLink file="system/toggles.js" />
|
2020-06-22 14:15:04 +03:00
|
|
|
</System.H1>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.P>The Toggle component is used to switch between two states.</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.H2>Usage</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>Define the Toggle boolean state and handle the state change the when a toggle is changed.</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-01 10:31:55 +03:00
|
|
|
{`state = {
|
2020-06-24 05:02:55 +03:00
|
|
|
three: true,
|
|
|
|
four: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};`}
|
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the Toggle component.</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-01 10:31:55 +03:00
|
|
|
{`<System.Toggle active={this.state.three} name="three" onChange={this._handleChange} />
|
2020-06-22 14:00:51 +03:00
|
|
|
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.Toggle active={this.state.four} name="four" onChange={this._handleChange} />`}
|
|
|
|
</System.CodeBlock>
|
|
|
|
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Output</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
2020-06-22 14:00:51 +03:00
|
|
|
<System.Toggle active={this.state.three} name="three" onChange={this._handleChange} />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.Toggle active={this.state.four} name="four" onChange={this._handleChange} />
|
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|