Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Dropdown): Single selection #584

Merged
merged 65 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
431268c
crude implementation
Dec 10, 2018
2ee1b5e
fixed the toggle and added/refactored styles
Dec 11, 2018
b959dd9
fixed the filtering to work for all variants
Dec 11, 2018
c0482c5
made the toggleButton tabbable by default
Dec 11, 2018
5fe6ed7
fixed style case active+focus
Dec 11, 2018
8a8882d
fixed wrong import
Dec 11, 2018
92ad9c0
fixed ariaLabel for trigger button
Dec 11, 2018
55e9807
added list focus and accessibility handling for it
Dec 12, 2018
0f294b2
fixed toggle button bug that appeared after trigger fix
Dec 13, 2018
27396f1
reverted change for filteredItems
Dec 13, 2018
35d7e53
refactored the renderComponent to pass conformance
Dec 13, 2018
fc64c6d
fixed button focus at selection
Dec 13, 2018
8b24b0c
merged ref code review improvement
Dec 13, 2018
a2b3424
removed unneeded code
Dec 13, 2018
bc88b89
removed ternary condition
Dec 14, 2018
eabbbe1
replaced some heights to make toggle button appear centered
Jan 2, 2019
50700a4
improvements on styles from code review
Jan 2, 2019
0d7a892
replaced Icon with unicode char for theme consistency
Jan 3, 2019
1bdf704
some more review comments handled
Jan 3, 2019
518dad5
some more code improvements in Dropdown
Jan 3, 2019
3cdc8d8
replaced right margin with padding for combobox
Jan 3, 2019
bb670f9
used functional components in the examples
Jan 3, 2019
c851c13
overriding downshift aria label for the toggle button
Jan 3, 2019
58c41a8
made the toggle button arrow non-selectable
Jan 3, 2019
96a61ab
used a lodash util instead of filter
Jan 3, 2019
97758c2
used buttonNode for consistency
Jan 4, 2019
c28f7c5
apply tabIndex only if dropdown is non-search
Jan 4, 2019
1563a65
Revert "used buttonNode for consistency"
Jan 4, 2019
5e4dc81
refactored the Refs use in Dropdown
Jan 4, 2019
14532ef
crude implementation
Dec 10, 2018
7e870fe
fixed the toggle and added/refactored styles
Dec 11, 2018
ee95d06
fixed the filtering to work for all variants
Dec 11, 2018
bcd061a
made the toggleButton tabbable by default
Dec 11, 2018
7d69d08
fixed style case active+focus
Dec 11, 2018
75ee900
fixed wrong import
Dec 11, 2018
8684525
fixed ariaLabel for trigger button
Dec 11, 2018
8a60271
added list focus and accessibility handling for it
Dec 12, 2018
5aa379e
fixed toggle button bug that appeared after trigger fix
Dec 13, 2018
eeaf144
reverted change for filteredItems
Dec 13, 2018
c286133
refactored the renderComponent to pass conformance
Dec 13, 2018
1ec2028
fixed button focus at selection
Dec 13, 2018
c19c12f
merged ref code review improvement
Dec 13, 2018
862c4bd
removed unneeded code
Dec 13, 2018
945bb95
removed ternary condition
Dec 14, 2018
0675513
replaced some heights to make toggle button appear centered
Jan 2, 2019
c571d92
improvements on styles from code review
Jan 2, 2019
277175e
replaced Icon with unicode char for theme consistency
Jan 3, 2019
83fc34d
some more review comments handled
Jan 3, 2019
cf48f4b
some more code improvements in Dropdown
Jan 3, 2019
b9d5412
replaced right margin with padding for combobox
Jan 3, 2019
d2ae9e1
used functional components in the examples
Jan 3, 2019
5882ab8
overriding downshift aria label for the toggle button
Jan 3, 2019
0350af6
made the toggle button arrow non-selectable
Jan 3, 2019
d13c089
used a lodash util instead of filter
Jan 3, 2019
40744a7
used buttonNode for consistency
Jan 4, 2019
390999a
apply tabIndex only if dropdown is non-search
Jan 4, 2019
6c54706
Revert "used buttonNode for consistency"
Jan 4, 2019
0c97678
refactored the Refs use in Dropdown
Jan 4, 2019
4996260
updated changelog
Jan 4, 2019
afeefa0
Merge branch 'feat/selection-dropdown' of https://github.com/stardust…
Jan 8, 2019
2b7f913
-added white background on the list in the Dropdown for fixing transp…
Jan 8, 2019
8244c86
Merge branch 'master' into feat/selection-dropdown
Jan 8, 2019
5d49229
-fixed changelog
Jan 8, 2019
f17b5b1
removed '.shorthand' from examplePath
Jan 8, 2019
36a34f7
Merge branch 'master' into feat/selection-dropdown
Jan 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Features
- Add `on` and `mouseLeaveDelay` props to `Popup` component @mnajdova ([#622](https://github.com/stardust-ui/react/pull/622))
- Add Dropdown Single Selection variant @silviuavram ([#584](https://github.com/stardust-ui/react/pull/584))

<!--------------------------------[ v0.16.0 ]------------------------------- -->
## [v0.16.0](https://github.com/stardust-ui/react/tree/v0.16.0) (2019-01-07)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@ const inputItems = [
'Selina Kyle',
]

class DropdownExample extends React.Component {
render() {
return (
<Dropdown
multiple
search
getA11ySelectionMessage={getA11ySelectionMessage}
getA11yStatusMessage={getA11yStatusMessage}
noResultsMessage="We couldn't find any matches."
placeholder="Start typing a name"
items={inputItems}
/>
)
}
}
const DropdownExample = () => (
<Dropdown
multiple
search
getA11ySelectionMessage={getA11ySelectionMessage}
getA11yStatusMessage={getA11yStatusMessage}
noResultsMessage="We couldn't find any matches."
placeholder="Start typing a name"
items={inputItems}
/>
)
silviuaavram marked this conversation as resolved.
Show resolved Hide resolved

const getA11ySelectionMessage = {
onAdd: item => `${item} has been selected.`,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as React from 'react'
import { Dropdown } from '@stardust-ui/react'

const inputItems = [
'Bruce Wayne',
'Natasha Romanoff',
'Steven Strange',
'Alfred Pennyworth',
`Scarlett O'Hara`,
'Imperator Furiosa',
'Bruce Banner',
'Peter Parker',
'Selina Kyle',
]

const DropdownExample = () => (
<Dropdown
getA11yStatusMessage={getA11yStatusMessage}
getA11ySelectionMessage={{
onAdd: item => `${item} has been selected.`,
}}
placeholder="Select your hero"
items={inputItems}
/>
)

const getA11yStatusMessage = ({
isOpen,
itemToString,
previousResultCount,
resultCount,
selectedItem,
}) => {
if (!isOpen) {
return selectedItem ? itemToString(selectedItem) : ''
}
if (!resultCount) {
return 'No results are available.'
}
if (resultCount !== previousResultCount) {
return `${resultCount} result${
resultCount === 1 ? ' is' : 's are'
} available, use up and down arrow keys to navigate. Press Enter key to select.`
}
return ''
}

export default DropdownExample
5 changes: 5 additions & 0 deletions docs/src/examples/components/Dropdown/Types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Types = () => (
<ExampleSection title="Types">
<ComponentExample
title="Single Selection"
description="A dropdown with single selection."
examplePath="components/Dropdown/Types/DropdownExampleSingleSelection.shorthand"
silviuaavram marked this conversation as resolved.
Show resolved Hide resolved
/>
<ComponentExample
title="Multiple Search"
description="A dropdown with multiple selection and search."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,18 @@ const inputItems = [
'Peter Parker',
'Selina Kyle',
]

class DropdownExample extends React.Component {
render() {
return (
<Dropdown
multiple
getA11ySelectionMessage={getA11ySelectionMessage}
getA11yStatusMessage={getA11yStatusMessage}
noResultsMessage="We couldn't find any matches."
search
fluid
placeholder="Start typing a name"
items={inputItems}
/>
)
}
}
const DropdownExample = () => (
<Dropdown
multiple
getA11ySelectionMessage={getA11ySelectionMessage}
getA11yStatusMessage={getA11yStatusMessage}
noResultsMessage="We couldn't find any matches."
search
fluid
placeholder="Start typing a name"
items={inputItems}
/>
)

const getA11ySelectionMessage = {
onAdd: item => `${item} has been selected.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,17 @@ const inputItems = [
},
]

class DropdownExample extends React.Component {
render() {
return (
<Dropdown
multiple
getA11yStatusMessage={getA11yStatusMessage}
search
getA11ySelectionMessage={getA11ySelectionMessage}
noResultsMessage="We couldn't find any matches."
placeholder="Start typing a name"
items={inputItems}
/>
)
}
}
const DropdownExample = () => (
<Dropdown
multiple
getA11yStatusMessage={getA11yStatusMessage}
search
getA11ySelectionMessage={getA11ySelectionMessage}
noResultsMessage="We couldn't find any matches."
placeholder="Start typing a name"
items={inputItems}
/>
)

const getA11ySelectionMessage = {
onAdd: item => `${item.header} has been selected.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,18 @@ const inputItems = [
'Selina Kyle',
]

class DropdownExample extends React.Component {
render() {
return (
<Dropdown
multiple
getA11yStatusMessage={getA11yStatusMessage}
getA11ySelectionMessage={getA11ySelectionMessage}
noResultsMessage="We couldn't find any matches."
search
placeholder="Start typing a name"
toggleButton
items={inputItems}
/>
)
}
}
const DropdownExample = () => (
<Dropdown
multiple
getA11yStatusMessage={getA11yStatusMessage}
getA11ySelectionMessage={getA11ySelectionMessage}
noResultsMessage="We couldn't find any matches."
search
placeholder="Start typing a name"
toggleButton
items={inputItems}
/>
)

const getA11ySelectionMessage = {
onAdd: item => `${item} has been selected.`,
Expand Down
Loading