gctGenerator/site/.vuepress/components/SelectComponent.vue

107 lines
2 KiB
Vue
Raw Normal View History

2020-06-28 06:33:20 +09:00
<template>
<div :class="disabled ? 'select-wrapper disabled' : 'select-wrapper'">
2020-07-01 14:26:48 +09:00
<select @change="(e) => this.onChange(e.target.value)" autocomplete="off" :disabled="disabled">
2020-06-29 00:35:18 +09:00
<option v-if="placeholder != null" selected disabled>
{{ placeholder }}
2020-06-29 00:35:18 +09:00
</option>
2020-06-28 06:33:20 +09:00
<option
2021-06-11 07:48:15 +09:00
v-for="(option, idx) in options"
v-bind:key="idx"
2020-06-28 06:33:20 +09:00
:value="option.value"
:selected="selectedValue && option.value === selectedValue"
>
2020-09-08 00:52:26 +09:00
{{ getLabel(option.label) }}
</option>
2020-06-28 06:33:20 +09:00
</select>
</div>
</template>
<script>
2020-07-04 02:23:15 +09:00
import { translate } from '../i18n/localeHelper';
2020-06-28 06:33:20 +09:00
export default {
props: {
disabled: { type: Boolean },
2020-06-28 06:33:20 +09:00
selectedValue: { type: String },
placeholder: { type: String },
options: { type: Array },
onChange: { type: Function },
2020-06-28 06:33:20 +09:00
},
data() {
return {};
},
2020-07-04 02:23:15 +09:00
methods: {
getLabel(key) {
return translate(key, this.$lang);
},
},
2020-06-28 06:33:20 +09:00
};
</script>
<style scoped>
.select-wrapper {
position: relative;
display: inline-block;
max-width: 400px;
min-width: 180px;
2020-06-28 09:31:31 +09:00
width: 100%;
2020-06-28 06:33:20 +09:00
margin: 0 auto;
background-color: #3eaf7c;
z-index: 10;
}
.select-wrapper.disabled,
.select-wrapper.disabled select {
background-color: rgb(165, 165, 165);
cursor: not-allowed;
}
2020-06-28 06:33:20 +09:00
select {
border: none;
outline: none;
background: transparent;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border-radius: 0;
margin: 0;
display: block;
width: 100%;
padding: 6px 55px 6px 15px;
font-size: 14px;
color: white;
font-weight: bold;
cursor: pointer;
2020-06-28 09:46:48 +09:00
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
2020-06-28 06:33:20 +09:00
}
2020-06-29 00:35:18 +09:00
select::-ms-expand {
display: none;
}
2020-06-28 06:33:20 +09:00
.select-wrapper:hover {
background-color: #47c38b;
}
select option {
color: black;
font-weight: normal;
}
.select-wrapper:after {
position: absolute;
2020-06-28 09:46:48 +09:00
right: 0px;
top: 3px;
width: 40px;
2020-06-28 06:33:20 +09:00
height: 100%;
content: '\25BC';
2020-06-28 06:33:20 +09:00
text-align: center;
color: white;
2020-06-28 09:46:48 +09:00
font-size: 14px;
2020-06-28 06:33:20 +09:00
z-index: -1;
}
</style>