Skip to content

Commit 51c8b8e

Browse files
gioboabenjamincanac
andauthoredNov 20, 2024··
fix(components): replace as const with correct type in config (#2652)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
1 parent 588a908 commit 51c8b8e

16 files changed

+66
-42
lines changed
 

‎docs/components/content/examples/CommandPaletteExampleThemeRaycast.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const ui = {
4545
inactive: 'text-gray-400 dark:text-gray-500'
4646
},
4747
avatar: {
48-
size: '2xs' as const
48+
size: '2xs'
4949
}
5050
}
5151
}

‎src/runtime/types/checkbox.d.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type colors from '#ui-colors'
2+
3+
export type CheckboxColor = typeof colors[number]

‎src/runtime/types/divider.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import type { divider } from '#ui/ui.config'
1+
import type { divider } from '../ui.config'
22

33
export type DividerSize = keyof typeof divider.border.size.horizontal | keyof typeof divider.border.size.vertical

‎src/runtime/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from './avatar'
44
export * from './badge'
55
export * from './breadcrumb'
66
export * from './button'
7+
export * from './checkbox'
78
export * from './chip'
89
export * from './clipboard'
910
export * from './command-palette'

‎src/runtime/ui.config/data/table.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ButtonColor, ButtonSize, ButtonVariant, CheckboxColor, ProgressAnimation, ProgressColor } from '../../types'
2+
13
export default {
24
wrapper: 'relative overflow-x-auto',
35
base: 'min-w-full table-fixed',
@@ -51,23 +53,23 @@ export default {
5153
icon: 'i-heroicons-arrows-up-down-20-solid',
5254
trailing: true,
5355
square: true,
54-
color: 'gray' as const,
55-
variant: 'ghost' as const,
56+
color: 'gray' as ButtonColor,
57+
variant: 'ghost' as ButtonVariant,
5658
class: '-m-1.5'
5759
},
5860
expandButton: {
5961
icon: 'i-heroicons-chevron-down',
60-
color: 'gray' as const,
61-
variant: 'ghost' as const,
62-
size: 'xs' as const,
62+
color: 'gray' as ButtonColor,
63+
variant: 'ghost' as ButtonVariant,
64+
size: 'xs' as ButtonSize,
6365
class: '-my-1.5 align-middle'
6466
},
6567
checkbox: {
66-
color: 'primary' as const
68+
color: 'primary' as CheckboxColor
6769
},
6870
progress: {
69-
color: 'primary' as const,
70-
animation: 'carousel' as const
71+
color: 'primary' as ProgressColor,
72+
animation: 'carousel' as ProgressAnimation
7173
},
7274
loadingState: {
7375
icon: 'i-heroicons-arrow-path-20-solid',

‎src/runtime/ui.config/elements/accordion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default {
1616
openIcon: 'i-heroicons-chevron-down-20-solid',
1717
closeIcon: '',
1818
class: 'mb-1.5 w-full',
19-
variant: 'soft' as const,
19+
variant: 'soft',
2020
truncate: true
2121
}
2222
}

‎src/runtime/ui.config/elements/alert.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AvatarSize, ButtonColor, ButtonSize, ButtonVariant } from '../../types'
2+
13
export default {
24
wrapper: 'w-full relative overflow-hidden',
35
inner: 'w-0 flex-1',
@@ -13,7 +15,7 @@ export default {
1315
},
1416
avatar: {
1517
base: 'flex-shrink-0 self-center',
16-
size: 'md' as const
18+
size: 'md' as AvatarSize
1719
},
1820
color: {
1921
white: {
@@ -32,9 +34,9 @@ export default {
3234
icon: null,
3335
closeButton: null,
3436
actionButton: {
35-
size: 'xs' as const,
36-
color: 'primary' as const,
37-
variant: 'link' as const
37+
size: 'xs' as ButtonSize,
38+
color: 'primary' as ButtonColor,
39+
variant: 'link' as ButtonVariant
3840
}
3941
}
4042
}

‎src/runtime/ui.config/elements/carousel.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ButtonColor } from '../../types'
2+
13
export default {
24
wrapper: 'relative',
35
container: 'relative w-full flex overflow-x-auto snap-x snap-mandatory scroll-smooth',
@@ -13,12 +15,12 @@ export default {
1315
},
1416
default: {
1517
prevButton: {
16-
color: 'black' as const,
18+
color: 'black' as ButtonColor,
1719
class: 'rtl:[&_span:first-child]:rotate-180 absolute start-4 top-1/2 transform -translate-y-1/2 rounded-full',
1820
icon: 'i-heroicons-chevron-left-20-solid'
1921
},
2022
nextButton: {
21-
color: 'black' as const,
23+
color: 'black' as ButtonColor,
2224
class: 'rtl:[&_span:last-child]:rotate-180 absolute end-4 top-1/2 transform -translate-y-1/2 rounded-full',
2325
icon: 'i-heroicons-chevron-right-20-solid'
2426
}

‎src/runtime/ui.config/elements/dropdown.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AvatarSize } from '../../types'
12
import { arrow } from '../popper'
23

34
export default {
@@ -28,7 +29,7 @@ export default {
2829
},
2930
avatar: {
3031
base: 'flex-shrink-0',
31-
size: '2xs' as const
32+
size: '2xs' as AvatarSize
3233
},
3334
label: 'truncate',
3435
shortcuts: 'hidden md:inline-flex flex-shrink-0 gap-0.5 ms-auto'

‎src/runtime/ui.config/forms/inputMenu.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { AvatarSize } from '../../types'
12
import { arrow } from '../popper'
23

34
export default {
@@ -36,7 +37,7 @@ export default {
3637
},
3738
avatar: {
3839
base: 'flex-shrink-0',
39-
size: '2xs' as const
40+
size: '2xs' as AvatarSize
4041
},
4142
chip: {
4243
base: 'flex-shrink-0 w-2 h-2 mx-1 rounded-full'

‎src/runtime/ui.config/layout/divider.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AvatarSize } from '../../types'
2+
13
export default {
24
wrapper: {
35
base: 'flex items-center align-center text-center',
@@ -42,11 +44,11 @@ export default {
4244
},
4345
avatar: {
4446
base: 'flex-shrink-0',
45-
size: '2xs' as const
47+
size: '2xs' as AvatarSize
4648
},
4749
label: 'text-sm',
4850
default: {
49-
size: '2xs' as const,
50-
type: 'solid' as const
51+
size: '2xs',
52+
type: 'solid'
5153
}
5254
}

‎src/runtime/ui.config/navigation/commandPalette.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AvatarSize } from '../../types'
2+
13
export default {
24
wrapper: 'flex flex-col flex-1 min-h-0 divide-y divide-gray-100 dark:divide-gray-800',
35
container: 'relative flex-1 overflow-y-auto divide-y divide-gray-100 dark:divide-gray-800 scroll-py-2',
@@ -46,7 +48,7 @@ export default {
4648
},
4749
avatar: {
4850
base: 'flex-shrink-0',
49-
size: '2xs' as const
51+
size: '2xs' as AvatarSize
5052
},
5153
chip: {
5254
base: 'flex-shrink-0 w-2 h-2 mx-1 rounded-full'

‎src/runtime/ui.config/navigation/horizontalNavigation.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AvatarSize, BadgeColor, BadgeSize, BadgeVariant } from '../../types'
2+
13
export default {
24
wrapper: 'relative w-full flex items-center justify-between',
35
container: 'flex items-center min-w-0',
@@ -15,12 +17,12 @@ export default {
1517
},
1618
avatar: {
1719
base: 'flex-shrink-0',
18-
size: '2xs' as const
20+
size: '2xs' as AvatarSize
1921
},
2022
badge: {
2123
base: 'flex-shrink-0 ms-auto relative rounded',
22-
color: 'gray' as const,
23-
variant: 'solid' as const,
24-
size: 'xs' as const
24+
color: 'gray' as BadgeColor,
25+
variant: 'solid' as BadgeVariant,
26+
size: 'xs' as BadgeSize
2527
}
2628
}

‎src/runtime/ui.config/navigation/pagination.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1+
import type { ButtonColor } from '../../types'
2+
13
export default {
24
wrapper: 'flex items-center -space-x-px',
35
base: '',
46
rounded: 'first:rounded-s-md last:rounded-e-md',
57
default: {
68
size: 'sm',
79
activeButton: {
8-
color: 'primary' as const
10+
color: 'primary' as ButtonColor
911
},
1012
inactiveButton: {
11-
color: 'white' as const
13+
color: 'white' as ButtonColor
1214
},
1315
firstButton: {
14-
color: 'white' as const,
16+
color: 'white' as ButtonColor,
1517
class: 'rtl:[&_span:first-child]:rotate-180',
1618
icon: 'i-heroicons-chevron-double-left-20-solid'
1719
},
1820
lastButton: {
19-
color: 'white' as const,
21+
color: 'white' as ButtonColor,
2022
class: 'rtl:[&_span:last-child]:rotate-180',
2123
icon: 'i-heroicons-chevron-double-right-20-solid'
2224
},
2325
prevButton: {
24-
color: 'white' as const,
26+
color: 'white' as ButtonColor,
2527
class: 'rtl:[&_span:first-child]:rotate-180',
2628
icon: 'i-heroicons-chevron-left-20-solid'
2729
},
2830
nextButton: {
29-
color: 'white' as const,
31+
color: 'white' as ButtonColor,
3032
class: 'rtl:[&_span:last-child]:rotate-180',
3133
icon: 'i-heroicons-chevron-right-20-solid'
3234
}

‎src/runtime/ui.config/navigation/verticalNavigation.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AvatarSize, BadgeColor, BadgeSize, BadgeVariant } from '../../types'
2+
13
export default {
24
wrapper: 'relative',
35
base: 'group relative flex items-center gap-1.5 focus:outline-none focus-visible:outline-none dark:focus-visible:outline-none focus-visible:before:ring-inset focus-visible:before:ring-1 focus-visible:before:ring-primary-500 dark:focus-visible:before:ring-primary-400 before:absolute before:inset-px before:rounded-md disabled:cursor-not-allowed disabled:opacity-75',
@@ -17,13 +19,13 @@ export default {
1719
},
1820
avatar: {
1921
base: 'flex-shrink-0',
20-
size: '2xs' as const
22+
size: '2xs' as AvatarSize
2123
},
2224
badge: {
2325
base: 'flex-shrink-0 ms-auto relative rounded',
24-
color: 'gray' as const,
25-
variant: 'solid' as const,
26-
size: 'xs' as const
26+
color: 'gray' as BadgeColor,
27+
variant: 'solid' as BadgeVariant,
28+
size: 'xs' as BadgeSize
2729
},
2830
divider: {
2931
wrapper: {

‎src/runtime/ui.config/overlays/notification.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { AvatarSize, ButtonColor, ButtonSize, ButtonVariant } from '../../types'
2+
13
export default {
24
wrapper: 'w-full pointer-events-auto',
35
container: 'relative overflow-hidden',
@@ -17,7 +19,7 @@ export default {
1719
},
1820
avatar: {
1921
base: 'flex-shrink-0 self-center',
20-
size: 'md' as const
22+
size: 'md' as AvatarSize
2123
},
2224
progress: {
2325
base: 'absolute bottom-0 end-0 start-0 h-1',
@@ -38,13 +40,13 @@ export default {
3840
timeout: 5000,
3941
closeButton: {
4042
icon: 'i-heroicons-x-mark-20-solid',
41-
color: 'gray' as const,
42-
variant: 'link' as const,
43+
color: 'gray' as ButtonColor,
44+
variant: 'link' as ButtonVariant,
4345
padded: false
4446
},
4547
actionButton: {
46-
size: 'xs' as const,
47-
color: 'white' as const
48+
size: 'xs' as ButtonSize,
49+
color: 'white' as ButtonColor
4850
}
4951
}
5052
}

0 commit comments

Comments
 (0)
Please sign in to comment.