1
- import { computed , defineComponent } from 'vue'
1
+ import { defineComponent , toRef } from 'vue'
2
+ import { useConfigurable } from '@/composables/useConfigurable'
2
3
import { useTypographyProps } from '@/composables/useTypography'
3
4
4
5
export const ATypography = defineComponent ( {
@@ -7,71 +8,37 @@ export const ATypography = defineComponent({
7
8
...useTypographyProps ( ) ,
8
9
} ,
9
10
setup ( props , { slots } ) {
10
- const title = computed ( ( ) => {
11
- const [ titleContent , titleClasses ] = props . title === undefined
12
- ? [ ]
13
- : typeof props . title === 'string'
14
- ? [ props . title ]
15
- : props . title
11
+ const title = useConfigurable ( toRef ( props , 'title' ) )
12
+ const subtitle = useConfigurable ( toRef ( props , 'subtitle' ) )
13
+ const text = useConfigurable ( toRef ( props , 'text' ) )
16
14
17
- return {
18
- titleContent,
19
- titleClasses,
20
- }
21
- } )
22
-
23
- // const [subtitleContent, subtitleClasses] = computed(() => props.subtitle === undefined
24
- const subtitle = computed ( ( ) => {
25
- const [ subtitleContent , subtitleClasses ] = props . subtitle === undefined
26
- ? [ ]
27
- : typeof props . subtitle === 'string'
28
- ? [ props . subtitle ]
29
- : props . subtitle
30
-
31
- return {
32
- subtitleContent,
33
- subtitleClasses,
34
- }
35
- } )
36
-
37
- const text = computed ( ( ) => {
38
- const [ textContent , textClasses ] = props . text === undefined
39
- ? [ ]
40
- : typeof props . text === 'string'
41
- ? [ props . text ]
42
- : props . text
43
-
44
- return {
45
- textContent,
46
- textClasses,
47
- }
48
- } )
49
-
50
- const typographyHeader = < div class = "flex justify-between" >
15
+ // TODO: Remove class block and use commented tag defaults instead of span once VitePress allow style isolation
16
+ return ( ) => {
17
+ const typographyHeader = < div class = "flex justify-between" >
51
18
< div class = "flex-grow" >
52
19
{
53
20
slots . title || props . title
54
- ? < props . titleTag class = { [ 'font-medium block em:uno-layer-base-text-lg uno-layer-base-text-[hsla(var(--a-typography-title-color),var(--a-typography-title-opacity))]' , title . value . titleClasses ] } > { slots . title ? slots . title ( ) : title . value . titleContent } </ props . titleTag >
21
+ ? < props . titleTag { ... title . value . attrs } class = { [ 'font-medium block em:uno-layer-base-text-lg uno-layer-base-text-[hsla(var(--a-typography-title-color),var(--a-typography-title-opacity))]' , title . value . classes ] } > { slots . title ? slots . title ( ) : title . value . content } </ props . titleTag >
55
22
: null
56
23
}
57
24
{
58
25
slots . subtitle || props . subtitle
59
- ? < props . subtitleTag class = { [ 'block em:uno-layer-base-text-sm uno-layer-base-text-[hsla(var(--a-typography-subtitle-color),var(--a-typography-subtitle-opacity))]' , subtitle . value . subtitleClasses ] } > { slots . subtitle ? slots . subtitle ( ) : subtitle . value . subtitleContent } </ props . subtitleTag >
26
+ ? < props . subtitleTag { ... subtitle . value . attrs } class = { [ 'block em:uno-layer-base-text-sm uno-layer-base-text-[hsla(var(--a-typography-subtitle-color),var(--a-typography-subtitle-opacity))]' , subtitle . value . classes ] } > { slots . subtitle ? slots . subtitle ( ) : subtitle . value . content } </ props . subtitleTag >
60
27
: null
61
28
}
62
29
</ div >
63
30
{ slots . headerRight ?.( ) }
64
31
</ div >
65
32
66
- // TODO: Remove class block and use commented tag defaults instead of span once VitePress allow style isolation
67
- return ( ) => < div class = "uno-layer-base-text-base gap-4 flex flex-col" >
33
+ return < div class = "uno-layer-base-text-base gap-4 flex flex-col" >
68
34
{ slots . title || props . title || slots . subtitle || props . subtitle || slots . headerRight ? typographyHeader : null }
69
35
{
70
36
slots . default || props . text
71
- ? < props . textTag class = { [ 'em:uno-layer-base-text-base uno-layer-base-text-[hsla(var(--a-typography-text-color),var(--a-typography-text-opacity))]' , text . value . textClasses ] } > { slots . default ? slots . default ( ) : text . value . textContent } </ props . textTag >
37
+ ? < props . textTag { ... text . value . attrs } class = { [ 'em:uno-layer-base-text-base uno-layer-base-text-[hsla(var(--a-typography-text-color),var(--a-typography-text-opacity))]' , text . value . classes ] } > { slots . default ? slots . default ( ) : text . value . content } </ props . textTag >
72
38
: null
73
39
}
74
40
</ div >
41
+ }
75
42
} ,
76
43
} )
77
44
0 commit comments