@@ -24,24 +24,45 @@ qwik-ui add modal
24
24
import { PropsOf , Slot , component$ } from ' @builder.io/qwik' ;
25
25
import { Modal as HeadlessModal } from ' @qwik-ui/headless' ;
26
26
import { cn } from ' @qwik-ui/utils' ;
27
+ import { cva , type VariantProps } from ' class-variance-authority' ;
27
28
28
29
const Root = HeadlessModal .Root ;
29
30
30
31
const Trigger = HeadlessModal .Trigger ;
31
32
32
33
const Close = HeadlessModal .Close ;
33
34
34
- const Panel = component$ <PropsOf <typeof HeadlessModal .Panel >>((props ) => {
35
+ export const panelVariants = cva (
36
+ [
37
+ ' fixed w-full bg-background p-6 text-foreground transition-all backdrop:brightness-50 backdrop:backdrop-blur-sm' ,
38
+ ' data-[closing]:duration-300 data-[open]:duration-300 data-[open]:animate-in data-[closing]:animate-out' ,
39
+ ' backdrop:data-[closing]:duration-300 backdrop:data-[open]:duration-300 backdrop:data-[open]:animate-in backdrop:data-[closing]:animate-out backdrop:data-[closing]:fade-out backdrop:data-[open]:fade-in' ,
40
+ ],
41
+ {
42
+ variants: {
43
+ position: {
44
+ center:
45
+ ' max-w-lg rounded-base shadow-lg data-[state=closed]:fade-out data-[state=open]:fade-in data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-bottom-2 backdrop:data-[closing]:fade-out backdrop:data-[open]:fade-in' ,
46
+ top: ' inset-x-0 top-0 mt-0 rounded-b-base border-b data-[closing]:slide-out-to-top data-[open]:slide-in-from-top' ,
47
+ bottom:
48
+ ' inset-x-0 bottom-0 mb-0 rounded-t-base border-t data-[closing]:slide-out-to-bottom data-[open]:slide-in-from-bottom' ,
49
+ left: ' inset-y-0 left-0 ml-0 h-full max-w-sm rounded-r-base border-r data-[closing]:slide-out-to-left data-[open]:slide-in-from-left' ,
50
+ right:
51
+ ' inset-y-0 right-0 mr-0 h-full max-w-sm rounded-l-base border-l data-[closing]:slide-out-to-right data-[open]:slide-in-from-right' ,
52
+ },
53
+ },
54
+ defaultVariants: {
55
+ position: ' center' ,
56
+ },
57
+ },
58
+ );
59
+
60
+ type PanelProps = PropsOf <typeof HeadlessModal .Panel > &
61
+ VariantProps <typeof panelVariants >;
62
+
63
+ const Panel = component$ <PanelProps >(({ position , ... props }) => {
35
64
return (
36
- <HeadlessModal.Panel
37
- { ... props }
38
- class = { cn (
39
- ' max-w-sm rounded-base border bg-background p-6 text-foreground shadow-md backdrop:brightness-50 backdrop:backdrop-blur-sm' ,
40
- ' data-[closed]:duration-300 data-[open]:duration-300 data-[open]:animate-in data-[closing]:animate-out data-[closing]:fade-out data-[open]:fade-in' ,
41
- ' backdrop:data-[closed]:duration-300 backdrop:data-[open]:duration-300 backdrop:data-[open]:animate-in backdrop:data-[closing]:animate-out backdrop:data-[closing]:fade-out backdrop:data-[open]:fade-in' ,
42
- props .class ,
43
- )}
44
- >
65
+ <HeadlessModal.Panel { ... props } class = { cn (panelVariants ({ position }), props .class )} >
45
66
<Slot />
46
67
</HeadlessModal.Panel >
47
68
);
@@ -103,3 +124,7 @@ import { Button, Modal } from '~/components/ui';
103
124
</Modal.Panel >
104
125
</Modal.Root >
105
126
```
127
+
128
+ ## Examples
129
+
130
+ <Showcase name = " sheet" />
0 commit comments