@@ -2,33 +2,19 @@ import { computed, Directive, input } from "@angular/core";
2
2
import { tv } from "tailwind-variants" ;
3
3
import { NgpDialog , NgpDialogDescription , NgpDialogOverlay , NgpDialogTitle , NgpDialogTrigger } from "ng-primitives/dialog" ;
4
4
5
- const dialogOverlayVariants = tv ( {
6
- base : 'data-[enter]:animate-in data-[exit]:animate-out data-[exit]:fade-out-0 data-[enter]:fade-in-0 fixed inset-0 z-50 bg-black/50'
7
- } ) ;
8
-
9
5
const dialogVariants = tv ( {
10
- base : 'bg-background data-[enter]:animate-in data-[exit]:animate-out data-[exit]:fade-out-0 data-[enter]:fade-in-0 data-[exit]:zoom-out-95 data-[enter]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border border-border p-6 shadow-lg sm:max-w-lg'
11
- } ) ;
12
-
13
- const dialogHeaderVariants = tv ( {
14
- base : 'flex gap-2 justify-between items-center sm:text-left'
15
- } ) ;
16
-
17
- const dialogFooterVariants = tv ( {
18
- base : 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end'
6
+ slots : {
7
+ base : 'bg-background data-[enter]:animate-in data-[exit]:animate-out data-[exit]:fade-out-0 data-[enter]:fade-in-0 data-[exit]:zoom-out-95 data-[enter]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border border-border p-6 shadow-lg sm:max-w-lg' ,
8
+ overlayVariant : 'data-[enter]:animate-in data-[exit]:animate-out data-[exit]:fade-out-0 data-[enter]:fade-in-0 fixed inset-0 z-50 bg-black/50' ,
9
+ headerVarinat : 'flex gap-2 justify-between items-center sm:text-left' ,
10
+ footerVariant : 'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end' ,
11
+ titleVariant : 'text-lg leading-none font-semibold' ,
12
+ descriptionVariant : 'text-muted-foreground text-sm' ,
13
+ triggerVariant : ''
14
+ }
19
15
} ) ;
20
16
21
- const dialogTitleVariants = tv ( {
22
- base : 'text-lg leading-none font-semibold'
23
- } ) ;
24
-
25
- const dialogDescriptionVariants = tv ( {
26
- base : 'text-muted-foreground text-sm'
27
- } ) ;
28
-
29
- const dialogPlainVariants = tv ( {
30
- base : ''
31
- } )
17
+ const { base, overlayVariant, headerVarinat, footerVariant, titleVariant, descriptionVariant, triggerVariant } = dialogVariants ( ) ;
32
18
33
19
@Directive ( {
34
20
selector : '[uiDialog]' ,
@@ -40,7 +26,7 @@ const dialogPlainVariants = tv({
40
26
} )
41
27
export class UiDialog {
42
28
inputClass = input < string > ( '' , { alias : 'class' } ) ;
43
- computedClass = computed ( ( ) => dialogVariants ( { class : this . inputClass ( ) } ) ) ;
29
+ computedClass = computed ( ( ) => base ( { class : this . inputClass ( ) } ) ) ;
44
30
}
45
31
46
32
@Directive ( {
@@ -53,7 +39,7 @@ export class UiDialog {
53
39
} )
54
40
export class UiDialogHeader {
55
41
inputClass = input < string > ( '' , { alias : 'class' } ) ;
56
- computedClass = computed ( ( ) => dialogHeaderVariants ( { class : this . inputClass ( ) } ) ) ;
42
+ computedClass = computed ( ( ) => headerVarinat ( { class : this . inputClass ( ) } ) ) ;
57
43
}
58
44
59
45
@Directive ( {
@@ -66,7 +52,7 @@ export class UiDialogHeader {
66
52
} )
67
53
export class UiDialogTitle {
68
54
inputClass = input < string > ( '' , { alias : 'class' } ) ;
69
- computedClass = computed ( ( ) => dialogTitleVariants ( { class : this . inputClass ( ) } ) ) ;
55
+ computedClass = computed ( ( ) => titleVariant ( { class : this . inputClass ( ) } ) ) ;
70
56
}
71
57
72
58
@Directive ( {
@@ -79,7 +65,7 @@ export class UiDialogTitle {
79
65
} )
80
66
export class UiDialogDescription {
81
67
inputClass = input < string > ( '' , { alias : 'class' } ) ;
82
- computedClass = computed ( ( ) => dialogDescriptionVariants ( { class : this . inputClass ( ) } ) ) ;
68
+ computedClass = computed ( ( ) => descriptionVariant ( { class : this . inputClass ( ) } ) ) ;
83
69
}
84
70
85
71
@Directive ( {
@@ -92,7 +78,7 @@ export class UiDialogDescription {
92
78
} )
93
79
export class UiDialogFooter {
94
80
inputClass = input < string > ( '' , { alias : 'class' } ) ;
95
- computedClass = computed ( ( ) => dialogFooterVariants ( { class : this . inputClass ( ) } ) ) ;
81
+ computedClass = computed ( ( ) => footerVariant ( { class : this . inputClass ( ) } ) ) ;
96
82
}
97
83
98
84
@Directive ( {
@@ -105,7 +91,7 @@ export class UiDialogFooter {
105
91
} )
106
92
export class UiDialogTrigger {
107
93
inputClass = input < string > ( '' , { alias : 'class' } ) ;
108
- computedClass = computed ( ( ) => dialogPlainVariants ( { class : this . inputClass ( ) } ) ) ;
94
+ computedClass = computed ( ( ) => triggerVariant ( { class : this . inputClass ( ) } ) ) ;
109
95
}
110
96
111
97
@Directive ( {
@@ -118,5 +104,5 @@ export class UiDialogTrigger {
118
104
} )
119
105
export class UiDialogOverlay {
120
106
inputClass = input < string > ( '' , { alias : 'class' } ) ;
121
- computedClass = computed ( ( ) => dialogOverlayVariants ( { class : this . inputClass ( ) } ) ) ;
107
+ computedClass = computed ( ( ) => overlayVariant ( { class : this . inputClass ( ) } ) ) ;
122
108
}
0 commit comments