Skip to content

Commit e10ba37

Browse files
committed
docs(make-it-yours): refactor to use styled modal
1 parent 497f023 commit e10ba37

File tree

1 file changed

+14
-85
lines changed

1 file changed

+14
-85
lines changed

apps/website/src/components/make-it-yours/make-it-yours.tsx

Lines changed: 14 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import {
2-
$,
3-
PropsOf,
4-
component$,
5-
useComputed$,
6-
useSignal,
7-
useStyles$,
8-
} from '@builder.io/qwik';
9-
import { Modal } from '@qwik-ui/headless';
10-
import { Button } from '~/components/ui';
1+
import { $, PropsOf, component$, useComputed$ } from '@builder.io/qwik';
2+
import { Modal, Button, buttonVariants } from '~/components/ui';
113
import {
124
ThemeBaseColor,
135
ThemeBorderRadius,
@@ -25,69 +17,6 @@ import CopyCssConfig from '../copy-css-config/copy-css-config';
2517
import { useAppState } from '~/_state/use-app-state';
2618

2719
export default component$<PropsOf<typeof Button>>(() => {
28-
useStyles$(`
29-
.make-it-yours::backdrop {
30-
background: rgba(0,0,0,0.05);
31-
}
32-
33-
.make-it-yours {
34-
animation: sheetOpen 0.75s forwards cubic-bezier(0.6, 0.6, 0, 1);
35-
}
36-
37-
.make-it-yours::backdrop {
38-
animation: sheetFadeIn 0.75s forwards cubic-bezier(0.6, 0.6, 0, 1);
39-
}
40-
41-
.make-it-yours.modal-closing {
42-
animation: sheetClose 0.35s forwards cubic-bezier(0.6, 0.6, 0, 1);
43-
}
44-
45-
.make-it-yours.modal-closing::backdrop {
46-
animation: sheetFadeOut 0.35s forwards cubic-bezier(0.6, 0.6, 0, 1);
47-
}
48-
49-
@keyframes sheetOpen {
50-
from {
51-
opacity: 0;
52-
transform: translateX(100%);
53-
}
54-
to {
55-
opacity: 1;
56-
transform: translateX(0%);
57-
}
58-
}
59-
60-
@keyframes sheetClose {
61-
from {
62-
opacity: 1;
63-
transform: translateX(0%);
64-
}
65-
to {
66-
opacity: 0;
67-
transform: translateX(100%);
68-
}
69-
}
70-
71-
@keyframes sheetFadeIn {
72-
from {
73-
opacity: 0;
74-
}
75-
to {
76-
opacity: 1;
77-
}
78-
}
79-
80-
@keyframes sheetFadeOut {
81-
from {
82-
opacity: 1;
83-
}
84-
to {
85-
opacity: 0;
86-
}
87-
}
88-
`);
89-
90-
const showSig = useSignal(false);
9120
const rootStore = useAppState();
9221

9322
const { theme, setTheme } = useTheme();
@@ -132,19 +61,17 @@ export default component$<PropsOf<typeof Button>>(() => {
13261
return [font, mode, style, baseColor, primaryColor, borderRadius].join(' ');
13362
});
13463
return (
135-
<Modal.Root closeOnBackdropClick={false} bind:show={showSig}>
136-
<Button
137-
size="sm"
138-
look="outline"
139-
class="flex sm:mr-2 sm:h-10"
140-
onClick$={() => {
141-
showSig.value = true;
142-
}}
64+
<Modal.Root>
65+
<Modal.Trigger
66+
class={cn(
67+
buttonVariants({ size: 'sm', look: 'outline' }),
68+
'flex sm:mr-2 sm:h-10',
69+
)}
14370
>
14471
<LuSlidersHorizontal class={cn('h-4 w-4 sm:mr-2')} />
14572
<span class={cn('hidden', 'sm:block')}>Make it yours</span>
146-
</Button>
147-
<Modal.Panel class="make-it-yours fixed bottom-[50%] right-0 top-[50%] mr-0 h-screen max-w-sm rounded-l-base border-y border-l bg-background px-4 py-8 text-foreground shadow-md sm:w-full">
73+
</Modal.Trigger>
74+
<Modal.Panel class="fixed right-0 mr-0 h-screen max-w-sm rounded-none rounded-l-base border-y border-l data-[closing]:slide-out-to-right data-[open]:slide-in-from-right sm:w-full">
14875
<header class="flex w-full">
14976
<h2 class="justify-self-start text-lg font-bold">Edit Profile</h2>
15077
</header>
@@ -550,9 +477,11 @@ export default component$<PropsOf<typeof Button>>(() => {
550477
</Button>
551478
<CopyCssConfig />
552479
</footer>
553-
<button onClick$={() => (showSig.value = false)} class="absolute right-4 top-5">
480+
<Modal.Close
481+
class={cn(buttonVariants({ size: 'sm', look: 'link' }), 'fixed right-4 top-5')}
482+
>
554483
<LuX class="h-8 w-8" />
555-
</button>
484+
</Modal.Close>
556485
</Modal.Panel>
557486
</Modal.Root>
558487
);

0 commit comments

Comments
 (0)