52
52
label.label Color
53
53
div.field.has-addons
54
54
div.control
55
- a.button (
56
- v-bind:style ="{ \
57
- color: newLabel.text_color, \
58
- backgroundColor: newLabel.background_color \
59
- }"
55
+ div.form__field
56
+ div.form__input
57
+ swatches(
58
+ v-model ="newLabel.background_color"
59
+ colors ="basic"
60
+ show-fallback =true
61
+ popover-to =""
62
+ v-bind:trigger-style ="{ width: '36px', height: '36px' }"
63
+ )
64
+ div.control
65
+ a.button.random-color-button (
60
66
v-on:click ="setColor(newLabel)"
61
67
)
62
68
span.icon.is-small
63
69
i.fas.fa-sync-alt
64
70
65
- div.control.is-expanded
66
- input.input (
67
- type ="text"
68
- placeholder ="Text input"
69
- v-model ="newLabel.background_color"
70
- )
71
-
72
71
div.column
73
72
div.field
74
73
label.label
151
150
label.label Color
152
151
div.field.has-addons
153
152
div.control
154
- a.button.has-text-white (
155
- v-bind:style ="{ backgroundColor: label.background_color }"
156
- v-on:click ="setColor(label)"
153
+ div.form__field
154
+ div.form__input
155
+ swatches(
156
+ v-model ="label.background_color"
157
+ colors ="basic"
158
+ show-fallback =true
159
+ popover-to =""
160
+ v-bind:trigger-style ="{ width: '36px', height: '36px' }"
161
+ )
162
+ div.control
163
+ a.button.random-color-button (
164
+ v-on:click ="setEditColor"
157
165
)
158
166
span.icon.is-small
159
167
i.fas.fa-sync-alt
160
168
161
- div.control.is-expanded
162
- input.input (
163
- type ="text"
164
- placeholder ="Text input"
165
- v-model ="label.background_color"
166
- )
167
-
168
169
div.column
169
170
div.field
170
171
label.label
176
177
a.button.is-primary ( v-on:click ="doneEdit(label)" ) Save changes
177
178
</template >
178
179
180
+ <style scoped>
181
+ .random-color-button {
182
+ height : 36px ;
183
+ width : 36px ;
184
+ background-color : transparent ;
185
+ color : #404040 ;
186
+ border : none ;
187
+ }
188
+ </style >
189
+
179
190
<script >
191
+ import Swatches from ' vue-swatches' ;
192
+ import ' vue-swatches/dist/vue-swatches.min.css' ;
180
193
import HTTP from ' ./http' ;
181
194
import Messages from ' ./messages.vue' ;
182
195
import { simpleShortcut } from ' ./filter' ;
183
196
184
197
export default {
185
- components: { Messages },
198
+ components: { Messages, Swatches },
186
199
187
200
filters: { simpleShortcut },
188
201
@@ -203,8 +216,8 @@ export default {
203
216
204
217
methods: {
205
218
generateColor () {
206
- const color = Math .floor (Math .random () * 0xFFFFFF ).toString (16 );
207
- const randomColor = ' #' + (' 000000' + color ).slice (- 6 );
219
+ const gencolor = Math .floor (Math .random () * 0xFFFFFF ).toString (16 );
220
+ const randomColor = ' #' + (' 000000' + gencolor ).slice (- 6 );
208
221
return randomColor;
209
222
},
210
223
@@ -222,6 +235,10 @@ export default {
222
235
label .text_color = textColor;
223
236
},
224
237
238
+ setEditColor () {
239
+ this .setColor (this .editedLabel );
240
+ },
241
+
225
242
shortcutKey (label ) {
226
243
let shortcut = label .suffix_key ;
227
244
if (label .prefix_key ) {
@@ -264,6 +281,7 @@ export default {
264
281
background_color: ' #209cee' ,
265
282
text_color: ' #ffffff' ,
266
283
};
284
+ this .setColor (this .newLabel );
267
285
},
268
286
269
287
cancelCreate () {
0 commit comments