This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
feat(Dropdown): add loading
prop
#729
Merged
Merged
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6d08667
feat(Dropdown): add `loading` prop
layershifter 00d8b83
push cleanups
layershifter de8fcc1
add changelog entry
layershifter d2564b3
add prototype
layershifter 36d2eef
revert some changes
layershifter 19e5d45
fix export names
layershifter 056f81e
Merge branches 'feat/dropdown-loading' and 'master' of https://github…
layershifter 8b61a89
more cleanups
layershifter ec5bb2a
more cleanups
layershifter 8fe5741
final cleanups
layershifter e908485
Merge branch 'master' of https://github.com/stardust-ui/react into fe…
layershifter 1b4772e
update description
layershifter ec11785
rename to `toggleIndicatorSize`
layershifter 0e3c61c
fix JSON mode
layershifter d88dbce
reduce items in example
layershifter e9cb73a
Merge branch 'master' of https://github.com/stardust-ui/react into fe…
layershifter 514c023
wip
layershifter 313d4ff
remove useless components
layershifter 0cdd20e
revert some changes
layershifter b00faa9
update comment
layershifter d14cef7
fix keys
layershifter 4d00a20
fix broken UT
layershifter d30c9f9
remove selector
layershifter 3a97807
Merge branches 'feat/dropdown-loading' and 'master' of https://github…
layershifter c14e633
Merge branches 'feat/dropdown-loading' and 'master' of https://github…
layershifter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
23 changes: 23 additions & 0 deletions
23
docs/src/examples/components/Dropdown/State/DropdownExampleLoading.knobs.tsx
This file contains hidden or 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,23 @@ | ||
import * as React from 'react' | ||
import Knobs from 'docs/src/components/Knobs/Knobs' | ||
|
||
type DropdownExampleLoadingKnobsProps = { | ||
loading?: boolean | ||
onKnobChange: () => void | ||
} | ||
|
||
const DropdownExampleLoadingKnobs: React.FC<DropdownExampleLoadingKnobsProps> = props => { | ||
const { loading, onKnobChange } = props | ||
|
||
return ( | ||
<Knobs> | ||
<Knobs.Boolean name="loading" onChange={onKnobChange} value={loading} /> | ||
</Knobs> | ||
) | ||
} | ||
|
||
DropdownExampleLoadingKnobs.defaultProps = { | ||
loading: true, | ||
} | ||
|
||
export default DropdownExampleLoadingKnobs |
17 changes: 17 additions & 0 deletions
17
docs/src/examples/components/Dropdown/State/DropdownExampleLoading.shorthand.tsx
This file contains hidden or 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 { Dropdown } from '@stardust-ui/react' | ||
import * as React from 'react' | ||
|
||
const inputItems = ['Bruce Wayne', 'Natasha Romanoff', 'Steven Strange', 'Alfred Pennyworth'] | ||
|
||
const DropdownExampleLoading: React.FC<{ knobs: { loading: boolean } }> = ({ knobs }) => ( | ||
<Dropdown | ||
loading={knobs.loading} | ||
loadingMessage="Loading..." | ||
multiple | ||
items={inputItems} | ||
placeholder="Start typing a name" | ||
search | ||
/> | ||
) | ||
|
||
export default DropdownExampleLoading |
This file contains hidden or 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,16 @@ | ||
import * as React from 'react' | ||
|
||
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
||
const State = () => ( | ||
<ExampleSection title="State"> | ||
<ComponentExample | ||
title="Loading" | ||
description="A dropdown can show that it is currently loading data." | ||
examplePath="components/Dropdown/State/DropdownExampleLoading" | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default State |
55 changes: 0 additions & 55 deletions
55
...es/components/Dropdown/Variations/DropdownExampleMultipleSearchToggleButton.shorthand.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
102 changes: 102 additions & 0 deletions
102
docs/src/prototypes/AsyncDropdownSearch/AsyncDropdownSearch.tsx
This file contains hidden or 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,102 @@ | ||
import { Divider, Dropdown, DropdownProps, Header, Loader, Segment } from '@stardust-ui/react' | ||
import * as faker from 'faker' | ||
import * as _ from 'lodash' | ||
import * as React from 'react' | ||
|
||
import CodeSnippet from '../../components/CodeSnippet' | ||
|
||
// ---------------------------------------- | ||
// Types | ||
// ---------------------------------------- | ||
type Entry = { | ||
header: string | ||
image: string | ||
content: string | ||
} | ||
|
||
interface SearchPageState { | ||
loading: boolean | ||
items: Entry[] | ||
searchQuery: string | ||
value: Entry[] | ||
} | ||
|
||
// ---------------------------------------- | ||
// Mock Data | ||
// ---------------------------------------- | ||
const createEntry = (): Entry => ({ | ||
image: faker.internet.avatar(), | ||
header: `${faker.name.firstName()} ${faker.name.lastName()}`, | ||
content: faker.commerce.department(), | ||
}) | ||
|
||
// ---------------------------------------- | ||
// Prototype Search Page View | ||
// ---------------------------------------- | ||
class AsyncDropdownSearch extends React.Component<{}, SearchPageState> { | ||
state = { | ||
loading: false, | ||
searchQuery: '', | ||
items: [], | ||
value: [], | ||
} | ||
|
||
searchTimer: number | ||
|
||
handleSelectedChange = (e: React.SyntheticEvent, { searchQuery, value }: DropdownProps) => { | ||
this.setState({ value: value as Entry[], searchQuery }) | ||
} | ||
|
||
handleSearchQueryChange = (e: React.SyntheticEvent, { searchQuery }: DropdownProps) => { | ||
this.setState({ searchQuery }) | ||
this.fetchItems() | ||
} | ||
|
||
fetchItems = () => { | ||
clearTimeout(this.searchTimer) | ||
this.setState({ loading: true }) | ||
|
||
this.searchTimer = setTimeout(() => { | ||
this.setState(prevState => ({ | ||
loading: false, | ||
items: [...prevState.items, ..._.times<Entry>(10, createEntry)], | ||
})) | ||
}, 2000) | ||
} | ||
|
||
render() { | ||
const { items, loading, searchQuery, value } = this.state | ||
|
||
return ( | ||
<div style={{ margin: 20 }}> | ||
<Segment> | ||
<Header content="Async Dropdown Search" /> | ||
<p>Use the field to perform a simulated search.</p> | ||
</Segment> | ||
|
||
<Segment> | ||
<Dropdown | ||
fluid | ||
items={items} | ||
loading={loading} | ||
loadingMessage={{ | ||
content: <Loader inline label="Loading..." labelPosition="end" size="larger" />, | ||
}} | ||
multiple | ||
onSearchQueryChange={this.handleSearchQueryChange} | ||
onSelectedChange={this.handleSelectedChange} | ||
placeholder="Try to enter something..." | ||
search | ||
searchQuery={searchQuery} | ||
toggleIndicator={false} | ||
value={value} | ||
/> | ||
<Divider /> | ||
<CodeSnippet mode="json" value={this.state} /> | ||
</Segment> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default AsyncDropdownSearch |
This file contains hidden or 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 @@ | ||
export { default } from './AsyncDropdownSearch' |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.