-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathQuestionColor.vue
More file actions
103 lines (91 loc) 路 2.2 KB
/
Copy pathQuestionColor.vue
File metadata and controls
103 lines (91 loc) 路 2.2 KB
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
<!--
- SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<Question
v-bind="questionProps"
:title-placeholder="answerType.titlePlaceholder"
:warning-invalid="answerType.warningInvalid"
v-on="commonListeners">
<div
class="question__content"
role="group"
:aria-labelledby="titleId"
:aria-describedby="description ? descriptionId : undefined">
<NcColorPicker
:model-value="pickedColor"
advanced-fields
@update:model-value="onUpdatePickedColor">
<NcButton :disabled="!readOnly">
{{ colorPickerPlaceholder }}
</NcButton>
</NcColorPicker>
<div :style="{ 'background-color': pickedColor }" class="color__field">
<NcButton
v-if="pickedColor !== '' && !isRequired"
class="color__field__button"
:aria-label="t('forms', 'Clear selected color')"
variant="tertiary"
@click="onUpdatePickedColor('')">
<template #icon>
<IconClose :size="20" />
</template>
</NcButton>
</div>
</div>
</Question>
</template>
<script>
import NcButton from '@nextcloud/vue/components/NcButton'
import NcColorPicker from '@nextcloud/vue/components/NcColorPicker'
import IconClose from 'vue-material-design-icons/Close.vue'
import Question from './Question.vue'
import QuestionMixin from '../../mixins/QuestionMixin.js'
export default {
name: 'QuestionColor',
components: {
IconClose,
NcButton,
NcColorPicker,
Question,
},
mixins: [QuestionMixin],
emits: ['update:values'],
data() {
return {
isLoading: false,
}
},
computed: {
colorPickerPlaceholder() {
return this.readOnly
? this.answerType.submitPlaceholder
: this.answerType.createPlaceholder
},
pickedColor() {
return this.values[0] ?? ''
},
},
methods: {
onUpdatePickedColor(color) {
this.$emit('update:values', [color])
},
},
}
</script>
<style lang="scss" scoped>
.question__content {
display: flex;
gap: var(--clickable-area-small);
}
.color__field {
width: 100px;
height: var(--default-clickable-area);
border-radius: var(--border-radius-element);
&__button {
position: relative;
margin-inline-start: calc(100% - var(--default-clickable-area));
}
}
</style>