slate/pages/system/checkboxes.js

87 lines
2.4 KiB
JavaScript
Raw Normal View History

import * as React from 'react';
import * as System from '~/components/system';
import SystemPage from '~/components/system/SystemPage';
import ViewSourceLink from '~/components/system/ViewSourceLink';
export default class SystemPageCheckboxes extends React.Component {
state = {
six: false,
seven: true,
};
_handleChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
};
render() {
return (
<SystemPage title="SDS: Checkboxes" description="..." url="https://fps.onrender.com/system/checkboxes">
<System.H1>
Checkboxes <ViewSourceLink file="system/checkboxes.js" />
</System.H1>
<br />
<br />
2020-06-24 05:02:55 +03:00
<System.P>
The Checkbox component is used in forms when a users needs to select one or more values from multiple options.
</System.P>
<br />
<br />
2020-06-24 05:02:55 +03:00
<br />
<System.H2>Usage</System.H2>
<hr />
<br />
<System.P>
Define the boolean Checkbox states and handle the state change the when user checks or unchecks the CheckBox.
</System.P>
2020-06-24 05:02:55 +03:00
<br />
<System.CodeBlock>
{`state = {
2020-06-24 05:02:55 +03:00
six: false,
seven: true,
};
_handleChange = (e) => {
this.setState({ [e.target.name]: e.target.value });
}; `}
</System.CodeBlock>
<br />
<br />
<System.P>Declare the CheckBox component.</System.P>
<br />
<System.CodeBlock>
{`<System.CheckBox name="six" value={this.state.six} onChange={this._handleChange}>
2020-06-24 05:02:55 +03:00
<strong>Unchecked</strong>
<br />
This CheckBox default is unchecked.
</System.CheckBox>
<System.CheckBox name="seven" value={this.state.seven} onChange={this._handleChange}>
<strong>Checked</strong>
<br />
This CheckBox default is checked.
</System.CheckBox>`}
</System.CodeBlock>
<br />
<br />
<System.H2>Output</System.H2>
<hr />
<br />
<System.CheckBox name="six" value={this.state.six} onChange={this._handleChange}>
2020-06-24 05:02:55 +03:00
<strong>Unchecked</strong>
<br />
2020-06-24 05:02:55 +03:00
This CheckBox default is unchecked.
</System.CheckBox>
<br />
<br />
<System.CheckBox name="seven" value={this.state.seven} onChange={this._handleChange}>
2020-06-24 05:02:55 +03:00
<strong>Checked</strong>
<br />
This CheckBox default is checked.
</System.CheckBox>
</SystemPage>
);
}
}