-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathNcAssistantButton.vue
More file actions
210 lines (187 loc) · 4.51 KB
/
NcAssistantButton.vue
File metadata and controls
210 lines (187 loc) · 4.51 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!--
- SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<docs>
```vue
<template>
<div class="wrapper">
<!-- Style selector -->
<div class="grid grid-3">
<NcCheckboxRadioSwitch v-model="style" value="icon" name="style" type="radio">Icon only</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="style" value="icontext" name="style" type="radio">Icon and text</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="disabled" type="checkbox">Disabled</NcCheckboxRadioSwitch>
</div>
<h5>Standard buttons</h5>
<div class="grid">
<p>Secondary</p>
<p>Primary</p>
<NcAssistantButton
aria-label="Generate content"
:disabled="disabled"
:text="text">
</NcAssistantButton>
<NcAssistantButton
aria-label="Generate content"
:disabled="disabled"
:text="text"
variant="primary">
</NcAssistantButton>
</div>
</div>
</template>
<script>
import Video from 'vue-material-design-icons/Video.vue'
export default {
components: {
Video,
},
data() {
return {
disabled: false,
style: 'icontext',
}
},
computed: {
text() {
if (this.style.includes('text')) {
return 'Generate content'
}
},
},
}
</script>
<style lang="scss" scoped>
.wrapper {
padding: 0 12px;
}
.grid {
display: grid;
gap: 12px;
grid-template-columns: 1fr 1fr;
grid-template-rows: repeat(auto-fill, auto);
justify-items: center;
position: relative;
margin: 12px 0;
}
.grid-3 {
grid-template-columns: 1fr 1fr 1fr;
}
h5 {
font-weight: var(--font-weight-heading, bold);
margin: 40px 0 20px 0;
}
p {
text-align: center;
margin: 4px 0 12px 0;
color: var(--color-text-maxcontrast)
}
button {
margin: auto;
}
</style>
```
</docs>
<script setup>
import { mdiCreation } from '@mdi/js'
import NcAssistantIcon from '../NcAssistantIcon/NcAssistantIcon.vue'
import NcButton from '../NcButton/NcButton.vue'
import NcIconSvgWrapper from '../NcIconSvgWrapper/NcIconSvgWrapper.vue'
defineProps({
/**
* Toggles the disabled state of the button on and off.
*/
disabled: {
type: Boolean,
default: false,
},
/**
* The readable text of the button.
* Can be overriden by using the `default` slot.
*
* If neither this is set nor the `default` slot is used, you will have to set at least `aria-label` or `aria-labelledby`.
*/
text: {
type: String,
default: '',
},
/**
* The button variant.
* In most cases the `secondary` style should be used.
*/
variant: {
type: String,
default: 'secondary',
},
})
defineEmits([
/**
* The mouse click event when the button is triggered.
*/
'click',
])
</script>
<template>
<div
:class="[{
[$style.assistantButton_disabled]: disabled,
[$style.assistantButton_primary]: variant === 'primary',
}, $style.assistantButton]">
<NcButton
:class="$style.assistantButton__button"
:disabled="disabled"
variant="tertiary"
@click="$emit('click', $event)">
<template #icon>
<NcIconSvgWrapper
v-if="variant === 'primary'"
:class="$style.assistantButton__icon"
:path="mdiCreation" />
<NcAssistantIcon v-else />
</template>
<template v-if="text || $scopedSlots.default" #default>
<div :class="$style.assistantButton__text">
<slot>{{ text }}</slot>
</div>
</template>
</NcButton>
</div>
</template>
<style module lang="scss">
.assistantButton {
--assistant-button-color: var(--color-element-assistant, linear-gradient(238deg, #A569D3 12%, #00679E 39%, #422083 86%));
--assistant-button-background-color: var(--color-background-assistant, #F6F5FF);
background-image: var(--color-border-assistant, linear-gradient(125deg, #7398FE 50%, #6104A4 125%));
border-radius: var(--border-radius-element);
height: var(--default-clickable-area);
width: fit-content;
padding-inline: 1px;
padding-block: 1px 2px;
&_disabled {
filter: saturate(0.5);
opacity: 0.5;
}
&_primary {
--assistant-button-color: white;
--assistant-button-background-color: var(--color-element-assistant,linear-gradient(238deg, #A569D3 12%, #00679E 39%, #422083 86%));
.assistantButton__icon,
.assistantButton__text {
color: white !important;
}
}
&__button {
--button-size: calc(var(--default-clickable-area) - 3px) !important;
background-color: var(--assistant-button-background-color) !important;
background-image: var(--assistant-button-background-color) !important;
border: none !important;
&:hover {
filter: brightness(120%);
}
}
&__text {
background-image: var(--assistant-button-color);
color: transparent !important;
background-clip: text;
}
}
</style>