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-02 00:56:32 +03:00
|
|
|
<<<<<<< HEAD
|
2020-07-04 08:05:39 +03:00
|
|
|
exampleOne: '1',
|
|
|
|
exampleTwo: '3',
|
2020-07-02 00:56:32 +03:00
|
|
|
=======
|
|
|
|
menu: "4",
|
|
|
|
fullMenu: "1",
|
|
|
|
countryMenu: "United States of America",
|
|
|
|
>>>>>>> added country dropdown and refactored dropdown options
|
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
|
|
|
<<<<<<< HEAD
|
2020-07-01 10:31:55 +03:00
|
|
|
<SystemPage title="SDS: Dropdowns" description="..." url="https://fps.onrender.com/system/dropdowns">
|
2020-07-02 00:56:32 +03:00
|
|
|
=======
|
|
|
|
<SystemPage
|
|
|
|
title="FCDS: Dropdowns"
|
|
|
|
description="Lorem Ipsum."
|
|
|
|
url="https://fps.onrender.com/system/dropdowns"
|
|
|
|
>
|
|
|
|
>>>>>>> added country dropdown and refactored dropdown options
|
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-02 00:56:32 +03:00
|
|
|
<<<<<<< HEAD
|
2020-07-01 10:31:55 +03:00
|
|
|
The Dropdown component is used to present the user a list of values where they can select a single option.
|
|
|
|
</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>
|
|
|
|
{`import * as React from 'react';
|
|
|
|
import { SelectMenu, SelectMenuFull } from 'slate-react-system';`}
|
|
|
|
</System.CodeBlock>
|
2020-07-02 00:56:32 +03:00
|
|
|
=======
|
|
|
|
The Dropdown component is used to present the user a list of values
|
|
|
|
where they can select a single option.
|
|
|
|
</System.P>
|
|
|
|
>>>>>>> added country dropdown and refactored dropdown options
|
2020-07-03 19:38:44 +03:00
|
|
|
<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 />
|
2020-07-02 00:56:32 +03:00
|
|
|
<<<<<<< HEAD
|
2020-06-24 05:02:55 +03:00
|
|
|
<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}
|
|
|
|
options={SELECT_MENU_OPTIONS}>
|
|
|
|
{SELECT_MENU_MAP[this.state.exampleOne]}
|
|
|
|
</SelectMenu>
|
|
|
|
)
|
|
|
|
}
|
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-03 19:38:44 +03:00
|
|
|
<SelectMenuFull
|
|
|
|
label="Pick a horoscope"
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleTwo"
|
|
|
|
value={this.state.exampleTwo}
|
2020-07-03 19:38:44 +03:00
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}>
|
2020-07-04 08:05:39 +03:00
|
|
|
{SELECT_MENU_MAP[this.state.exampleTwo]}
|
2020-07-03 19:38:44 +03:00
|
|
|
</SelectMenuFull>
|
2020-07-04 08:05:39 +03:00
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-07-02 00:56:32 +03:00
|
|
|
=======
|
|
|
|
<System.P>
|
|
|
|
Define the Dropdown default value states and handle the state change
|
|
|
|
when a dropdown value is selected.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
|
|
|
{`state = {
|
|
|
|
menu: '4',
|
|
|
|
fullMenu: '1',
|
|
|
|
countryMenu: 'United States of America',
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};`}
|
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the Dropdown component.</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
|
|
|
{`<System.SelectMenu
|
|
|
|
name="menu"
|
|
|
|
value={this.state.menu}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}>
|
|
|
|
{SELECT_MENU_MAP[this.state.one]}
|
|
|
|
</System.SelectMenu>
|
|
|
|
|
|
|
|
<System.SelectMenu
|
|
|
|
label="Pick a horoscope"
|
|
|
|
name="fullMenu"
|
|
|
|
full
|
|
|
|
value={this.state.fullMenu}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}>
|
|
|
|
{SELECT_MENU_MAP[this.state.three]}
|
|
|
|
</System.SelectMenu>
|
|
|
|
|
|
|
|
<System.SelectCountryMenu
|
|
|
|
label="Pick your country"
|
|
|
|
name="countryMenu"
|
|
|
|
full
|
|
|
|
value={this.state.countryMenu}
|
|
|
|
category="country"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>`}
|
|
|
|
>>>>>>> added country dropdown and refactored dropdown options
|
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-02 00:56:32 +03:00
|
|
|
<<<<<<< HEAD
|
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}
|
|
|
|
options={SELECT_MENU_OPTIONS}>
|
2020-07-04 08:05:39 +03:00
|
|
|
{SELECT_MENU_MAP[this.state.exampleOne]}
|
2020-06-22 14:00:51 +03:00
|
|
|
</System.SelectMenu>
|
2020-07-02 00:56:32 +03:00
|
|
|
=======
|
|
|
|
label="Pick a horoscope"
|
|
|
|
name="menu"
|
|
|
|
value={this.state.menu}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
|
|
|
>>>>>>> added country dropdown and refactored dropdown 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-02 00:56:32 +03:00
|
|
|
<<<<<<< HEAD
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleTwo"
|
|
|
|
value={this.state.exampleTwo}
|
2020-06-22 14:00:51 +03:00
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}>
|
2020-07-04 08:05:39 +03:00
|
|
|
{SELECT_MENU_MAP[this.state.exampleTwo]}
|
2020-06-22 14:00:51 +03:00
|
|
|
</System.SelectMenuFull>
|
2020-07-02 00:56:32 +03:00
|
|
|
=======
|
|
|
|
name="fullMenu"
|
|
|
|
full
|
|
|
|
value={this.state.fullMenu}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.SelectCountryMenu
|
|
|
|
label="Pick your country"
|
|
|
|
name="countryMenu"
|
|
|
|
full
|
|
|
|
value={this.state.countryMenu}
|
|
|
|
category="country"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
>>>>>>> added country dropdown and refactored dropdown options
|
2020-06-22 14:00:51 +03:00
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|