-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate select-field docs to the new standard
- Loading branch information
Showing
14 changed files
with
473 additions
and
540 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
docs/src/app/components/pages/components/SelectField/ExampleCustomLabel.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import SelectField from 'material-ui/lib/SelectField'; | ||
import MenuItem from 'material-ui/lib/menus/menu-item'; | ||
|
||
export default class SelectFieldExampleCustomLabel extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {value: 1}; | ||
} | ||
|
||
handleChange = (event, index, value) => this.setState({value}); | ||
|
||
render() { | ||
return ( | ||
<SelectField value={this.state.value} onChange={this.handleChange}> | ||
<MenuItem value={1} label="5 am - 12 pm" primaryText="Morning"/> | ||
<MenuItem value={2} label="12 pm - 5 pm" primaryText="Afternoon"/> | ||
<MenuItem value={3} label="5 pm to 9 pm" primaryText="Evening"/> | ||
<MenuItem value={4} label="9 pm to 4 am" primaryText="Night"/> | ||
</SelectField> | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/src/app/components/pages/components/SelectField/ExampleDisabled.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import SelectField from 'material-ui/lib/SelectField'; | ||
import MenuItem from 'material-ui/lib/menus/menu-item'; | ||
|
||
const SelectFieldExampleDisabled = () => ( | ||
<SelectField value={1} disabled={true}> | ||
<MenuItem value={1} primaryText="Never"/> | ||
<MenuItem value={2} primaryText="Every Night"/> | ||
</SelectField> | ||
); | ||
|
||
export default SelectFieldExampleDisabled; |
48 changes: 48 additions & 0 deletions
48
docs/src/app/components/pages/components/SelectField/ExampleError.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import SelectField from 'material-ui/lib/SelectField'; | ||
import MenuItem from 'material-ui/lib/menus/menu-item'; | ||
|
||
const items = [ | ||
<MenuItem key={1} value={1} primaryText="Never"/>, | ||
<MenuItem key={2} value={2} primaryText="Every Night"/>, | ||
<MenuItem key={3} value={3} primaryText="Weeknights"/>, | ||
<MenuItem key={4} value={4} primaryText="Weekends"/>, | ||
<MenuItem key={5} value={5} primaryText="Weekly"/>, | ||
]; | ||
|
||
export default class SelectFieldExampleError extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {value: null}; | ||
} | ||
|
||
handleChange = (event, index, value) => this.setState({value}); | ||
|
||
render() { | ||
const {value} = this.state; | ||
|
||
const night = value === 2 || value === 3; | ||
|
||
return ( | ||
<div> | ||
<SelectField | ||
value={value} | ||
onChange={this.handleChange} | ||
errorText={!night && 'Should be Night'} | ||
> | ||
{items} | ||
</SelectField> | ||
<br/> | ||
<SelectField | ||
value={value} | ||
onChange={this.handleChange} | ||
errorText={night && 'Should not be Night (Custom error style)'} | ||
errorStyle={{color: 'orange'}} | ||
> | ||
{items} | ||
</SelectField> | ||
</div> | ||
); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
docs/src/app/components/pages/components/SelectField/ExampleFloatingLabel.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import SelectField from 'material-ui/lib/SelectField'; | ||
import MenuItem from 'material-ui/lib/menus/menu-item'; | ||
|
||
const items = [ | ||
<MenuItem key={1} value={1} primaryText="Never"/>, | ||
<MenuItem key={2} value={2} primaryText="Every Night"/>, | ||
<MenuItem key={3} value={3} primaryText="Weeknights"/>, | ||
<MenuItem key={4} value={4} primaryText="Weekends"/>, | ||
<MenuItem key={5} value={5} primaryText="Weekly"/>, | ||
]; | ||
|
||
export default class SelectFieldExampleFloatingLabel extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {value: null}; | ||
} | ||
|
||
handleChange = (event, index, value) => this.setState({value}); | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<SelectField | ||
value={this.state.value} | ||
onChange={this.handleChange} | ||
floatingLabelText="Float Label Text" | ||
> | ||
{items} | ||
</SelectField> | ||
<br/> | ||
<SelectField | ||
value={this.state.value} | ||
onChange={this.handleChange} | ||
floatingLabelText="Custom Float Label Text" | ||
floatingLabelStyle={{color: 'red'}} | ||
> | ||
{items} | ||
</SelectField> | ||
</div> | ||
); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
docs/src/app/components/pages/components/SelectField/ExampleSimple.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import SelectField from 'material-ui/lib/SelectField'; | ||
import MenuItem from 'material-ui/lib/menus/menu-item'; | ||
|
||
export default class SelectFieldExampleSimple extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.state = {value: 2}; | ||
} | ||
|
||
handleChange = (event, index, value) => this.setState({value}); | ||
|
||
render() { | ||
return ( | ||
<SelectField value={this.state.value} onChange={this.handleChange}> | ||
<MenuItem value={1} primaryText="Never"/> | ||
<MenuItem value={2} primaryText="Every Night"/> | ||
<MenuItem value={3} primaryText="Weeknights"/> | ||
<MenuItem value={4} primaryText="Weekends"/> | ||
<MenuItem value={5} primaryText="Weekly"/> | ||
</SelectField> | ||
); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
docs/src/app/components/pages/components/SelectField/Page.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import CodeExample from '../../../CodeExample'; | ||
import PropTypeDescription from '../../../PropTypeDescription'; | ||
import MarkdownElement from '../../../MarkdownElement'; | ||
|
||
import selectFieldReadmeText from './README'; | ||
import SelectFieldExampleSimple from './ExampleSimple'; | ||
import selectFieldExampleSimpleCode from '!raw!./ExampleSimple'; | ||
import SelectFieldExampleDisabled from './ExampleDisabled'; | ||
import selectFieldExampleDisabledCode from '!raw!./ExampleDisabled'; | ||
import SelectFieldExampleCustomLabel from './ExampleCustomLabel'; | ||
import selectFieldExampleCustomLabelCode from '!raw!./ExampleCustomLabel'; | ||
import SelectFieldExampleFloatingLabel from './ExampleFloatingLabel'; | ||
import selectFieldExampleFloatingLabelCode from '!raw!./ExampleFloatingLabel'; | ||
import SelectFieldExampleError from './ExampleError'; | ||
import selectFieldExampleErrorCode from '!raw!./ExampleError'; | ||
import selectFieldCode from '!raw!material-ui/lib/SelectField/SelectField'; | ||
|
||
const SelectFieldPage = () => ( | ||
<div> | ||
<MarkdownElement text={selectFieldReadmeText} /> | ||
<CodeExample code={selectFieldExampleSimpleCode}> | ||
<SelectFieldExampleSimple /> | ||
</CodeExample> | ||
<CodeExample code={selectFieldExampleDisabledCode}> | ||
<SelectFieldExampleDisabled /> | ||
</CodeExample> | ||
<CodeExample code={selectFieldExampleCustomLabelCode}> | ||
<SelectFieldExampleCustomLabel /> | ||
</CodeExample> | ||
<CodeExample code={selectFieldExampleFloatingLabelCode}> | ||
<SelectFieldExampleFloatingLabel /> | ||
</CodeExample> | ||
<CodeExample code={selectFieldExampleErrorCode}> | ||
<SelectFieldExampleError /> | ||
</CodeExample> | ||
<PropTypeDescription code={selectFieldCode}/> | ||
</div> | ||
); | ||
|
||
export default SelectFieldPage; |
6 changes: 6 additions & 0 deletions
6
docs/src/app/components/pages/components/SelectField/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
## Select Field | ||
|
||
To learn more about `SelectField` please visit the specifications | ||
[here](https://www.google.com/design/spec/components/menus.html#menus-usage). | ||
|
||
### Examples |
Oops, something went wrong.