This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-picker.vue
122 lines (112 loc) · 3.38 KB
/
example-picker.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<template>
<div class="example-picker">
<div class="picker" v-for="part in pickerItems" v-bind:key="part.name">
<div class="title">
<div class="title-part">
{{ locale(part.name) }}:
</div>
<div class="title-color">
{{ getPartColor(part.name) }}
</div>
</div>
<button-group-swatch
v-bind:variant="'thin'"
v-bind:items="part.items"
v-bind:value="part.value"
v-on:update:value="value => onPicker(part.name, value)"
/>
</div>
</div>
</template>
<style scoped>
.example-picker > .picker {
margin-top: 20px;
}
.example-picker .title {
color: #151515;
display: flex;
font-size: 12px;
letter-spacing: 1px;
margin-bottom: 7px;
padding-right: 10px;
text-transform: uppercase;
}
.example-picker .title > .title-part {
font-weight: 600;
text-align: right;
white-space: nowrap;
}
.example-picker .title > .title-color {
margin-left: 5px;
}
.example-picker ::v-deep .button-group-swatch.thin .swatch > .swatch-image {
border: 2px solid transparent;
height: 50px;
width: 50px;
}
.example-picker ::v-deep .button-group-swatch.thin .swatch.selected > .swatch-image,
.example-picker ::v-deep .button-group-swatch.thin .swatch:hover:not(.disabled) > .swatch-image {
border-color: #000000;
}
.example-picker ::v-deep .button-group-swatch.thin .swatch {
margin-right: 7px;
}
body.mobile .example-picker ::v-deep .button-group-swatch.thin .swatch {
margin: 0px 10px 0px 0px;
}
</style>
<script>
export const ExamplePicker = {
name: "example-picker",
props: {
parts: {
type: Array,
default: () => []
}
},
computed: {
options() {
return this.$store.state.options;
},
selectedParts() {
return this.$store.getters.getParts();
},
pickerItems() {
return this.parts.map(part => {
const items = [];
Object.entries(this.options[part]).forEach(([material, colors]) => {
colors.forEach(color => {
items.push({
value: [material, color].join(":"),
url: this.$ripe._getSwatchURL({
color: color,
material: material,
retina: true
}),
label: false
});
});
});
const value = [
this.selectedParts[part].material,
this.selectedParts[part].color
].join(":");
return {
name: part,
items: items,
value: value
};
});
}
},
methods: {
onPicker(part, value) {
this.setPart(part, ...value.split(":"));
},
getPartColor(part) {
return this.locale(`colors.${this.selectedParts[part].color}`);
}
}
};
export default ExamplePicker;
</script>