|
|
@ -41,7 +41,11 @@ class Dropdown extends React.Component {
|
|
|
|
background: ${COLORS.BLACK};
|
|
|
|
background: ${COLORS.BLACK};
|
|
|
|
user-select: none;
|
|
|
|
user-select: none;
|
|
|
|
padding: 8px 16px;
|
|
|
|
padding: 8px 16px;
|
|
|
|
border-bottom: 1px solid ${COLORS.SECONDARY};
|
|
|
|
border-bottom: 1px solid ${this.props.color || COLORS.SECONDARY};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dropdown-list-item span {
|
|
|
|
|
|
|
|
color: ${this.props.color || '#fff'};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dropdown-list-item:hover {
|
|
|
|
.dropdown-list-item:hover {
|
|
|
@ -58,8 +62,11 @@ class Dropdown extends React.Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const color = this.props.color || COLORS.SECONDARY
|
|
|
|
|
|
|
|
|
|
|
|
// find longest list value in number of characters
|
|
|
|
// find longest list value in number of characters
|
|
|
|
const MIN_WIDTH = this.props.list.reduce(
|
|
|
|
const list = this.props.button ? [...this.props.list, this.props.selected] : this.props.list
|
|
|
|
|
|
|
|
const MIN_WIDTH = list.reduce(
|
|
|
|
(max, { name }) => (name && name.length > max ? name.length : max),
|
|
|
|
(max, { name }) => (name && name.length > max ? name.length : max),
|
|
|
|
0
|
|
|
|
0
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -67,13 +74,13 @@ class Dropdown extends React.Component {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
className="dropdown-container"
|
|
|
|
className="dropdown-container"
|
|
|
|
style={{ minWidth: MIN_WIDTH * 14 }}
|
|
|
|
style={{ minWidth: MIN_WIDTH * 10 + 32 }}
|
|
|
|
onClick={this.toggle}
|
|
|
|
onClick={this.toggle}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<div className={`dropdown-display ${this.state.isVisible ? 'is-visible' : ''}`}>
|
|
|
|
<div className={`dropdown-display ${this.state.isVisible ? 'is-visible' : ''}`}>
|
|
|
|
<span style={{ minWidth: '4rem' }}>{this.props.selected.name}</span>
|
|
|
|
<span style={{ minWidth: '4rem' }}>{this.props.selected.name}</span>
|
|
|
|
<div className="arrow-down">
|
|
|
|
<div className="arrow-down">
|
|
|
|
<ArrowDown />
|
|
|
|
<ArrowDown fill={color} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="dropdown-list">{this.renderListItems()}</div>
|
|
|
|
<div className="dropdown-list">{this.renderListItems()}</div>
|
|
|
@ -98,7 +105,7 @@ class Dropdown extends React.Component {
|
|
|
|
|
|
|
|
|
|
|
|
.dropdown-display {
|
|
|
|
.dropdown-display {
|
|
|
|
height: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border: 1px solid ${COLORS.SECONDARY};
|
|
|
|
border: 1px solid ${color};
|
|
|
|
border-radius: 3px;
|
|
|
|
border-radius: 3px;
|
|
|
|
user-select: none;
|
|
|
|
user-select: none;
|
|
|
|
padding: 8px 16px;
|
|
|
|
padding: 8px 16px;
|
|
|
@ -109,6 +116,10 @@ class Dropdown extends React.Component {
|
|
|
|
z-index: 1;
|
|
|
|
z-index: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.dropdown-display span {
|
|
|
|
|
|
|
|
color: ${color};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.dropdown-display:hover {
|
|
|
|
.dropdown-display:hover {
|
|
|
|
background: ${COLORS.HOVER};
|
|
|
|
background: ${COLORS.HOVER};
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,7 +131,7 @@ class Dropdown extends React.Component {
|
|
|
|
.dropdown-list {
|
|
|
|
.dropdown-list {
|
|
|
|
display: none;
|
|
|
|
display: none;
|
|
|
|
margin-top: -1px;
|
|
|
|
margin-top: -1px;
|
|
|
|
border: 1px solid ${COLORS.SECONDARY};
|
|
|
|
border: 1px solid ${color};
|
|
|
|
border-radius: 0px 0px 3px 3px;
|
|
|
|
border-radius: 0px 0px 3px 3px;
|
|
|
|
max-height: 350px;
|
|
|
|
max-height: 350px;
|
|
|
|
overflow-y: scroll;
|
|
|
|
overflow-y: scroll;
|
|
|
|