Skip to content

Commit f219de4

Browse files
committed
chore: update styled modal changeset
1 parent 55b2a41 commit f219de4

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

.changeset/slimy-snakes-poke.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,44 @@ plugins: [
3434

3535
### Modal.Panel
3636

37-
The Panel now uses tailwindcss-animate
37+
The Panel now uses tailwindcss-animate and comes built-in with 5 `position` variant props
3838

3939
```tsx
40-
class={cn(
41-
'max-w-sm rounded-base border bg-background p-6 text-foreground shadow-md backdrop:brightness-50 backdrop:backdrop-blur-sm',
42-
'data-[closed]:duration-300 data-[open]:duration-300 data-[open]:animate-in data-[closing]:animate-out data-[closing]:fade-out data-[open]:fade-in',
43-
'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',
44-
props.class,
45-
)}
40+
export const panelVariants = cva(
41+
[
42+
'fixed w-full bg-background p-6 text-foreground transition-all backdrop:brightness-50 backdrop:backdrop-blur-sm',
43+
'data-[closing]:duration-300 data-[open]:duration-300 data-[open]:animate-in data-[closing]:animate-out',
44+
'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',
45+
],
46+
{
47+
variants: {
48+
position: {
49+
center:
50+
'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',
51+
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',
52+
bottom:
53+
'inset-x-0 bottom-0 mb-0 rounded-t-base border-t data-[closing]:slide-out-to-bottom data-[open]:slide-in-from-bottom',
54+
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',
55+
right:
56+
'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',
57+
},
58+
},
59+
defaultVariants: {
60+
position: 'center',
61+
},
62+
},
63+
);
64+
65+
type PanelProps = PropsOf<typeof HeadlessModal.Panel> &
66+
VariantProps<typeof panelVariants>;
67+
68+
const Panel = component$<PanelProps>(({ position, ...props }) => {
69+
return (
70+
<HeadlessModal.Panel {...props} class={cn(panelVariants({ position }), props.class)}>
71+
<Slot />
72+
</HeadlessModal.Panel>
73+
);
74+
});
4675
```
4776

4877
over previous tailwind.config.js home-made plugin

0 commit comments

Comments
 (0)