@everchron/ec-shards 0.8.9 → 0.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ec-shards.common.js +162 -29
- package/dist/ec-shards.common.js.map +1 -1
- package/dist/ec-shards.css +1 -1
- package/dist/ec-shards.umd.js +162 -29
- package/dist/ec-shards.umd.js.map +1 -1
- package/dist/ec-shards.umd.min.js +2 -2
- package/dist/ec-shards.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/swatches-picker/swatches-picker.vue +41 -5
- package/src/stories/swatches-picker/swatches-picker.stories.js +7 -3
package/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<div class="ecs-swatches" :class="sizeClass">
|
|
4
4
|
<div
|
|
5
5
|
v-for="item in swatches" :key="item.color"
|
|
6
|
-
@click="
|
|
6
|
+
@click="() => setColor(item)"
|
|
7
7
|
:title="item.title"
|
|
8
8
|
class="ecs-swatches-color"
|
|
9
9
|
:style="{backgroundColor: item.color, color: item.color}"
|
|
10
|
-
:class="selectedColor == item.color ? 'active' : ''">
|
|
10
|
+
:class="selectedColor[0].color == item.color ? 'active' : ''">
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
@@ -24,7 +24,24 @@
|
|
|
24
24
|
/** Sets the selected color value. Must be a HEX value that exists in the swatches (data) list. */
|
|
25
25
|
selected: {
|
|
26
26
|
type: String,
|
|
27
|
-
validator: v => [
|
|
27
|
+
validator: v => [
|
|
28
|
+
'#F9DF00',
|
|
29
|
+
'#F3A100',
|
|
30
|
+
'#B7EA80',
|
|
31
|
+
'#48E4C2',
|
|
32
|
+
'#489DFF',
|
|
33
|
+
'#B877F0',
|
|
34
|
+
'#FD78FD',
|
|
35
|
+
'#C59465',
|
|
36
|
+
'#858E9F',
|
|
37
|
+
'#227FD3',
|
|
38
|
+
'#5DAF00',
|
|
39
|
+
'#A4927A',
|
|
40
|
+
'#95989C',
|
|
41
|
+
'#D78B21',
|
|
42
|
+
'null',
|
|
43
|
+
null
|
|
44
|
+
].includes(v)
|
|
28
45
|
}
|
|
29
46
|
},
|
|
30
47
|
|
|
@@ -46,7 +63,9 @@
|
|
|
46
63
|
{ title: 'Silver', color: '#95989C' },
|
|
47
64
|
{ title: 'Gold', color: '#D78B21' },
|
|
48
65
|
],
|
|
49
|
-
selectedColor:
|
|
66
|
+
selectedColor: [
|
|
67
|
+
{ title: '', color: this.selected }
|
|
68
|
+
]
|
|
50
69
|
}
|
|
51
70
|
},
|
|
52
71
|
|
|
@@ -55,12 +74,29 @@
|
|
|
55
74
|
if (this.size && this.size !== '')
|
|
56
75
|
return `ecs-swatches-${this.size}`
|
|
57
76
|
return this.size
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
selectedTitleIndex() {
|
|
80
|
+
return this.swatches.findIndex(x => x.color === this.selected)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
methods: {
|
|
85
|
+
setColor(item){
|
|
86
|
+
this.selectedColor.splice(0)
|
|
87
|
+
this.selectedColor.push(item)
|
|
58
88
|
}
|
|
59
89
|
},
|
|
60
90
|
|
|
91
|
+
mounted () {
|
|
92
|
+
if(this.selected)
|
|
93
|
+
this.selectedColor[0].title = this.swatches[this.selectedTitleIndex].title
|
|
94
|
+
this.$emit('input', this.selectedColor)
|
|
95
|
+
},
|
|
96
|
+
|
|
61
97
|
watch: {
|
|
62
98
|
selectedColor(){
|
|
63
|
-
/** Returns the selected color value as
|
|
99
|
+
/** Returns the selected color value as an array including the name and color. */
|
|
64
100
|
this.$emit('input', this.selectedColor)
|
|
65
101
|
},
|
|
66
102
|
}
|
|
@@ -9,17 +9,21 @@ export const SwatchesPicker = () => ({
|
|
|
9
9
|
components: { EcsSwatchesPicker },
|
|
10
10
|
data() {
|
|
11
11
|
return {
|
|
12
|
-
selectedColor: ''
|
|
12
|
+
selectedColor: [{ title: '', color: '#489DFF'}]
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
template: `<
|
|
15
|
+
template: `<div>
|
|
16
|
+
<ecs-swatches-picker v-model="selectedColor" :selected="selectedColor[0].color" />
|
|
17
|
+
<hr style="border: none; border-bottom: 1px solid #DADEE6; margin: 20px 0">
|
|
18
|
+
{{ selectedColor[0].title }} {{ selectedColor[0].color }}
|
|
19
|
+
</div>`,
|
|
16
20
|
});
|
|
17
21
|
|
|
18
22
|
export const SwatchesPickerSizes = () => ({
|
|
19
23
|
components: { EcsSwatchesPicker },
|
|
20
24
|
data() {
|
|
21
25
|
return {
|
|
22
|
-
selectedColor: ''
|
|
26
|
+
selectedColor: [{ title: '', color: '#F9DF00' }]
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
29
|
template: `<div>
|