Skip to content

Commit b5182cb

Browse files
fix#4535: add type to color and icon props (#4537)
* fix#4535: add type to color props * fix(#4535): replace absolute import path with relative --------- Co-authored-by: Maksym Nedoshev <m0ksem1337@gmail.com>
1 parent dad2370 commit b5182cb

File tree

43 files changed

+157
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+157
-95
lines changed

packages/compiler/playground/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import TestPage from './pages/TestPage.vue';
33
</script>
44

55
<template>
6-
<VaNavbar>
6+
<VaNavbar color="myCustomColor">
77
<template #left>
88
Vuestic UI Devtools demo
99
</template>

packages/ui/src/components/va-alert/VaAlert.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272

7373
</div>
7474
</transition>
75+
7576
</template>
7677

7778
<script lang="ts" setup>
@@ -81,11 +82,14 @@ import {
8182
useComponentPresetProp,
8283
useStateful, useStatefulProps, useStatefulEmits,
8384
useTranslation,
85+
ColorName,
8486
} from '../../composables'
8587
8688
import { useAlertStyles } from './useAlertStyles'
8789
88-
import { VaIcon } from '../va-icon'
90+
import { VaIcon, VaIconName } from '../va-icon'
91+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
92+
import { VaAlert } from '.'
8993
9094
defineOptions({
9195
name: 'VaAlert',
@@ -97,11 +101,11 @@ const props = defineProps({
97101
98102
modelValue: { type: Boolean, default: true },
99103
stateful: { type: Boolean, default: true },
100-
color: { type: String, default: 'primary' },
104+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'primary' },
101105
textColor: { type: String, default: '' },
102106
title: { type: String, default: '' },
103107
description: { type: String, default: '' },
104-
icon: { type: String, default: '' },
108+
icon: { type: String as PropType<StringWithAutocomplete<VaIconName>>, default: '' },
105109
closeText: { type: String, default: '' },
106110
closeIcon: { type: String, default: 'close' },
107111
closeable: { type: Boolean, default: false },

packages/ui/src/components/va-app-bar/VaAppBar.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<script lang="ts" setup>
1313
import { PropType, computed, toRef } from 'vue'
1414
15-
import { useColors, useFixedBar, useFixedBarProps, useComponentPresetProp, useElementTextColor, useTemplateRef, useSelectorTemplateRef, useElementScrollableParent } from '../../composables'
16-
15+
import { useColors, useFixedBar, useFixedBarProps, useComponentPresetProp, useElementTextColor, useTemplateRef, useSelectorTemplateRef, useElementScrollableParent, ColorName } from '../../composables'
16+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
1717
defineOptions({
1818
name: 'VaAppBar',
1919
})
@@ -25,7 +25,7 @@ const props = defineProps({
2525
target: { type: [Object, String] as PropType<string | HTMLElement>, default: '' },
2626
shadowOnScroll: { type: Boolean, default: false },
2727
shadowColor: { type: String, default: '' },
28-
color: { type: String, default: 'primary' },
28+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'primary' },
2929
})
3030
3131
const targetHtmlElement = useSelectorTemplateRef(toRef(props, 'target'))

packages/ui/src/components/va-avatar/VaAvatar.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</template>
3333

3434
<script lang="ts">
35-
import { ref, watch, computed } from 'vue'
35+
import { ref, watch, computed, PropType } from 'vue'
3636
3737
import {
3838
useBem,
@@ -42,11 +42,13 @@ import {
4242
useSizeProps,
4343
useLoadableControlProps,
4444
useComponentPresetProp,
45+
ColorName,
4546
} from '../../composables'
4647
import { extractComponentProps, filterComponentProps } from '../../utils/component-options'
4748
48-
import { VaIcon, VaProgressCircle, VaFallback } from '../index'
49+
import { VaIcon, VaProgressCircle, VaFallback, VaIconName } from '../index'
4950
import { pick } from '../../utils/pick'
51+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
5052
5153
const VaFallbackPropsDeclaration = extractComponentProps(VaFallback)
5254
</script>
@@ -63,12 +65,12 @@ const props = defineProps({
6365
...useComponentPresetProp,
6466
...VaFallbackPropsDeclaration,
6567
66-
color: { type: String, default: 'primary' },
68+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'primary' },
6769
textColor: { type: String },
6870
square: { type: Boolean, default: false },
6971
fontSize: { type: String, default: '' },
7072
src: { type: String, default: null },
71-
icon: { type: String, default: '' },
73+
icon: { type: String as PropType<StringWithAutocomplete<VaIconName>>, default: '' },
7274
alt: { type: String, default: '' },
7375
})
7476

packages/ui/src/components/va-backtop/VaBacktop.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
<script lang="ts" setup>
2323
import { PropType, ref, computed, onMounted, onBeforeUnmount } from 'vue'
24-
import { useComponentPresetProp, useTranslation, useTranslationProp, useNumericProp, makeNumericProp } from '../../composables'
24+
import { useComponentPresetProp, useTranslation, useTranslationProp, useNumericProp, makeNumericProp, ColorName } from '../../composables'
2525
import { VaButton } from '../va-button'
2626
import { warn } from '../../utils/console'
27+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
2728
2829
defineOptions({
2930
name: 'VaBacktop',
@@ -39,7 +40,7 @@ const props = defineProps({
3940
speed: makeNumericProp({ default: 50 }),
4041
verticalOffset: { type: String, default: '1rem' },
4142
horizontalOffset: { type: String, default: '1rem' },
42-
color: { type: String, default: 'primary' },
43+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'primary' },
4344
horizontalPosition: {
4445
type: String as PropType<'right' | 'left'>,
4546
default: 'right',

packages/ui/src/components/va-badge/VaBadge.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@
2020
</template>
2121

2222
<script lang="ts" setup>
23-
import { computed, unref, useSlots } from 'vue'
23+
import { computed, unref, useSlots, PropType } from 'vue'
2424
2525
import {
2626
useBem,
2727
useColors,
2828
useElementTextColor,
2929
useDeprecated,
3030
useComponentPresetProp,
31+
ColorName,
3132
} from '../../composables'
3233
3334
import { useFloatingPosition, useFloatingPositionProps } from './hooks/useFloatingPositionStyles'
3435
import { pick } from '../../utils/pick'
36+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
37+
import { VaBadge } from '.'
3538
3639
defineOptions({
3740
name: 'VaBadge',
@@ -41,7 +44,7 @@ const props = defineProps({
4144
...useComponentPresetProp,
4245
...useFloatingPositionProps,
4346
44-
color: { type: String, default: 'danger' },
47+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'danger' },
4548
textColor: { type: String },
4649
text: { type: [String, Number], default: '' },
4750
multiLine: { type: Boolean, default: false },

packages/ui/src/components/va-breadcrumbs/VaBreadcrumbs.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
<script lang="ts">
2-
import { computed, defineComponent, Fragment, h, ref, VNode } from 'vue'
2+
import { computed, defineComponent, Fragment, h, ref, VNode, PropType } from 'vue'
33
44
import {
55
useComponentPresetProp,
66
useAlignable,
77
useAlignableProps,
88
useColors,
99
useTranslation, useTranslationProp,
10+
ColorName,
1011
} from '../../composables'
1112
1213
import { hasOwnProperty } from '../../utils/has-own-property'
1314
import { resolveSlot } from '../../utils/resolveSlot'
15+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
1416
1517
export default defineComponent({
1618
name: 'VaBreadcrumbs',
1719
props: {
1820
...useAlignableProps,
1921
...useComponentPresetProp,
2022
separator: { type: String, default: '/' },
21-
color: { type: String, default: null },
23+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: null },
2224
disabledColor: { type: String, default: 'secondary' },
2325
activeColor: { type: String, default: null },
2426
separatorColor: { type: String, default: null },

packages/ui/src/components/va-button/VaButton.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ import { useButtonBackground } from './hooks/useButtonBackground'
7070
import { useButtonAttributes } from './hooks/useButtonAttributes'
7171
import { useButtonTextColor } from './hooks/useButtonTextColor'
7272
73-
import { VaIcon } from '../va-icon'
73+
import { VaIcon, VaIconName } from '../va-icon'
7474
import { VaProgressCircle } from '../va-progress-circle'
7575
import { pick } from '../../utils/pick'
7676
7777
import type { ColorName } from '../../composables'
78-
78+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
79+
import { VaButton } from '.'
7980
defineOptions({
8081
name: 'VaButton',
8182
})
@@ -107,7 +108,7 @@ const props = defineProps({
107108
validator: (v: string) => ['small', 'medium', 'large'].includes(v),
108109
},
109110
110-
icon: { type: String, default: '' },
111+
icon: { type: String as PropType<StringWithAutocomplete<VaIconName>>, default: '' },
111112
iconRight: { type: String, default: '' },
112113
iconColor: { type: String, default: '' },
113114

packages/ui/src/components/va-card/VaCard.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</template>
1818

1919
<script lang="ts" setup>
20-
import { computed } from 'vue'
20+
import { computed, PropType } from 'vue'
2121
import { getGradientBackground } from '../../services/color'
2222
import {
2323
useBem,
@@ -26,8 +26,10 @@ import {
2626
useElementTextColor,
2727
useRouterLink,
2828
useRouterLinkProps,
29+
ColorName,
2930
} from '../../composables'
3031
import { pick } from '../../utils/pick'
32+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
3133
3234
defineOptions({
3335
name: 'VaCard',
@@ -47,7 +49,7 @@ const props = defineProps({
4749
stripeColor: { type: String, default: '' },
4850
gradient: { type: Boolean, default: false },
4951
textColor: { type: String },
50-
color: { type: String, default: 'background-secondary' },
52+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'background-secondary' },
5153
})
5254
5355
const { getColor } = useColors()

packages/ui/src/components/va-carousel/VaCarousel.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ import {
104104
useSwipe, useSwipeProps, useComponentPresetProp,
105105
useTranslation, useTranslationProp, useNumericProp,
106106
makeNumericProp,
107+
ColorName,
107108
} from '../../composables'
108109
110+
import { StringWithAutocomplete } from '../../utils/types/prop-type'
109111
import { VaImage } from '../va-image'
110112
import VaCarouselButton from './components/VaCarouselButton.vue'
111113
@@ -153,7 +155,7 @@ const props = defineProps({
153155
default: 'transition',
154156
validator: (value: string) => ['fade', 'transition'].includes(value),
155157
},
156-
color: { type: String, default: 'primary' },
158+
color: { type: String as PropType<StringWithAutocomplete<ColorName>>, default: 'primary' },
157159
ratio: { type: [Number, String] },
158160
159161
ariaLabel: useTranslationProp('$t:carousel'),

0 commit comments

Comments
 (0)