Skip to content

Commit d956c46

Browse files
committed
chore: adjust for Vue 2
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 59bb4b5 commit d956c46

File tree

3 files changed

+47
-48
lines changed

3 files changed

+47
-48
lines changed

src/components/NcAssistantButton/NcAssistantButton.vue

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<p>Primary</p>
2121
<NcAssistantButton
2222
aria-label="Generate content"
23-
:disabled
24-
:text>
23+
:disabled="disabled"
24+
:text="text">
2525
</NcAssistantButton>
2626
<NcAssistantButton
2727
aria-label="Generate content"
28-
:disabled
29-
:text
28+
:disabled="disabled"
29+
:text="text"
3030
variant="primary">
3131
</NcAssistantButton>
3232
</div>
@@ -93,63 +93,66 @@ button {
9393
```
9494
</docs>
9595

96-
<script setup lang="ts">
96+
<script setup>
9797
import { mdiCreation } from '@mdi/js'
9898
import NcAssistantIcon from '../NcAssistantIcon/NcAssistantIcon.vue'
9999
import NcButton from '../NcButton/NcButton.vue'
100100
import NcIconSvgWrapper from '../NcIconSvgWrapper/NcIconSvgWrapper.vue'
101101
102-
withDefaults(defineProps<{
102+
defineProps({
103103
/**
104104
* Toggles the disabled state of the button on and off.
105105
*/
106-
disabled?: boolean
106+
disabled: {
107+
type: Boolean,
108+
default: false,
109+
},
107110
108111
/**
109112
* The readable text of the button.
110113
* Can be overriden by using the `default` slot.
111114
*
112115
* If neither this is set nor the `default` slot is used, you will have to set at least `aria-label` or `aria-labelledby`.
113116
*/
114-
text?: string
117+
text: {
118+
type: String,
119+
default: '',
120+
},
115121
116122
/**
117123
* The button variant.
118124
* In most cases the `secondary` style should be used.
119125
*/
120-
variant?: 'primary' | 'secondary'
121-
}>(), {
122-
text: '',
123-
variant: 'secondary',
126+
variant: {
127+
type: String,
128+
default: 'secondary',
129+
},
124130
})
125131
126-
defineEmits<{
132+
defineEmits([
127133
/**
128134
* The mouse click event when the button is triggered.
129135
*/
130-
click: [MouseEvent]
131-
}>()
136+
'click',
137+
])
132138
</script>
133139

134140
<template>
135-
<div
136-
:class="[{
137-
[$style.assistantButton_disabled!]: disabled,
138-
[$style.assistantButton_primary!]: variant === 'primary',
139-
}, $style.assistantButton]">
140-
<NcButton
141-
:class="$style.assistantButton__button"
142-
:disabled
141+
<div :class="[{
142+
[$style.assistantButton_disabled]: disabled,
143+
[$style.assistantButton_primary]: variant === 'primary',
144+
}, $style.assistantButton]">
145+
<NcButton :class="$style.assistantButton__button"
146+
:disabled="disabled"
143147
variant="tertiary"
144148
@click="$emit('click', $event)">
145149
<template #icon>
146-
<NcIconSvgWrapper
147-
v-if="variant === 'primary'"
150+
<NcIconSvgWrapper v-if="variant === 'primary'"
148151
:class="$style.assistantButton__icon"
149152
:path="mdiCreation" />
150153
<NcAssistantIcon v-else />
151154
</template>
152-
<template v-if="text || $slots.default" #default>
155+
<template v-if="text || $scopedSlots.default" #default>
153156
<div :class="$style.assistantButton__text">
154157
<slot>{{ text }}</slot>
155158
</div>

src/components/NcAssistantContent/NcAssistantContent.vue

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,23 @@
4343
```
4444
</docs>
4545

46-
<script setup lang="ts">
47-
import type { Slot } from 'vue'
48-
import type { VueClassType } from '../../utils/VueTypes.ts'
46+
<script setup>
4947
50-
withDefaults(defineProps<{
48+
defineProps({
5149
/**
5250
* Classes to assign to the content container
5351
*/
54-
contentClasses?: VueClassType
55-
}>(), {
56-
contentClasses: '',
52+
contentClasses: {
53+
type: [String, Array, Object],
54+
default: '',
55+
},
5756
})
58-
59-
defineSlots<{
60-
/**
61-
* The content to be shown.
62-
*/
63-
default?: Slot
64-
}>()
6557
</script>
6658

6759
<template>
6860
<div :class="$style.assistantContent">
6961
<div :class="[$style.assistantContent__inner, contentClasses]">
62+
<!-- @slot The content to be shown. -->
7063
<slot />
7164
</div>
7265
</div>

src/components/NcAssistantIcon/NcAssistantIcon.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,36 @@
2020
```
2121
</docs>
2222

23-
<script setup lang="ts">
23+
<script setup>
2424
import { mdiCreation } from '@mdi/js'
2525
import { computed } from 'vue'
2626
27-
const props = withDefaults(defineProps<{
27+
const props = defineProps({
2828
/**
2929
* Set if the icon should be used as inline content e.g. within text.
3030
* By default the icon is made a block element for use inside `icon`-slots.
3131
*/
32-
inline?: boolean
32+
inline: {
33+
type: Boolean,
34+
default: false,
35+
},
3336
3437
/**
3538
* Size of the icon.
3639
* Defaults to the proper size to be used in buttons and other interactive elements
3740
* like all `Nc*` components with an icon slot.
3841
*/
39-
size?: number
40-
}>(), {
41-
size: 20,
42+
size: {
43+
type: Number,
44+
default: 20,
45+
},
4246
})
4347
4448
const sizePx = computed(() => `${props.size}px`)
4549
</script>
4650

4751
<template>
48-
<span
49-
aria-hidden="true"
52+
<span aria-hidden="true"
5053
:class="[$style.assistantIcon, inline && $style.assistantIcon_inline]"
5154
role="img">
5255
<svg :class="$style.assistantIcon__svg" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">

0 commit comments

Comments
 (0)