@everchron/ec-shards 0.9.1 → 0.9.2
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 +44 -92
- package/dist/ec-shards.common.js.map +1 -1
- package/dist/ec-shards.css +1 -1
- package/dist/ec-shards.umd.js +44 -92
- 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 +18 -38
- package/src/stories/swatches-picker/swatches-picker.stories.js +161 -7
package/package.json
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
<template>
|
|
3
3
|
<div class="ecs-swatches" :class="sizeClass">
|
|
4
4
|
<div
|
|
5
|
-
v-for="item in swatches" :key="item.
|
|
6
|
-
@click="selectedColor = item.
|
|
5
|
+
v-for="item in swatches" :key="item.id"
|
|
6
|
+
@click="selectedColor = item.hex"
|
|
7
7
|
:title="item.title"
|
|
8
8
|
class="ecs-swatches-color"
|
|
9
|
-
:style="{backgroundColor: item.
|
|
10
|
-
:class="selectedColor == item.
|
|
9
|
+
:style="{backgroundColor: item.hex, color: item.hex}"
|
|
10
|
+
:class="selectedColor == item.hex ? 'active' : ''">
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
@@ -23,30 +23,17 @@
|
|
|
23
23
|
},
|
|
24
24
|
/** Sets the selected color value. Must be a HEX value that exists in the swatches (data) list. */
|
|
25
25
|
selected: {
|
|
26
|
-
type: String
|
|
27
|
-
|
|
26
|
+
type: String
|
|
27
|
+
},
|
|
28
|
+
/** The available color swatches the user can choose from. Array structure: contains Objects with `id`, `title`, `hex`. */
|
|
29
|
+
swatches: {
|
|
30
|
+
type: Array,
|
|
31
|
+
required: true
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
|
|
31
35
|
data () {
|
|
32
36
|
return {
|
|
33
|
-
swatches: [
|
|
34
|
-
{ title: 'Yellow', color: '#F9DF00' },
|
|
35
|
-
{ title: 'Orange', color: '#F3A100' },
|
|
36
|
-
{ title: 'Lime', color: '#B7EA80' },
|
|
37
|
-
{ title: 'Cyan', color: '#48E4C2' },
|
|
38
|
-
{ title: 'Sky Blue', color: '#489DFF' },
|
|
39
|
-
{ title: 'Indigo', color: '#B877F0' },
|
|
40
|
-
{ title: 'Pink', color: '#FD78FD' },
|
|
41
|
-
{ title: 'Brown', color: '#C59465' },
|
|
42
|
-
{ title: 'Gray', color: '#858E9F' },
|
|
43
|
-
{ title: 'Red', color: '#EE5452' },
|
|
44
|
-
{ title: 'Dark Blue', color: '#227FD3' },
|
|
45
|
-
{ title: 'Green', color: '#5DAF00' },
|
|
46
|
-
{ title: 'Brass', color: '#A4927A' },
|
|
47
|
-
{ title: 'Silver', color: '#95989C' },
|
|
48
|
-
{ title: 'Gold', color: '#D78B21' }
|
|
49
|
-
],
|
|
50
37
|
selectedColor: this.selected,
|
|
51
38
|
selectedTitle: ''
|
|
52
39
|
}
|
|
@@ -62,29 +49,22 @@
|
|
|
62
49
|
|
|
63
50
|
methods: {
|
|
64
51
|
emitSelected(){
|
|
65
|
-
/** Returns the selected color value
|
|
66
|
-
this.$emit('input', {
|
|
67
|
-
color: this.selectedColor,
|
|
68
|
-
title: this.selectedTitle
|
|
69
|
-
})
|
|
70
|
-
*/
|
|
52
|
+
/** Returns the selected color value as HEX. */
|
|
71
53
|
this.$emit('input', this.selectedColor)
|
|
72
54
|
}
|
|
73
55
|
},
|
|
74
56
|
|
|
75
|
-
/*
|
|
76
|
-
mounted () {
|
|
77
|
-
if (this.selected)
|
|
78
|
-
this.selectedTitle = this.swatches[this.swatches.findIndex(x => x.color === this.selectedColor)].title
|
|
79
|
-
this.emitSelected()
|
|
80
|
-
},
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
57
|
watch: {
|
|
84
58
|
selectedColor(){
|
|
85
|
-
this.selectedTitle = this.swatches[this.swatches.findIndex(x => x.
|
|
59
|
+
this.selectedTitle = this.swatches[this.swatches.findIndex(x => x.hex === this.selectedColor)].title
|
|
86
60
|
this.emitSelected()
|
|
87
61
|
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
mounted () {
|
|
65
|
+
if (this.selected)
|
|
66
|
+
this.selectedTitle = this.swatches[this.swatches.findIndex(x => x.hex === this.selectedColor)].title
|
|
67
|
+
this.emitSelected()
|
|
88
68
|
}
|
|
89
69
|
}
|
|
90
70
|
</script>
|
|
@@ -9,13 +9,90 @@ export const SwatchesPicker = () => ({
|
|
|
9
9
|
components: { EcsSwatchesPicker },
|
|
10
10
|
data() {
|
|
11
11
|
return {
|
|
12
|
-
selectedColor: ''
|
|
12
|
+
selectedColor: '',
|
|
13
|
+
swatchesData: [
|
|
14
|
+
{
|
|
15
|
+
"id": 1,
|
|
16
|
+
"title": "Yellow",
|
|
17
|
+
"hex": "#F9DF00"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": 2,
|
|
21
|
+
"title": "Orange",
|
|
22
|
+
"hex": "#F3A100"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"id": 3,
|
|
26
|
+
"title": "Lime",
|
|
27
|
+
"hex": "#B7EA80"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"id": 4,
|
|
31
|
+
"title": "Cyan",
|
|
32
|
+
"hex": "#48E4C2"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": 5,
|
|
36
|
+
"title": "Blue",
|
|
37
|
+
"hex": "#489DFF"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"id": 6,
|
|
41
|
+
"title": "Indigo",
|
|
42
|
+
"hex": "#B877F0"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": 7,
|
|
46
|
+
"title": "Pink",
|
|
47
|
+
"hex": "#FD78FD"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": 8,
|
|
51
|
+
"title": "Brown",
|
|
52
|
+
"hex": "#C59465"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": 9,
|
|
56
|
+
"title": "Grey",
|
|
57
|
+
"hex": "#858E9F"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": 10,
|
|
61
|
+
"title": "Red",
|
|
62
|
+
"hex": "#EE5452"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"id": 11,
|
|
66
|
+
"title": "Dark Blue",
|
|
67
|
+
"hex": "#227FD3"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"id": 12,
|
|
71
|
+
"title": "Green",
|
|
72
|
+
"hex": "#5DAF00"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": 13,
|
|
76
|
+
"title": "Brass",
|
|
77
|
+
"hex": "#A4927A"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": 14,
|
|
81
|
+
"title": "Silver",
|
|
82
|
+
"hex": "#95989C"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": 15,
|
|
86
|
+
"title": "Gold",
|
|
87
|
+
"hex": "#D78B21"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
13
90
|
}
|
|
14
91
|
},
|
|
15
92
|
template: `<div>
|
|
16
|
-
<ecs-swatches-picker v-model="selectedColor" selected="#F9DF00" />
|
|
93
|
+
<ecs-swatches-picker v-model="selectedColor" selected="#F9DF00" :swatches="swatchesData" />
|
|
17
94
|
<hr style="border: none; border-bottom: 1px solid #DADEE6; margin: 20px 0">
|
|
18
|
-
Selected: {{ selectedColor
|
|
95
|
+
Selected: {{ selectedColor }}
|
|
19
96
|
</div>`,
|
|
20
97
|
});
|
|
21
98
|
|
|
@@ -23,12 +100,89 @@ export const SwatchesPickerSizes = () => ({
|
|
|
23
100
|
components: { EcsSwatchesPicker },
|
|
24
101
|
data() {
|
|
25
102
|
return {
|
|
26
|
-
selectedColor: ''
|
|
103
|
+
selectedColor: '',
|
|
104
|
+
swatchesData: [
|
|
105
|
+
{
|
|
106
|
+
"id": 1,
|
|
107
|
+
"title": "Yellow",
|
|
108
|
+
"hex": "#F9DF00"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": 2,
|
|
112
|
+
"title": "Orange",
|
|
113
|
+
"hex": "#F3A100"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"id": 3,
|
|
117
|
+
"title": "Lime",
|
|
118
|
+
"hex": "#B7EA80"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": 4,
|
|
122
|
+
"title": "Cyan",
|
|
123
|
+
"hex": "#48E4C2"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"id": 5,
|
|
127
|
+
"title": "Blue",
|
|
128
|
+
"hex": "#489DFF"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": 6,
|
|
132
|
+
"title": "Indigo",
|
|
133
|
+
"hex": "#B877F0"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"id": 7,
|
|
137
|
+
"title": "Pink",
|
|
138
|
+
"hex": "#FD78FD"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"id": 8,
|
|
142
|
+
"title": "Brown",
|
|
143
|
+
"hex": "#C59465"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"id": 9,
|
|
147
|
+
"title": "Grey",
|
|
148
|
+
"hex": "#858E9F"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": 10,
|
|
152
|
+
"title": "Red",
|
|
153
|
+
"hex": "#EE5452"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": 11,
|
|
157
|
+
"title": "Dark Blue",
|
|
158
|
+
"hex": "#227FD3"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"id": 12,
|
|
162
|
+
"title": "Green",
|
|
163
|
+
"hex": "#5DAF00"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"id": 13,
|
|
167
|
+
"title": "Brass",
|
|
168
|
+
"hex": "#A4927A"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"id": 14,
|
|
172
|
+
"title": "Silver",
|
|
173
|
+
"hex": "#95989C"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"id": 15,
|
|
177
|
+
"title": "Gold",
|
|
178
|
+
"hex": "#D78B21"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
27
181
|
}
|
|
28
182
|
},
|
|
29
183
|
template: `<div>
|
|
30
|
-
<ecs-swatches-picker v-model="selectedColor" size="sml" selected="#
|
|
31
|
-
<ecs-swatches-picker v-model="selectedColor" size="md" selected="#F9DF00" />
|
|
32
|
-
<ecs-swatches-picker v-model="selectedColor" size="lg" selected="#F9DF00" />
|
|
184
|
+
<ecs-swatches-picker v-model="selectedColor" size="sml" :swatches="swatchesData" selected="#D78B21" />
|
|
185
|
+
<ecs-swatches-picker v-model="selectedColor" size="md" :swatches="swatchesData" selected="#F9DF00" />
|
|
186
|
+
<ecs-swatches-picker v-model="selectedColor" size="lg" :swatches="swatchesData" selected="#F9DF00" />
|
|
33
187
|
</div>`,
|
|
34
188
|
});
|