mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
[Ivan Diaz] - Update dropdown component
This commit is contained in:
parent
6fa28619bd
commit
b054381bb1
@ -48,7 +48,7 @@ var DropDown = React.createClass({
|
|||||||
var animation = this.getAnimationStyles();
|
var animation = this.getAnimationStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="drop-down">
|
<div className={this.getClass()}>
|
||||||
<div className="drop-down--current" onClick={this.getClickCallback(this.getSelectedIndex())}>
|
<div className="drop-down--current" onClick={this.getClickCallback(this.getSelectedIndex())}>
|
||||||
{this.props.items[this.getSelectedIndex()]}
|
{this.props.items[this.getSelectedIndex()]}
|
||||||
</div>
|
</div>
|
||||||
@ -72,17 +72,21 @@ var DropDown = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderItem(item, index) {
|
renderItem(item, index) {
|
||||||
var render = null;
|
return (
|
||||||
|
<li className="drop-down--list-item" onClick={this.getClickCallback(index)}>
|
||||||
|
{item}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
if (index !== this.state.selectedIndex) {
|
getClass() {
|
||||||
render = (
|
var classes = {
|
||||||
<li className="drop-down--list-item" onClick={this.getClickCallback(index)}>
|
'drop-down': true,
|
||||||
{item}
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return render;
|
[this.props.className]: (this.props.className)
|
||||||
|
};
|
||||||
|
|
||||||
|
return classNames(classes);
|
||||||
},
|
},
|
||||||
|
|
||||||
getClickCallback(index) {
|
getClickCallback(index) {
|
||||||
@ -90,16 +94,10 @@ var DropDown = React.createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleClick(index) {
|
handleClick(index) {
|
||||||
if (this.getSelectedIndex() === index) {
|
this.setState({
|
||||||
this.setState({
|
opened: !this.state.opened,
|
||||||
opened: !this.state.opened
|
selectedIndex: index
|
||||||
});
|
});
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.setState({
|
|
||||||
selectedIndex: index
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getSelectedIndex() {
|
getSelectedIndex() {
|
||||||
|
@ -8,13 +8,16 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&--current {
|
&--current {
|
||||||
color: $primary-black;
|
|
||||||
background-color: $light-grey;
|
background-color: $light-grey;
|
||||||
padding: 8px;
|
border-radius: 4px 4px 0 0;
|
||||||
|
color: $primary-black;
|
||||||
|
padding: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--list-container {
|
&--list-container {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
position: absolute;
|
||||||
|
width: 150px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&--list {
|
&--list {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user