Skip to content

Commit e10db92

Browse files
committed
added disabled option
1 parent 03ba575 commit e10db92

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

dropdown.scss

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$default-text-hover-color: black;
33
$default-hover-color: #cde4f5;
44
$default-text-color: #fff;
5+
$disabled-text-color: #555;
56
$option-padding: 4px 10px;
67

78
.dropdown {
@@ -79,6 +80,11 @@ $option-padding: 4px 10px;
7980
var(--main-el-border-radius);
8081
}
8182
}
83+
84+
&.disabled {
85+
color: $disabled-text-color;
86+
cursor: not-allowed;
87+
}
8288
}
8389
.dropdown.expanded {
8490
background: var(--dropdown-expanded-color);

dropdown.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<div
33
class="dropdown"
4-
@click.stop="toggleDropdownOptions"
5-
:class="{ expanded: isExpanded }"*
4+
@click.stop="checkDropdownHandler"
5+
:class="{ expanded: isExpanded, disabled: config.disabled }"
66
:style="computedStyles"
77
>
88
<div class="dropdown-label-container">
@@ -47,6 +47,7 @@
4747
backgroundColor: "#cde4f5",
4848
backgroundExpandedColor: "#fff",
4949
hoverBackgroundColor: "#0084d4",
50+
disabledBackgroundColor: "#ccc",
5051
isExpanded: false,
5152
placeholder: "Placeholder",
5253
textColor: "black",
@@ -65,7 +66,7 @@
6566
{"--option-height": this.optionHeight + "px"},
6667
{"--main-el-border-radius": this.borderRadius},
6768
{"--dropdown-width": this.width + "px"},
68-
{"--dropdown-background-color": this.backgroundColor},
69+
{"--dropdown-background-color": this.config.disabled ? this.disabledBackgroundColor : this.backgroundColor},
6970
{"--dropdown-expanded-color": this.backgroundExpandedColor},
7071
{"--dropdown-border": this.border},
7172
{"--dropdown-hover-background-color": this.hoverBackgroundColor},
@@ -142,7 +143,12 @@
142143
if (this.isExpanded) {
143144
this.isExpanded = false
144145
}
145-
}
146+
},
147+
checkDropdownHandler() {
148+
if (!this.config.disabled) {
149+
this.toggleDropdownOptions()
150+
}
151+
},
146152
},
147153
created() {
148154
document.addEventListener('click', this.documentClicked);

0 commit comments

Comments
 (0)