Skip to content

Commit ca88194

Browse files
committed
Added color dropdown to help choose contrasting colors for the labels.
1 parent 7e2ba5d commit ca88194

File tree

3 files changed

+1686
-1661
lines changed

3 files changed

+1686
-1661
lines changed

app/server/static/components/label.vue

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,18 @@
5252
label.label Color
5353
div.field.has-addons
5454
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(v-model="newLabel.background_color", colors="basic", \
58+
show-fallback=true, popover-to="", :trigger-style="{ \
59+
width: '36px', height: '36px' }")
60+
div.control
61+
a.button.random-color-button(
6062
v-on:click="setColor(newLabel)"
6163
)
6264
span.icon.is-small
6365
i.fas.fa-sync-alt
6466

65-
div.control.is-expanded
66-
input.input(
67-
type="text"
68-
placeholder="Text input"
69-
v-model="newLabel.background_color"
70-
)
71-
7267
div.column
7368
div.field
7469
label.label  
@@ -151,20 +146,18 @@
151146
label.label Color
152147
div.field.has-addons
153148
div.control
154-
a.button.has-text-white(
155-
v-bind:style="{ backgroundColor: label.background_color }"
156-
v-on:click="setColor(label)"
149+
div.form__field
150+
div.form__input
151+
swatches(v-model="label.background_color", colors="basic", \
152+
show-fallback=true, popover-to="", :trigger-style="{ \
153+
width: '36px', height: '36px' }")
154+
div.control
155+
a.button.random-color-button(
156+
v-on:click="setColor(newLabel)"
157157
)
158158
span.icon.is-small
159159
i.fas.fa-sync-alt
160160

161-
div.control.is-expanded
162-
input.input(
163-
type="text"
164-
placeholder="Text input"
165-
v-model="label.background_color"
166-
)
167-
168161
div.column
169162
div.field
170163
label.label  
@@ -176,13 +169,25 @@
176169
a.button.is-primary(v-on:click="doneEdit(label)") Save changes
177170
</template>
178171

172+
<style scoped>
173+
.random-color-button {
174+
height: 36px;
175+
width: 36px;
176+
background-color: transparent;
177+
color: #404040;
178+
border: none;
179+
}
180+
</style>
181+
179182
<script>
183+
import Swatches from 'vue-swatches';
184+
import 'vue-swatches/dist/vue-swatches.min.css';
180185
import HTTP from './http';
181186
import Messages from './messages.vue';
182187
import { simpleShortcut } from './filter';
183188
184189
export default {
185-
components: { Messages },
190+
components: { Messages, Swatches },
186191
187192
filters: { simpleShortcut },
188193
@@ -203,8 +208,8 @@ export default {
203208
204209
methods: {
205210
generateColor() {
206-
const color = Math.floor(Math.random() * 0xFFFFFF).toString(16);
207-
const randomColor = '#' + ('000000' + color).slice(-6);
211+
const gencolor = Math.floor(Math.random() * 0xFFFFFF).toString(16);
212+
const randomColor = '#' + ('000000' + gencolor).slice(-6);
208213
return randomColor;
209214
},
210215
@@ -264,6 +269,7 @@ export default {
264269
background_color: '#209cee',
265270
text_color: '#ffffff',
266271
};
272+
this.setColor(this.newLabel);
267273
},
268274
269275
cancelCreate() {

0 commit comments

Comments
 (0)