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

Feat/multi dropdown component #422

Merged
merged 87 commits into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
090db96
first changes picked up from people picker prototype
Oct 29, 2018
e51d086
added state reducer and created test component to refresh items prop
Oct 29, 2018
e7ec250
fixed mouse selection and removed downshift selectedItem on multiple
Nov 1, 2018
04308ec
removed label, its style and fixed width
Nov 2, 2018
5b68b28
fixed maxWidth, backspace deletion and label for remove button
Nov 2, 2018
eaf0684
added the content color list item variable back
Nov 5, 2018
b091d31
added toggle button to the dropdown
Nov 6, 2018
ad3e75e
added list inside container to fix width issue
Nov 6, 2018
4a8f3f6
added fluid prop changes
Nov 7, 2018
bc3ea74
added white background on no results list item
Nov 7, 2018
2a6b8ea
added toggle button conditional padding
Nov 7, 2018
2e84331
destructured some props in styles
Nov 7, 2018
67a0eea
added more examples and on search change callback
Nov 7, 2018
4a6ae65
added example with only text items, made content mandatory
Nov 8, 2018
f6daaa9
reverted header and content optional property
Nov 8, 2018
1cff228
stopped click propagation on label content
Nov 8, 2018
27479d9
changed the var names for input and active
Nov 8, 2018
e29a8ee
moved downshift to dependencies
Nov 8, 2018
e54deb7
added callbacks for generating custom dropdown messages
Nov 8, 2018
586249b
made the dropdown an autocontrolled component
Nov 9, 2018
2745f7d
moved some examples to variations
Nov 12, 2018
c6eb13e
stop propagation when clicking on label header and image
Nov 13, 2018
a9c3c9a
some typings and applied optional props correctly
Nov 13, 2018
e319734
fixed the conditional parameters passing
Nov 13, 2018
267fa1d
exposed optional prop itemToString
Nov 13, 2018
78d5d5f
added container styles as classNames
Nov 13, 2018
9375a90
added typings for the rest of the methods
Nov 14, 2018
3eadd3b
adressed some conformance errors
Nov 14, 2018
2c6964a
added isConformant test
Nov 14, 2018
a0d3f21
added and renamed event handlers
Nov 14, 2018
d12f2ad
added isconformant test for dropdown
Nov 15, 2018
a97c084
rename onChange methods to make test pass [hack to remove]
Nov 15, 2018
2875cb2
refactored ref from slot
Nov 16, 2018
e455868
updated styles after rebase
Nov 16, 2018
9ae571a
moved desc to interface, prop renames, custom a11status
Nov 19, 2018
8834721
refactored the aria live implementation for add and remove
Nov 19, 2018
c73b747
fixed StatusMessageOptions type issue
Nov 19, 2018
8d1629d
addded listRef back with correct implementation
Nov 19, 2018
5578134
added listRef callback directly
Nov 19, 2018
b7454e0
removed comment from test file
Nov 19, 2018
10f3298
commited lock
Nov 19, 2018
9c1a589
updated the styles
Nov 20, 2018
2da8b2e
refactored the refs
Nov 20, 2018
0474757
fixed list and menu overlapping
Nov 20, 2018
842316b
added the scroll bar back
Nov 20, 2018
5086ed6
renamed the ref providing wrapper
Nov 20, 2018
a817823
refactored the examples, added placeholder to all
Nov 20, 2018
a10110f
addressed Marija and Sofiya code reviews
Nov 22, 2018
c8cb13a
moved innerRef prop from Input to Slot
Nov 22, 2018
d34e6d5
removed onContainerClick prop
Nov 22, 2018
2d95fed
removed onBackspaceDelete prop
Nov 22, 2018
1ebe21e
added shorthands for Label and ListItem in Dropdown
Nov 27, 2018
df884ea
changed some propTypes
Nov 27, 2018
345cadf
shorthanded the input
Nov 29, 2018
cdd8780
strings for example, downshift props as handled objects
Nov 30, 2018
85d085d
changes in the descriptions of the api
Nov 30, 2018
c081907
integrated filtering of options to the component
Dec 5, 2018
d1865fe
merged master and fixed conflicts
Dec 5, 2018
c925e86
addressed commonPropTypes changes
Dec 5, 2018
461514f
renamed onChange to onSelectedChange
Dec 5, 2018
d854fc7
added changes to the api description, also code comments
Dec 5, 2018
763afb8
updated the texts for the subcomponents as well
Dec 5, 2018
8d4f12f
subcomponents as static fields of the dropdown, and some text correction
Dec 5, 2018
1e9fe66
added image shorthand to list item media + highlighted is active now
Dec 6, 2018
a095231
fixed UTs
Dec 6, 2018
d5bd4be
removed the render functions from shorthands
Dec 6, 2018
63bc16d
changes related to applying styles
Dec 6, 2018
6a210bd
changed the examples to reflect text as being the default item
Dec 6, 2018
f6b7122
added additional check for refProvidingWrapper
Dec 6, 2018
d5ed736
fixed the inner ref issue accordingly
Dec 6, 2018
08b1396
fixed input styles
Dec 6, 2018
2d853c3
removed the aria live strings from the component
Dec 6, 2018
587fe68
remove unnecessary state from examples
kuzhelov-ms Dec 7, 2018
f4a146e
addressed code review
Dec 7, 2018
359fea1
removed no items text from component, added to examples
Dec 8, 2018
cb1f066
removed unused variables param
Dec 8, 2018
6f22327
remove leftovers from docs, simplify props descriptions
kuzhelov-ms Dec 9, 2018
cbb7282
refactor and apply fixes to Dropdown
kuzhelov-ms Dec 9, 2018
da15cac
introduce fixes to DropdownLabel
kuzhelov-ms Dec 9, 2018
f3776be
fix generic parameters of prop types for dropdown components
kuzhelov-ms Dec 9, 2018
131c17c
pass styles to DropdownLabel instead of classes
kuzhelov-ms Dec 9, 2018
27f57d8
add fogottent prop to theme styles types
kuzhelov-ms Dec 9, 2018
4259f53
prevent downshift dependency to leak through the public API
kuzhelov-ms Dec 9, 2018
585168d
Merge branch 'master' into feat/multi-dropdown-component
kuzhelov Dec 9, 2018
345e551
fix lint issues
kuzhelov-ms Dec 10, 2018
4d17654
remove duplicated input example
kuzhelov-ms Dec 10, 2018
3258d9b
update changelog
kuzhelov-ms Dec 10, 2018
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 @@ -32,6 +32,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Features
- `Ref` components uses `forwardRef` API by default @layershifter ([#491](https://github.com/stardust-ui/react/pull/491))
- Label Processed Teams icons moved to Stardust theme @kuzhelov ([#574](https://github.com/stardust-ui/react/pull/574))
- Add `Dropdown` component @silviuavram ([#422](https://github.com/stardust-ui/react/pull/422))

### Documentation
- Add `prettier` support throughout the docs @levithomason ([#568](https://github.com/stardust-ui/react/pull/568))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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',
]

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 getA11ySelectionMessage = {
onAdd: item => `${item} has been selected.`,
onRemove: item => `${item} has been removed.`,
}

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
15 changes: 15 additions & 0 deletions docs/src/examples/components/Dropdown/Types/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as React from 'react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Types = () => (
<ExampleSection title="Types">
<ComponentExample
title="Multiple Search"
description="A dropdown with multiple selection and search."
examplePath="components/Dropdown/Types/DropdownExampleMultipleSearch.shorthand"
/>
</ExampleSection>
)

export default Types
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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',
]

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 getA11ySelectionMessage = {
onAdd: item => `${item} has been selected.`,
onRemove: item => `${item} has been removed.`,
}

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import * as React from 'react'
import { Dropdown } from '@stardust-ui/react'

const inputItems = [
{
header: 'Bruce Wayne',
image: 'public/images/avatar/small/matt.jpg',
content: 'Software Engineer',
},
{
header: 'Natasha Romanoff',
image: 'public/images/avatar/small/jenny.jpg',
content: 'UX Designer 2',
},
{
header: 'Steven Strange',
image: 'public/images/avatar/small/joe.jpg',
content: 'Principal Software Engineering Manager',
},
{
header: 'Alfred Pennyworth',
image: 'public/images/avatar/small/justen.jpg',
content: 'Technology Consultant',
},
{
header: `Scarlett O'Hara`,
image: 'public/images/avatar/small/laura.jpg',
content: 'Software Engineer 2',
},
{
header: 'Imperator Furiosa',
image: 'public/images/avatar/small/veronika.jpg',
content: 'Boss',
},
{
header: 'Bruce Banner',
image: 'public/images/avatar/small/chris.jpg',
content: 'Senior Computer Scientist',
},
{
header: 'Peter Parker',
image: 'public/images/avatar/small/daniel.jpg',
content: 'Partner Software Engineer',
},
{
header: 'Selina Kyle',
image: 'public/images/avatar/small/ade.jpg',
content: 'Graphic Designer',
},
]

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 getA11ySelectionMessage = {
onAdd: item => `${item.header} has been selected.`,
onRemove: item => `${item.header} has been removed.`,
}

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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',
]

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 getA11ySelectionMessage = {
onAdd: item => `${item} has been selected.`,
onRemove: item => `${item} has been removed.`,
}

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
25 changes: 25 additions & 0 deletions docs/src/examples/components/Dropdown/Variations/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection'

const Variations = () => (
<ExampleSection title="Variations">
<ComponentExample
title="Multiple Search with Image and Content"
description="A multiple search dropdown which items have header, content and image."
examplePath="components/Dropdown/Variations/DropdownExampleMultipleSearchImageAndContent.shorthand"
/>
<ComponentExample
title="Multiple Search Fluid"
description="A multiple search dropdown that fits the width of the container."
examplePath="components/Dropdown/Variations/DropdownExampleMultipleSearchFluid.shorthand"
/>
<ComponentExample
title="Multiple Search with Toggle Button"
description="A multiple search dropdown with toggle button that shows/hides the items list."
examplePath="components/Dropdown/Variations/DropdownExampleMultipleSearchToggleButton.shorthand"
/>
</ExampleSection>
)

export default Variations
12 changes: 12 additions & 0 deletions docs/src/examples/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react'
import Types from './Types'
import Variations from './Variations'

const DropdownExamples = () => (
<div>
<Types />
<Variations />
</div>
)

export default DropdownExamples
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ const InputExampleInputSlot = () => (
/>
}
/>

<Text content="Wrapped Input with custom element:" />
<Input
placeholder="Search..."
role="presentation"
input={<input placeholder="Placeholder Override..." role="checkbox" style={inputStyles} />}
/>
</Grid>
)

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"dependencies": {
"classnames": "^2.2.5",
"color": "^3.1.0",
"downshift": "^3.0.0",
"fela": "^6.1.7",
"fela-plugin-fallback-value": "^5.0.17",
"fela-plugin-placeholder-prefixer": "^5.0.18",
Expand Down
Loading