Skip to content

Commit 6f09c17

Browse files
committed
Add Vocabulary Select implementation instead of buefy select
1 parent 6866aac commit 6f09c17

File tree

3 files changed

+97
-22
lines changed

3 files changed

+97
-22
lines changed

src/App.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,10 @@ export default {
140140
@import "~bulma";
141141
@import '~buefy/src/scss/utils/_variables.scss';
142142
@import '~buefy/src/scss/components/_modal.scss';
143-
@import '~buefy/src/scss/components/_select.scss';
144143
@import '~buefy/src/scss/components/_form.scss';
145144
@import '~buefy/src/scss/components/_icon.scss';
146145
147-
@import "@creativecommons/vocabulary/scss/vocabulary.scss";
146+
@import "~@creativecommons/vocabulary/scss/vocabulary.scss";
148147
149148
#app {
150149
-webkit-font-smoothing: antialiased;

src/Vocabulary/VSelect.vue

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<template>
2+
<div
3+
class="control"
4+
:class="{ 'is-expanded': expanded }"
5+
>
6+
<span
7+
class="select"
8+
:class="spanClasses"
9+
>
10+
<select
11+
ref="select"
12+
v-model="computedValue"
13+
v-bind="$attrs"
14+
@blur="$emit('blur', $event)"
15+
@focus="$emit('focus', $event)"
16+
>
17+
<template v-if="placeholder">
18+
<option
19+
v-if="computedValue == null"
20+
:value="null"
21+
disabled
22+
hidden
23+
>
24+
{{ placeholder }}
25+
</option>
26+
</template>
27+
<slot />
28+
</select>
29+
</span>
30+
<slot name="left-icon" />
31+
</div>
32+
</template>
33+
34+
<script>
35+
export default {
36+
name: 'VSelect',
37+
inheritAttrs: false,
38+
props: {
39+
value: {
40+
type: [String, Number],
41+
default: null
42+
},
43+
placeholder: String,
44+
expanded: Boolean
45+
},
46+
data() {
47+
return {
48+
selected: this.value,
49+
elementRef: 'select'
50+
}
51+
},
52+
computed: {
53+
computedValue: {
54+
get() {
55+
return this.selected
56+
},
57+
set(value) {
58+
this.selected = value
59+
this.$emit('input', value)
60+
}
61+
},
62+
spanClasses() {
63+
return [this.size, this.statusType, {
64+
'is-fullwidth': this.expanded,
65+
'is-empty': this.selected === null
66+
}]
67+
}
68+
},
69+
watch: {
70+
/**
71+
* When v-model is changed:
72+
* 1. Set the selected option.
73+
* 2. If it's invalid, validate again.
74+
*/
75+
value(value) {
76+
this.selected = value
77+
}
78+
}
79+
}
80+
</script>

src/components/DropdownStep.vue

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
<template>
22
<div class="step-actions">
3-
<b-field class="license-dropdown">
4-
<b-select
5-
:placeholder="this.$t('stepper.DD.placeholder')"
6-
:value="shortName"
7-
@input="setCurrentLicense"
3+
<v-select
4+
class="license-dropdown"
5+
:placeholder="$t('stepper.DD.placeholder')"
6+
:value="shortName"
7+
@input="setCurrentLicense"
8+
>
9+
<option
10+
v-for="license in licenseList"
11+
:key="license"
12+
:value="license"
813
>
9-
<option
10-
v-for="license in licenseList"
11-
:key="license"
12-
:value="license"
13-
>
14-
{{ license }}
15-
</option>
16-
</b-select>
17-
</b-field>
14+
{{ license }}
15+
</option>
16+
</v-select>
1817
</div>
1918
</template>
2019
<script>
2120
import { mapGetters } from 'vuex'
21+
import VSelect from '@/Vocabulary/VSelect'
2222
export default {
2323
name: 'DropdownStep',
24+
components: { VSelect },
25+
inheritAttrs: false,
2426
props: {
25-
status: {
26-
type: String,
27-
validator(value) {
28-
return ['active', 'previous', 'inactive'].includes(value)
29-
}
30-
},
3127
id: Number
3228
},
3329
data() {

0 commit comments

Comments
 (0)