2020-07-02 00:56:32 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
2020-07-07 04:14:30 +03:00
|
|
|
import * as Constants from "~/common/constants";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
2020-07-07 04:14:30 +03:00
|
|
|
import Group from "~/components/system/Group";
|
2020-07-02 00:56:32 +03:00
|
|
|
import SystemPage from "~/components/system/SystemPage";
|
|
|
|
import ViewSourceLink from "~/components/system/ViewSourceLink";
|
2020-07-21 03:56:14 +03:00
|
|
|
import CodeBlock from "~/components/system/CodeBlock";
|
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-21 02:48:10 +03:00
|
|
|
url="https://slate.host/system/dropdowns"
|
2020-07-02 00:56:32 +03:00
|
|
|
>
|
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>
|
2020-07-07 04:14:30 +03:00
|
|
|
Import React and the <System.CodeText>SelectMenu</System.CodeText>{" "}
|
|
|
|
and/or the <System.CodeText>SelectCountryMenu</System.CodeText>{" "}
|
|
|
|
Components.
|
2020-07-03 19:38:44 +03:00
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-21 03:56:14 +03:00
|
|
|
<CodeBlock>
|
2020-07-05 08:20:57 +03:00
|
|
|
{`import * as React from 'react';
|
|
|
|
import { SelectMenu, SelectCountryMenu } from 'slate-react-system';`}
|
2020-07-21 03:56:14 +03:00
|
|
|
</CodeBlock>
|
2020-07-03 19:38:44 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<System.H2>Dropdown</System.H2>
|
2020-06-24 05:02:55 +03:00
|
|
|
<hr />
|
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<System.SelectMenu
|
|
|
|
label="Pick a horoscope"
|
|
|
|
name="exampleOne"
|
|
|
|
value={this.state.exampleOne}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.SelectMenu
|
|
|
|
label="Pick a horoscope (full length)"
|
|
|
|
name="exampleTwo"
|
|
|
|
full
|
|
|
|
value={this.state.exampleTwo}
|
|
|
|
category="horoscope"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
options={SELECT_MENU_OPTIONS}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Define the dropdown menu options. Each entry must have a name and a
|
|
|
|
value.
|
|
|
|
</System.P>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
2020-07-21 03:56:14 +03:00
|
|
|
<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-07-21 03:56:14 +03:00
|
|
|
</CodeBlock>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Declare the Dropdown component. Default values can be assigned using{" "}
|
|
|
|
<System.CodeText>value</System.CodeText>.
|
|
|
|
</System.P>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
2020-07-21 03:56:14 +03:00
|
|
|
<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
|
2020-07-07 04:14:30 +03:00
|
|
|
label="Pick a horoscope"
|
2020-07-04 08:05:39 +03:00
|
|
|
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-07 04:14:30 +03:00
|
|
|
label="Pick a horoscope (full length)"
|
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-07 04:14:30 +03:00
|
|
|
}`}
|
2020-07-21 03:56:14 +03:00
|
|
|
</CodeBlock>
|
2020-07-07 04:14:30 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Country Picker Dropdown</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.SelectCountryMenu
|
|
|
|
label="Pick your country"
|
|
|
|
name="exampleThree"
|
|
|
|
full
|
|
|
|
value={this.state.exampleThree}
|
|
|
|
category="country"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Declare a dropdown to select from a list of countries.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
2020-07-21 03:56:14 +03:00
|
|
|
<CodeBlock>
|
2020-07-07 04:14:30 +03:00
|
|
|
{`class ExampleThree extends React.Component {
|
2020-07-05 08:20:57 +03:00
|
|
|
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-07-21 03:56:14 +03:00
|
|
|
</CodeBlock>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<System.H2>Accepted React Properties</System.H2>
|
|
|
|
<hr />
|
2020-07-02 00:56:32 +03:00
|
|
|
<br />
|
2020-07-07 04:14:30 +03:00
|
|
|
<Group title="Dropdowns">
|
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
|
|
|
{ key: "a", name: "Name", width: "128px" },
|
2020-07-14 07:28:18 +03:00
|
|
|
{ key: "b", name: "Type", width: "88px", type: "OBJECT_TYPE" },
|
2020-07-07 04:14:30 +03:00
|
|
|
{ key: "c", name: "Default", width: "88px" },
|
|
|
|
{ key: "d", name: "Description", width: "100%" },
|
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
options
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "Array",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "[]",
|
|
|
|
d:
|
|
|
|
"Array of options to select from. Each object in the array should have a name and value",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
onChange
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "function",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Function called upon an onChange event",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
value
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d:
|
|
|
|
"The value that the dropdown takes. Can be used to assign default values as well.",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 4,
|
|
|
|
a: "name",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Input name",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 5,
|
|
|
|
a: "label",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Label text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 6,
|
|
|
|
a: "description",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Description text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 7,
|
|
|
|
a: "tooltip",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Tooltip text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 8,
|
|
|
|
a: "full",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "boolean",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "false",
|
|
|
|
d: "Sets width to 100% if true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 9,
|
|
|
|
a: "category",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Category text",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Group>
|
2020-06-22 14:00:51 +03:00
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|