2020-07-07 04:14:30 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
|
|
|
import Group from "~/components/system/Group";
|
|
|
|
import * as Constants from "~/common/constants";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
2020-07-07 04:14:30 +03:00
|
|
|
import SystemPage from "~/components/system/SystemPage";
|
|
|
|
import ViewSourceLink from "~/components/system/ViewSourceLink";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
|
|
|
const RADIO_GROUP_OPTIONS = [
|
|
|
|
{
|
2020-07-07 04:14:30 +03:00
|
|
|
value: "1",
|
2020-06-22 14:00:51 +03:00
|
|
|
label: (
|
|
|
|
<React.Fragment>
|
2020-06-24 05:02:55 +03:00
|
|
|
<strong>Option one</strong>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />I want to have cake and soda for breakfast.
|
|
|
|
</React.Fragment>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
2020-07-07 04:14:30 +03:00
|
|
|
value: "2",
|
2020-06-22 14:00:51 +03:00
|
|
|
label: (
|
|
|
|
<React.Fragment>
|
2020-06-24 05:02:55 +03:00
|
|
|
<strong>Option two</strong>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />I want to have cake and soda for lunch.
|
|
|
|
</React.Fragment>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
2020-07-07 04:14:30 +03:00
|
|
|
value: "3",
|
2020-06-22 14:00:51 +03:00
|
|
|
label: (
|
|
|
|
<React.Fragment>
|
2020-06-24 05:02:55 +03:00
|
|
|
<strong>Option three</strong>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />I want to have cake and soda for dinner.
|
|
|
|
</React.Fragment>
|
|
|
|
),
|
2020-07-01 10:31:55 +03:00
|
|
|
},
|
2020-06-22 14:00:51 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
export default class SystemPageRadios extends React.Component {
|
|
|
|
state = {
|
2020-07-07 04:14:30 +03:00
|
|
|
exampleOne: "2",
|
2020-06-22 14:00:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-07-07 04:14:30 +03:00
|
|
|
<SystemPage
|
|
|
|
title="SDS: Radios"
|
|
|
|
description="..."
|
|
|
|
url="https://fps.onrender.com/system/radios"
|
|
|
|
>
|
2020-06-22 14:15:04 +03:00
|
|
|
<System.H1>
|
2020-07-01 10:31:55 +03:00
|
|
|
Radios <ViewSourceLink file="system/radios.js" />
|
2020-06-22 14:15:04 +03:00
|
|
|
</System.H1>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-01 10:31:55 +03:00
|
|
|
<System.P>
|
2020-07-07 04:14:30 +03:00
|
|
|
The Radio component is used when you require a user to select only one
|
|
|
|
value in a series of options.
|
2020-07-01 10:31:55 +03:00
|
|
|
</System.P>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-03 19:38:44 +03:00
|
|
|
<br />
|
|
|
|
<System.H2>Imports</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<System.P>Import React and the RadioGroup Component.</System.P>
|
2020-07-03 19:38:44 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-07 04:14:30 +03:00
|
|
|
{`import * as React from 'react';
|
2020-07-03 19:38:44 +03:00
|
|
|
import { RadioGroup } from 'slate-react-system';`}
|
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.H2>Usage</System.H2>
|
|
|
|
<hr />
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.P>Define the radio group values and labels.</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.CodeBlock>
|
2020-07-01 10:31:55 +03:00
|
|
|
{`const RADIO_GROUP_OPTIONS = [
|
2020-06-24 05:02:55 +03:00
|
|
|
{
|
|
|
|
value: '1',
|
|
|
|
label: (
|
|
|
|
<React.Fragment>
|
|
|
|
<strong>Option one</strong>
|
|
|
|
<br />I want to have cake and soda for breakfast.
|
|
|
|
</React.Fragment>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: '2',
|
|
|
|
label: (
|
|
|
|
<React.Fragment>
|
|
|
|
<strong>Option two</strong>
|
|
|
|
<br />I want to have cake and soda for lunch.
|
|
|
|
</React.Fragment>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: '3',
|
|
|
|
label: (
|
|
|
|
<React.Fragment>
|
|
|
|
<strong>Option three</strong>
|
|
|
|
<br />I want to have cake and soda for dinner.
|
|
|
|
</React.Fragment>
|
|
|
|
),
|
|
|
|
}
|
|
|
|
];`}
|
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the RadioGroup component.</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleOne extends React.Component {
|
|
|
|
state = { ExampleOne: '2' }
|
|
|
|
|
2020-07-04 08:34:20 +03:00
|
|
|
_handleChange = e => this.setState(
|
2020-07-04 08:05:39 +03:00
|
|
|
{ [e.target.name]: e.target.value }
|
2020-07-04 08:34:20 +03:00
|
|
|
);
|
2020-07-04 08:05:39 +03:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<RadioGroup
|
|
|
|
name="ExampleOne"
|
|
|
|
options={RADIO_GROUP_OPTIONS}
|
|
|
|
selected={this.state.ExampleOne}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Output</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
2020-06-22 14:00:51 +03:00
|
|
|
<System.RadioGroup
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleOne"
|
2020-06-22 14:00:51 +03:00
|
|
|
options={RADIO_GROUP_OPTIONS}
|
2020-07-04 08:05:39 +03:00
|
|
|
selected={this.state.exampleOne}
|
2020-06-22 14:00:51 +03:00
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<br />
|
2020-07-03 19:38:44 +03:00
|
|
|
<System.H2>Accepted React Properties</System.H2>
|
2020-06-24 05:02:55 +03:00
|
|
|
<hr />
|
|
|
|
<br />
|
2020-07-01 10:31:55 +03:00
|
|
|
<Group title="RadioGroup">
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
2020-07-07 04:14:30 +03:00
|
|
|
{ key: "a", name: "Name", width: "128px" },
|
|
|
|
{ key: "b", name: "Type", width: "88px" },
|
|
|
|
{ key: "c", name: "Default", width: "88px" },
|
|
|
|
{ key: "d", name: "Description", width: "100%" },
|
2020-06-24 05:02:55 +03:00
|
|
|
],
|
|
|
|
rows: [
|
2020-07-07 04:14:30 +03:00
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
onChange
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
b: <System.CodeText nowrap>function</System.CodeText>,
|
|
|
|
c: "null",
|
|
|
|
d: "Function called upon an onChange event",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
selected
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
b: <System.CodeText nowrap>boolean</System.CodeText>,
|
|
|
|
c: "false",
|
|
|
|
d:
|
|
|
|
"The value that is currently selected. Can be used to assign default values as well",
|
|
|
|
},
|
2020-07-01 10:31:55 +03:00
|
|
|
{
|
|
|
|
id: 3,
|
2020-07-07 04:14:30 +03:00
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
options
|
|
|
|
</span>
|
|
|
|
),
|
|
|
|
b: <System.CodeText nowrap>Array</System.CodeText>,
|
|
|
|
c: "[]",
|
|
|
|
d:
|
|
|
|
"An array of options, each of which has a value and a label",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 4,
|
|
|
|
a: "name",
|
|
|
|
b: <System.CodeText nowrap>string</System.CodeText>,
|
|
|
|
c: "null",
|
|
|
|
d: "Input name",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 5,
|
|
|
|
a: "label",
|
|
|
|
b: <System.CodeText nowrap>string</System.CodeText>,
|
|
|
|
c: "null",
|
|
|
|
d: "Label text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 6,
|
|
|
|
a: "description",
|
|
|
|
b: <System.CodeText nowrap>string</System.CodeText>,
|
|
|
|
c: "null",
|
|
|
|
d: "Description text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 7,
|
|
|
|
a: "tooltip",
|
|
|
|
b: <System.CodeText nowrap>string</System.CodeText>,
|
|
|
|
c: "null",
|
|
|
|
d: "Tooltip text",
|
2020-07-01 10:31:55 +03:00
|
|
|
},
|
2020-06-24 05:02:55 +03:00
|
|
|
],
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Group>
|
2020-06-22 14:00:51 +03:00
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|