Skip to content

Commit a678ca7

Browse files
Merge pull request #734 from thejackshelton/prepare-0.4
New Modal API Changes
2 parents af1cbff + 130c5f4 commit a678ca7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+795
-647
lines changed

.changeset/few-keys-argue.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
'@qwik-ui/headless': minor
3+
---
4+
5+
### Modal API Changes
6+
7+
In a previous release, the following components have been deprecated:
8+
9+
- ModalHeader
10+
- ModalContent
11+
- ModalFooter
12+
13+
These components were native header, div, and footer elements and did nothing special under the hood. We are deprecating them in order to simplify the API and make it more consistent with the rest of the components.
14+
15+
The new components are:
16+
17+
#### <Modal.Root>
18+
19+
This is the main container of the modal, and now holds the major props and configuration. Examples include:
20+
21+
- 'bind:show'?: Signal<boolean>;
22+
- closeOnBackdropClick?: boolean;
23+
- alert?: boolean;
24+
- onShow$?: QRL<() => void>;
25+
- onClose$?: QRL<() => void>;
26+
27+
#### <Modal.Panel>
28+
29+
Previously `<Modal />` the modal panel is the dialog element that is rendered on top of the page. Its props have since been moved to the `<Modal.Root />` component, please refer to the docs for more information.
30+
31+
#### <Modal.Trigger>
32+
33+
The modal now comes with a default trigger, which will open the modal when clicked.
34+
35+
#### <Modal.Title>
36+
37+
This computes the accessible name from the string children of the modal.
38+
39+
### <Modal.Description>
40+
41+
This computes the accessible description from the string children of the modal.
42+
43+
### <Modal.Close>
44+
45+
This is a button that closes the modal when clicked.

apps/website/src/components/copy-css-config/copy-css-config.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default component$(() => {
1515
const { theme } = useTheme();
1616

1717
return (
18-
<>
18+
<Modal.Root bind:show={showSig}>
1919
<Button
2020
onClick$={() => {
2121
cssThemeOutput.value = extractThemeCSS(
@@ -29,10 +29,7 @@ export default component$(() => {
2929
>
3030
Copy code
3131
</Button>
32-
<Modal.Root
33-
bind:show={showSig}
34-
class="my-animation h-[650px] max-w-2xl overflow-x-hidden rounded-base bg-background p-8 text-foreground shadow-md backdrop:backdrop-blur backdrop:backdrop-brightness-50 dark:backdrop:backdrop-brightness-100"
35-
>
32+
<Modal.Panel class="my-animation h-[650px] max-w-2xl overflow-x-hidden rounded-base bg-background p-8 text-foreground shadow-md backdrop:backdrop-blur backdrop:backdrop-brightness-50 dark:backdrop:backdrop-brightness-100">
3633
<header>
3734
<h2 class="mb-2 text-lg font-bold">Copy config</h2>
3835
<p class="mb-6">
@@ -46,7 +43,7 @@ export default component$(() => {
4643
<button onClick$={() => (showSig.value = false)} class="absolute right-6 top-7">
4744
<LuX class="h-8 w-8" />
4845
</button>
49-
</Modal.Root>
50-
</>
46+
</Modal.Panel>
47+
</Modal.Root>
5148
);
5249
});

apps/website/src/components/header/header.tsx

Lines changed: 69 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { SunIcon } from '../icons/SunIcon';
2121
import { LogoIcon, LogoWithBorders } from '../icons/logo';
2222

2323
import { useTheme } from 'qwik-themes';
24-
import MakeItYours from '../make-it-yours/make-it-yours';
2524
import { Modal } from '@qwik-ui/headless';
2625
import { useAppState } from '~/_state/use-app-state';
2726
import { LuX } from '@qwikest/icons/lucide';
@@ -30,6 +29,7 @@ import { useKitMenuItems } from '~/routes/layout';
3029
import { cn } from '@qwik-ui/utils';
3130
import { DiscordIcon } from '../icons/discord';
3231
import { Button, buttonVariants } from '@qwik-ui/styled';
32+
import MakeItYours from '../make-it-yours/make-it-yours';
3333

3434
export interface HeaderProps {
3535
showVersion?: boolean;
@@ -129,82 +129,75 @@ export default component$(({ showVersion = false }: HeaderProps) => {
129129
const { theme } = useTheme();
130130

131131
return (
132-
<>
133-
<div
134-
class={cn(
135-
'sticky top-0 z-10 flex h-16 justify-center border-b bg-background',
136-
theme?.includes('brutalist') && 'border-b-2',
137-
)}
138-
>
139-
<header class="flex w-full max-w-screen-2xl items-center justify-between">
140-
<section class="flex items-center justify-start">
141-
<a href="/" aria-label="Qwik UI Logo" class="ml-4">
142-
<LogoWithBorders class="hidden sm:block" />
143-
<LogoIcon class="block sm:hidden" />
144-
</a>
145-
{showVersion && (
146-
<div class="ml-4 hidden text-xs md:flex">
147-
{kitSignal.value?.name &&
148-
kitSignal.value?.name + ' ' + kitSignal.value?.version}
149-
</div>
150-
)}
151-
</section>
152-
153-
<div class="mr-4 flex items-center">
154-
<div class="mr-6 hidden items-center space-x-8 text-sm lg:flex">
155-
<a
156-
class={isDocsActive('/docs/headless/')}
157-
href="/docs/headless/introduction/"
158-
>
159-
Headless
160-
</a>
161-
{rootStore.featureFlags?.showStyled && (
162-
<a
163-
class={isDocsActive('/docs/styled/')}
164-
href="/docs/styled/introduction/"
165-
>
166-
Styled
167-
</a>
168-
)}
132+
<Modal.Root
133+
class={cn(
134+
'sticky top-0 z-10 flex h-16 justify-center border-b bg-background',
135+
theme?.includes('brutalist') && 'border-b-2',
136+
)}
137+
bind:show={isSidebarOpenedSig}
138+
>
139+
<header class="flex w-full max-w-screen-2xl items-center justify-between">
140+
<section class="flex items-center justify-start">
141+
<a href="/" aria-label="Qwik UI Logo" class="ml-4">
142+
<LogoWithBorders class="hidden sm:block" />
143+
<LogoIcon class="block sm:hidden" />
144+
</a>
145+
{showVersion && (
146+
<div class="ml-4 hidden text-xs md:flex">
147+
{kitSignal.value?.name &&
148+
kitSignal.value?.name + ' ' + kitSignal.value?.version}
169149
</div>
170-
<div class="flex items-center space-x-1 xs:space-x-4">
171-
<MakeItYours />
172-
<a
173-
href="https://discord.gg/PVWUUejrez"
174-
target="_blank"
175-
class={cn(buttonVariants({ size: 'icon', look: 'ghost' }))}
176-
>
177-
<DiscordIcon />
178-
</a>
179-
<a
180-
target="_blank"
181-
href="https://github.com/qwikifiers/qwik-ui"
182-
aria-label="Qwik-UI GitHub repository"
183-
class={cn(buttonVariants({ size: 'icon', look: 'ghost' }))}
184-
>
185-
<GitHubIcon />
150+
)}
151+
</section>
152+
153+
<div class="mr-4 flex items-center">
154+
<div class="mr-6 hidden items-center space-x-8 text-sm lg:flex">
155+
<a
156+
class={isDocsActive('/docs/headless/')}
157+
href="/docs/headless/introduction/"
158+
>
159+
Headless
160+
</a>
161+
{rootStore.featureFlags?.showStyled && (
162+
<a class={isDocsActive('/docs/styled/')} href="/docs/styled/introduction/">
163+
Styled
186164
</a>
187-
<DarkModeToggle />
188-
<Button
189-
type="button"
190-
aria-label="Toggle navigation"
191-
onClick$={() => {
192-
isSidebarOpenedSig.value = !isSidebarOpenedSig.value;
193-
}}
194-
size="icon"
195-
look="ghost"
196-
class="flex lg:hidden"
197-
>
198-
{isSidebarOpenedSig.value ? <CloseIcon /> : <MenuIcon />}
199-
</Button>
200-
</div>
165+
)}
201166
</div>
202-
</header>
203-
</div>
204-
<Modal.Root
205-
bind:show={isSidebarOpenedSig}
206-
class="sidebar-mobile ml-auto mr-0 h-screen w-full min-w-80 max-w-sm rounded-base border-0 bg-background p-8 text-foreground shadow-md"
207-
>
167+
<div class="flex items-center space-x-1 xs:space-x-4">
168+
<MakeItYours />
169+
<a
170+
href="https://discord.gg/PVWUUejrez"
171+
target="_blank"
172+
class={cn(buttonVariants({ size: 'icon', look: 'ghost' }))}
173+
>
174+
<DiscordIcon />
175+
</a>
176+
<a
177+
target="_blank"
178+
href="https://github.com/qwikifiers/qwik-ui"
179+
aria-label="Qwik-UI GitHub repository"
180+
class={cn(buttonVariants({ size: 'icon', look: 'ghost' }))}
181+
>
182+
<GitHubIcon />
183+
</a>
184+
<DarkModeToggle />
185+
<Button
186+
type="button"
187+
aria-label="Toggle navigation"
188+
onClick$={() => {
189+
isSidebarOpenedSig.value = !isSidebarOpenedSig.value;
190+
}}
191+
size="icon"
192+
look="ghost"
193+
class="flex lg:hidden"
194+
>
195+
{isSidebarOpenedSig.value ? <CloseIcon /> : <MenuIcon />}
196+
</Button>
197+
</div>
198+
</div>
199+
</header>
200+
<Modal.Panel class="sidebar-mobile ml-auto mr-0 h-screen w-full min-w-80 max-w-sm rounded-base border-0 bg-background p-8 text-foreground shadow-md">
208201
<div class="mb-2 pb-4 pt-2">
209202
<DocsNavigation
210203
linksGroups={
@@ -220,8 +213,8 @@ export default component$(({ showVersion = false }: HeaderProps) => {
220213
>
221214
<LuX class="h-8 w-8" />
222215
</button>
223-
</Modal.Root>
224-
</>
216+
</Modal.Panel>
217+
</Modal.Root>
225218
);
226219
});
227220

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default component$<PropsOf<typeof Button>>(() => {
132132
return [font, mode, style, baseColor, primaryColor, borderRadius].join(' ');
133133
});
134134
return (
135-
<div>
135+
<Modal.Root closeOnBackdropClick={false} bind:show={showSig}>
136136
<Button
137137
size="sm"
138138
look="outline"
@@ -144,11 +144,7 @@ export default component$<PropsOf<typeof Button>>(() => {
144144
<LuSlidersHorizontal class={cn('h-4 w-4 sm:mr-3')} />
145145
<span class={cn('hidden', 'sm:block')}>Make it yours</span>
146146
</Button>
147-
<Modal.Root
148-
closeOnBackdropClick={false}
149-
bind:show={showSig}
150-
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"
151-
>
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">
152148
<header class="flex w-full">
153149
<h2 class="justify-self-start text-lg font-bold">Edit Profile</h2>
154150
</header>
@@ -557,7 +553,7 @@ export default component$<PropsOf<typeof Button>>(() => {
557553
<button onClick$={() => (showSig.value = false)} class="absolute right-4 top-5">
558554
<LuX class="h-8 w-8" />
559555
</button>
560-
</Modal.Root>
561-
</div>
556+
</Modal.Panel>
557+
</Modal.Root>
562558
);
563559
});

apps/website/src/components/showcase/showcase.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ export const Showcase = component$<ShowcaseProps>(({ name, ...props }) => {
3636
selectedClassName="bg-primary hover:bg-primary text-primary-foreground hover:text-primary-foreground border-t-1 font-medium "
3737
>
3838
<Tabs.List class="flex rounded-t-lg border border-b-0 bg-accent">
39-
<Tabs.Tab class="rounded-tl-md px-3 py-2 hover:bg-primary/90 hover:text-primary-foreground">
39+
<Tabs.Tab class="h-[44px] rounded-tl-md px-3 py-2 hover:bg-primary/90 hover:text-primary-foreground">
4040
Preview
4141
</Tabs.Tab>
42-
<Tabs.Tab class="px-3 py-2 hover:bg-primary/90 hover:text-primary-foreground">
42+
<Tabs.Tab class="h-[44px] px-3 py-2 hover:bg-primary/90 hover:text-primary-foreground">
4343
Code
4444
</Tabs.Tab>
4545
</Tabs.List>

apps/website/src/global.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,10 @@
12941294
.dark .note-link a {
12951295
border-bottom: 1px solid white !important;
12961296
}
1297+
1298+
.gif-container {
1299+
border-radius: var(--border-radius);
1300+
}
12971301
}
12981302

12991303
:root {
Lines changed: 23 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,29 @@
1-
import { component$ } from '@builder.io/qwik';
1+
import { component$, useStyles$ } from '@builder.io/qwik';
22
import { Accordion } from '@qwik-ui/headless';
3-
import SVG from './svg';
3+
import { LuChevronDown } from '@qwikest/icons/lucide';
44

55
export default component$(() => {
6+
useStyles$(styles);
7+
const items = [1, 2, 3];
8+
69
return (
7-
<>
8-
<div class="flex w-full justify-center">
9-
<Accordion.Root class="w-full" animated enhance={true}>
10-
<Accordion.Item class="border-b">
11-
<Accordion.Header as="h3">
12-
<Accordion.Trigger class="group flex w-full items-center justify-between rounded-t-sm py-4 text-left hover:underline">
13-
<span>Can I add headings inside the accordion?</span>
14-
<span class="pl-2">
15-
<SVG class="ease transition-transform duration-500 group-aria-expanded:rotate-180 group-aria-expanded:transform" />
16-
</span>
17-
</Accordion.Trigger>
18-
</Accordion.Header>
19-
<Accordion.Content class="accordion-animation-1 overflow-hidden">
20-
<p class="pb-4">
21-
Yes, if you wrap the <strong>Accordion.Header</strong> component around
22-
the trigger, screen readers will announce it properly.
23-
</p>
24-
</Accordion.Content>
25-
</Accordion.Item>
26-
<Accordion.Item class="border-b">
27-
<Accordion.Header as="h3">
28-
<Accordion.Trigger class="group flex w-full items-center justify-between py-4 text-left hover:underline">
29-
<span>Is it easy to animate?</span>
30-
<span class="pl-2">
31-
<SVG class="ease transition-transform duration-500 group-aria-expanded:rotate-180 group-aria-expanded:transform" />
32-
</span>
33-
</Accordion.Trigger>
34-
</Accordion.Header>
35-
<Accordion.Content class="accordion-animation-1 overflow-hidden">
36-
<p class="pb-4">
37-
Yup! You can even use animations or CSS transitions using the{' '}
38-
<strong>animated</strong> prop on the accordion root!
39-
</p>
40-
</Accordion.Content>
41-
</Accordion.Item>
42-
<Accordion.Item class="border-b">
43-
<Accordion.Header as="h3">
44-
<Accordion.Trigger class="group flex w-full items-center justify-between py-4 text-left hover:underline aria-expanded:rounded-none">
45-
<span>How about opening multiple items?</span>
46-
<span class="pl-2">
47-
<SVG class="ease transition-transform duration-500 group-aria-expanded:rotate-180 group-aria-expanded:transform" />
48-
</span>
49-
</Accordion.Trigger>
50-
</Accordion.Header>
51-
<Accordion.Content class="accordion-animation-1 overflow-hidden">
52-
<p class="pb-4">
53-
You can do that by setting the <strong>behavior</strong> prop to "multi"
54-
on the Accordion
55-
</p>
56-
</Accordion.Content>
57-
</Accordion.Item>
58-
</Accordion.Root>
59-
</div>
60-
</>
10+
<Accordion.Root>
11+
{items.map((item) => (
12+
<Accordion.Item class="accordion-item" key={item}>
13+
<Accordion.Header>
14+
<Accordion.Trigger class="accordion-trigger">
15+
<span>Trigger {item}</span>
16+
<LuChevronDown />
17+
</Accordion.Trigger>
18+
</Accordion.Header>
19+
<Accordion.Content class="accordion-content">
20+
Inside Content {item}
21+
</Accordion.Content>
22+
</Accordion.Item>
23+
))}
24+
</Accordion.Root>
6125
);
6226
});
27+
28+
// interal
29+
import styles from '../snippets/accordion.css?inline';

0 commit comments

Comments
 (0)