2020-07-02 00:56:32 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
2020-07-02 00:56:32 +03:00
|
|
|
import SystemPage from "~/components/system/SystemPage";
|
|
|
|
import ViewSourceLink from "~/components/system/ViewSourceLink";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
|
|
|
const SELECT_MENU_OPTIONS = [
|
2020-07-02 00:56:32 +03:00
|
|
|
{ value: "1", name: "Capricorn" },
|
|
|
|
{ value: "2", name: "Aquarius" },
|
|
|
|
{ value: "3", name: "Pisces" },
|
|
|
|
{ value: "4", name: "Aries" },
|
|
|
|
{ value: "5", name: "Taurus" },
|
|
|
|
{ value: "6", name: "Gemini" },
|
|
|
|
{ value: "7", name: "Cancer" },
|
|
|
|
{ value: "8", name: "Leo" },
|
|
|
|
{ value: "9", name: "Virgo" },
|
|
|
|
{ value: "10", name: "Libra" },
|
|
|
|
{ value: "11", name: "Scorpio" },
|
|
|
|
{ value: "12", name: "Sagittarus" },
|
2020-06-22 14:00:51 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
export default class SystemPageDropdowns extends React.Component {
|
|
|
|
state = {
|
2020-07-05 08:20:57 +03:00
|
|
|
exampleOne: "1",
|
|
|
|
exampleTwo: "3",
|
|
|
|
exampleThree: "United States of America",
|
2020-06-22 14:00:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-07-02 00:56:32 +03:00
|
|
|
<SystemPage
|
2020-07-05 08:20:57 +03:00
|
|
|
title="SDS: Dropdowns"
|
|
|
|
description="..."
|
2020-07-02 00:56:32 +03:00
|
|
|
url="https://fps.onrender.com/system/dropdowns"
|
|
|
|
>
|
2020-06-22 14:15:04 +03:00
|
|
|
<System.H1>
|
2020-07-01 10:31:55 +03:00
|
|
|
Dropdowns <ViewSourceLink file="system/dropdowns.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-05 08:20:57 +03:00
|
|
|
The Dropdown component is used to present the user a list of values
|
|
|
|
where they can select a single option.
|
2020-07-01 10:31:55 +03:00
|
|
|
</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-03 19:38:44 +03:00
|
|
|
<br />
|
|
|
|
<System.H2>Imports</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Import React and the SelectMenu and/or the SelectMenuFull Components.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-05 08:20:57 +03:00
|
|
|
{`import * as React from 'react';
|
|
|
|
import { SelectMenu, SelectCountryMenu } from 'slate-react-system';`}
|
2020-07-03 19:38:44 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.H2>Usage</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>Define the dropdown menu options.</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-01 10:31:55 +03:00
|
|
|
{`const SELECT_MENU_OPTIONS = [
|
2020-06-24 05:02:55 +03:00
|
|
|
{ value: '1', name: 'Capricorn' },
|
|
|
|
{ value: '2', name: 'Aquarius' },
|
|
|
|
{ value: '3', name: 'Pisces' },
|
|
|
|
{ value: '4', name: 'Aries' },
|
|
|
|
{ value: '5', name: 'Taurus' },
|
|
|
|
{ value: '6', name: 'Gemini' },
|
|
|
|
{ value: '7', name: 'Cancer' },
|
|
|
|
{ value: '8', name: 'Leo' },
|
|
|
|
{ value: '9', name: 'Virgo' },
|
|
|
|
{ value: '10', name: 'Libra' },
|
|
|
|
{ value: '11', name: 'Scorpio' },
|
|
|
|
{ value: '12', name: 'Sagittarus' },
|
2020-07-02 00:56:32 +03:00
|
|
|
];`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the Dropdown component.</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleOne extends React.Component {
|
|
|
|
state = { exampleOne: '1' }
|
|
|
|
|
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(
|
|
|
|
<SelectMenu
|
|
|
|
name="exampleOne"
|
|
|
|
value={this.state.exampleOne}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
2020-07-05 08:20:57 +03:00
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
2020-07-04 08:05:39 +03:00
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}
|
2020-06-24 05:02:55 +03:00
|
|
|
|
2020-07-04 08:05:39 +03:00
|
|
|
|
|
|
|
class ExampleTwo extends React.Component {
|
|
|
|
state = { exampleTwo: '3' }
|
|
|
|
|
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(
|
2020-07-05 08:20:57 +03:00
|
|
|
<SelectMenu
|
2020-07-03 19:38:44 +03:00
|
|
|
label="Pick a horoscope"
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleTwo"
|
2020-07-05 08:20:57 +03:00
|
|
|
full
|
2020-07-04 08:05:39 +03:00
|
|
|
value={this.state.exampleTwo}
|
2020-07-03 19:38:44 +03:00
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
2020-07-05 08:20:57 +03:00
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
2020-07-04 08:05:39 +03:00
|
|
|
)
|
|
|
|
}
|
2020-07-05 08:20:57 +03:00
|
|
|
}
|
2020-07-02 00:56:32 +03:00
|
|
|
|
|
|
|
|
2020-07-05 08:20:57 +03:00
|
|
|
class ExampleThree extends React.Component {
|
|
|
|
state = { exampleThree: "United States of America" }
|
2020-07-02 00:56:32 +03:00
|
|
|
|
2020-07-05 08:20:57 +03:00
|
|
|
_handleChange = e => this.setState(
|
|
|
|
{ [e.target.name]: e.target.value }
|
|
|
|
);
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<SelectCountryMenu
|
|
|
|
label="Pick your country"
|
|
|
|
name="countryMenu"
|
|
|
|
full
|
|
|
|
value={this.state.countryMenu}
|
|
|
|
category="country"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}`}
|
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.SelectMenu
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleOne"
|
|
|
|
value={this.state.exampleOne}
|
2020-06-22 14:00:51 +03:00
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
2020-07-02 00:56:32 +03:00
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.SelectMenu
|
2020-06-22 14:00:51 +03:00
|
|
|
label="Pick a horoscope"
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleTwo"
|
2020-07-02 00:56:32 +03:00
|
|
|
full
|
2020-07-05 08:20:57 +03:00
|
|
|
value={this.state.exampleTwo}
|
2020-07-02 00:56:32 +03:00
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.SelectCountryMenu
|
|
|
|
label="Pick your country"
|
2020-07-05 08:40:43 +03:00
|
|
|
name="exampleThree"
|
2020-07-02 00:56:32 +03:00
|
|
|
full
|
2020-07-05 08:40:43 +03:00
|
|
|
value={this.state.exampleThree}
|
2020-07-02 00:56:32 +03:00
|
|
|
category="country"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
2020-06-22 14:00:51 +03:00
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|