-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1db707
commit cc91c86
Showing
4 changed files
with
138 additions
and
105 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
docs/app/Examples/modules/Dropdown/Content/AsyncOptions.js
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,39 @@ | ||
import _ from 'lodash' | ||
import React, { Component } from 'react' | ||
import { Button, Dropdown } from 'stardust' | ||
import faker from 'faker' | ||
|
||
export default class DropdownAsyncOptions extends Component { | ||
state = { isFetching: false } | ||
|
||
updateItems = () => { | ||
this.setState({ isFetching: true }) | ||
|
||
// fake api call | ||
setTimeout(() => { | ||
this.setState({ | ||
isFetching: false, | ||
options: _.times(50, () => { | ||
const name = faker.name.findName() | ||
return { text: name, value: name } | ||
}), | ||
}) | ||
}, 1000) | ||
} | ||
|
||
render() { | ||
const { options, isFetching } = this.state | ||
return ( | ||
<div> | ||
<Button onClick={this.updateItems}> | ||
Fetch Items | ||
</Button> | ||
<Dropdown | ||
className={`search selection multiple ${isFetching && 'disabled loading'}`} | ||
defaultText='Dropdown' | ||
options={options} | ||
/> | ||
</div> | ||
) | ||
} | ||
} |
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,17 @@ | ||
import React, { Component } from 'react' | ||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
export default class DropdownContentExamples extends Component { | ||
render() { | ||
return ( | ||
<ExampleSection title='Content'> | ||
<ComponentExample | ||
title='Async Options' | ||
description="A dropdown's options can change over time" | ||
examplePath='modules/Dropdown/Content/AsyncOptions' | ||
/> | ||
</ExampleSection> | ||
) | ||
} | ||
} |
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