Skip to content

Commit 94bb6d9

Browse files
authored
Merge pull request #633 from maiieul/docs-ux
docs(UX/make-it-yours) improvements
2 parents 29bb39a + ebfc0d7 commit 94bb6d9

File tree

10 files changed

+220
-174
lines changed

10 files changed

+220
-174
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export interface AppState {
22
featureFlags?: {
33
showStyled?: boolean;
4+
showNeumorphic?: boolean;
45
};
56
}

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { $, component$, useSignal } from '@builder.io/qwik';
1+
import { component$, useSignal } from '@builder.io/qwik';
22
import { Modal, ModalContent, ModalHeader } from '@qwik-ui/headless';
33
import { Button } from '@qwik-ui/styled';
44
import { extractThemeCSS } from '@qwik-ui/utils';
@@ -13,23 +13,17 @@ export default component$(() => {
1313

1414
const { theme } = useTheme();
1515

16-
const generateCSSThemeOutput = $(async () => {
17-
console.log('theme', theme);
18-
const cssRules = extractThemeCSS(
19-
theme === 'dark' || theme === 'light'
20-
? 'border-radius-0 simple primary-cyan-600 light base-slate'
21-
: theme,
22-
globalCSS,
23-
);
24-
cssThemeOutput.value = cssRules;
25-
});
26-
2716
return (
2817
<>
2918
<Button
3019
onClick$={() => {
3120
showSig.value = true;
32-
generateCSSThemeOutput();
21+
cssThemeOutput.value = extractThemeCSS(
22+
theme === 'dark' || theme === 'light'
23+
? 'border-radius-0 simple primary-cyan-600 light base-slate'
24+
: theme,
25+
globalCSS,
26+
);
3327
}}
3428
>
3529
Copy code

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

Lines changed: 84 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { component$, useComputed$, useSignal, useStyles$ } from '@builder.io/qwik';
1+
import { $, component$, useComputed$, useSignal, useStyles$ } from '@builder.io/qwik';
22
// eslint-disable-next-line @nx/enforce-module-boundaries
33
import { version as headlessVersion } from '../../../../../packages/kit-headless/package.json';
44
// eslint-disable-next-line @nx/enforce-module-boundaries
@@ -23,6 +23,7 @@ import { LuX } from '@qwikest/icons/lucide';
2323
import { DocsNavigation } from '../navigation-docs/navigation-docs';
2424
import { useKitMenuItems } from '~/routes/layout';
2525
import { cn } from '@qwik-ui/utils';
26+
import { DiscordIcon } from '../icons/discord';
2627

2728
export interface HeaderProps {
2829
showVersion?: boolean;
@@ -128,21 +129,34 @@ export default component$(({ showVersion = false }: HeaderProps) => {
128129

129130
const { theme, setTheme } = useTheme();
130131

132+
const switchLightDark = $((input: string | string[]): string | string[] | undefined => {
133+
const switchWord = (word: string): string =>
134+
word.includes('light')
135+
? word.replace('light', 'dark')
136+
: word.replace('dark', 'light');
137+
if (typeof input === 'string') {
138+
return switchWord(input);
139+
} else if (Array.isArray(input)) {
140+
return input.map((item) => switchWord(item));
141+
}
142+
});
143+
131144
return (
132145
<div
133146
class={cn(
134147
'bg-background sticky top-0 z-10 flex h-16 justify-center border-b',
135148
theme?.includes('brutalist') && 'border-b-2',
136149
)}
137150
>
138-
<header class="xs:gap-8 flex w-full max-w-screen-2xl items-center gap-6">
139-
<section class="mr-auto flex flex-col gap-1 md:flex-row md:gap-8">
140-
<a href="/" aria-label="Qwik UI Logo" class="lg:ml-8">
151+
<header class="flex w-full max-w-screen-2xl items-center justify-between">
152+
<div class="block sm:hidden" />
153+
<section class="xs:flex xs:items-center mr-auto hidden">
154+
<a href="/" aria-label="Qwik UI Logo" class="ml-8">
141155
<LogoWithBorders />
142156
</a>
143157
{showVersion && (
144158
<div data-tip="Qwik-UI Version" class="mr-auto">
145-
<div class="ml-2 flex flex-row gap-1 text-xs md:mt-1 md:flex-col md:text-sm">
159+
<div class="ml-4 hidden text-xs sm:flex-col md:flex">
146160
<span> {kitSignal.value?.name} Kit </span>
147161
<span>
148162
{' '}
@@ -153,84 +167,81 @@ export default component$(({ showVersion = false }: HeaderProps) => {
153167
)}
154168
</section>
155169

156-
<nav class="hidden gap-4 lg:flex">
157-
<a class={isRouteActive('/about')} href="/about">
158-
About
159-
</a>
160-
<a class={isDocsActive('/docs/headless/')} href="/docs/headless/introduction">
161-
Headless Kit
162-
</a>
163-
{rootStore.featureFlags?.showStyled && (
164-
<a class={isDocsActive('/docs/styled/')} href="/docs/styled/introduction">
165-
Styled Kit
170+
<div class="xs:space-x-8 mr-4 flex items-center space-x-6">
171+
<nav class="hidden gap-4 lg:flex">
172+
<a class={isDocsActive('/docs/headless/')} href="/docs/headless/introduction">
173+
Headless Kit
166174
</a>
167-
)}
175+
{rootStore.featureFlags?.showStyled && (
176+
<a class={isDocsActive('/docs/styled/')} href="/docs/styled/introduction">
177+
Styled Kit
178+
</a>
179+
)}
180+
</nav>
181+
<MakeItYours />
168182
<a
169183
class={isRouteActive('https://discord.gg/PVWUUejrez')}
170184
href="https://discord.gg/PVWUUejrez"
171185
target="_blank"
172186
>
173-
Community
187+
<DiscordIcon />
174188
</a>
175-
{/* <a href="/contact">Contact</a> */}
176-
</nav>
177-
<MakeItYours />
178-
<button
179-
type="button"
180-
aria-label="Toggle dark mode"
181-
onClick$={() => {
182-
theme?.includes('light') ? setTheme('dark') : setTheme('light');
183-
}}
184-
>
185-
<div class="hidden dark:block">
186-
<MoonIcon />
187-
</div>
188-
<div class="block dark:hidden">
189-
<SunIcon />
190-
</div>
191-
</button>
192-
<a
193-
target="_blank"
194-
href="https://github.com/qwikifiers/qwik-ui"
195-
aria-label="Qwik-UI GitHub repository"
196-
class="sm:mr-8"
197-
>
198-
<GitHubIcon />
199-
</a>
200-
<button
201-
type="button"
202-
aria-label="Toggle navigation"
203-
onClick$={() => {
204-
isSidebarOpenedSig.value = !isSidebarOpenedSig.value;
205-
}}
206-
class="mr-4 block lg:hidden"
207-
>
208-
{isSidebarOpenedSig.value ? <CloseIcon /> : <MenuIcon />}
209-
</button>
210-
<Modal
211-
bind:show={isSidebarOpenedSig}
212-
class="sidebar-mobile bg-background text-foreground rounded-base ml-0 mr-auto h-screen max-w-lg border-0 p-8 shadow-md"
213-
>
214-
<ModalHeader>
215-
<h2 class="text-lg font-bold">Copy config</h2>
216-
<p>
217-
Copy and paste the following code into your global.css file to apply the
218-
styles.
219-
</p>
220-
</ModalHeader>
221-
<ModalContent class="mb-2 pb-4 pt-2">
222-
<DocsNavigation
223-
linksGroups={menuItemsGroups}
224-
class="bg-background max-w-80 overflow-auto"
225-
/>
226-
</ModalContent>
189+
<a
190+
target="_blank"
191+
href="https://github.com/qwikifiers/qwik-ui"
192+
aria-label="Qwik-UI GitHub repository"
193+
class="sm:mr-8"
194+
>
195+
<GitHubIcon />
196+
</a>
197+
<button
198+
type="button"
199+
aria-label="Toggle dark mode"
200+
onClick$={async () => setTheme(await switchLightDark(theme || 'light'))}
201+
>
202+
<div class="hidden dark:block">
203+
<MoonIcon />
204+
</div>
205+
<div class="block dark:hidden">
206+
<SunIcon />
207+
</div>
208+
</button>
209+
227210
<button
228-
onClick$={() => (isSidebarOpenedSig.value = false)}
229-
class="absolute right-6 top-[26px]"
211+
type="button"
212+
aria-label="Toggle navigation"
213+
onClick$={() => {
214+
isSidebarOpenedSig.value = !isSidebarOpenedSig.value;
215+
}}
216+
class="mr-4 block lg:hidden"
230217
>
231-
<LuX class="h-8 w-8" />
218+
{isSidebarOpenedSig.value ? <CloseIcon /> : <MenuIcon />}
232219
</button>
233-
</Modal>
220+
<Modal
221+
bind:show={isSidebarOpenedSig}
222+
class="sidebar-mobile bg-background text-foreground rounded-base ml-0 mr-auto h-screen max-w-lg border-0 p-8 shadow-md"
223+
>
224+
<ModalHeader>
225+
<h2 class="text-lg font-bold">Copy config</h2>
226+
<p>
227+
Copy and paste the following code into your global.css file to apply the
228+
styles.
229+
</p>
230+
</ModalHeader>
231+
<ModalContent class="mb-2 pb-4 pt-2">
232+
<DocsNavigation
233+
linksGroups={menuItemsGroups}
234+
class="bg-background max-w-80 overflow-auto"
235+
/>
236+
</ModalContent>
237+
<button
238+
onClick$={() => (isSidebarOpenedSig.value = false)}
239+
class="absolute right-6 top-[26px]"
240+
>
241+
<LuX class="h-8 w-8" />
242+
</button>
243+
</Modal>
244+
</div>
234245
</header>
235246
</div>
236247
);

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

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LuSlidersHorizontal, LuX } from '@qwikest/icons/lucide';
66
import { useTheme } from 'qwik-themes';
77
import { baseOptions, borderRadiusOptions, primaryOptions } from '~/_state/make-it-yours';
88
import CopyCssConfig from '../copy-css-config/copy-css-config';
9+
import { useAppState } from '~/_state/use-app-state';
910

1011
export default component$(() => {
1112
useStyles$(`
@@ -71,6 +72,7 @@ export default component$(() => {
7172
`);
7273

7374
const showSig = useSignal(false);
75+
const rootStore = useAppState();
7476

7577
const { theme, setTheme } = useTheme();
7678

@@ -93,17 +95,18 @@ export default component$(() => {
9395
});
9496
return (
9597
<section>
96-
<button
98+
<Button
99+
look="outline"
97100
onClick$={() => {
98101
showSig.value = true;
99102
}}
100103
class="hover:bg-accent/80 rounded-base border px-3 py-2"
101104
>
102105
<div class="flex justify-center">
103-
<LuSlidersHorizontal class="mr-3 h-6 w-6" />
106+
<LuSlidersHorizontal class="h-6 w-6 sm:mr-3" />
104107
<span class="hidden sm:block">Make it yours</span>
105108
</div>
106-
</button>
109+
</Button>
107110
<Modal
108111
closeOnBackdropClick={false}
109112
bind:show={showSig}
@@ -135,7 +138,9 @@ export default component$(() => {
135138
>
136139
<option value={'simple'}>Simple</option>
137140
<option value={'brutalist'}>Brutalist</option>
138-
<option value={'neumorphic'}>Neumorphic</option>
141+
{rootStore.featureFlags?.showNeumorphic && (
142+
<option value={'neumorphic'}>Neumorphic</option>
143+
)}
139144
</select>
140145

141146
<label class="mb-1 mt-8 block font-medium">Base</label>
@@ -465,7 +470,7 @@ export default component$(() => {
465470

466471
<div>
467472
<label class="mb-1 mt-8 block font-medium">Radius</label>
468-
<div class="flex flex-col space-y-2">
473+
<div class="flex space-x-3">
469474
{borderRadiusOptions.map((borderRadius) => {
470475
const isActive =
471476
themeComputedObjectSig.value.borderRadius === borderRadius;
@@ -477,9 +482,13 @@ export default component$(() => {
477482
themeComputedObjectSig.value.borderRadius = borderRadius;
478483
setTheme(await themeStoreToThemeClasses$());
479484
}}
480-
class={cn(isActive && 'border-ring mb-2')}
485+
class={cn('w-12', isActive && 'border-ring mb-2')}
481486
>
482-
{borderRadius}
487+
{borderRadius === 'border-radius-0' && 0}
488+
{borderRadius === 'border-radius-dot-25' && '.25'}
489+
{borderRadius === 'border-radius-dot-50' && '.5'}
490+
{borderRadius === 'border-radius-dot-75' && '.75'}
491+
{borderRadius === 'border-radius-1' && 1}
483492
</Button>
484493
);
485494
})}
@@ -501,7 +510,13 @@ export default component$(() => {
501510
</div>
502511
</ModalContent>
503512

504-
<ModalFooter class=" flex w-full justify-end gap-4">
513+
<ModalFooter class=" flex w-full justify-between gap-4">
514+
<Button
515+
look="ghost"
516+
onClick$={() => setTheme(theme?.includes('dark') ? 'dark' : 'light')}
517+
>
518+
Reset
519+
</Button>
505520
<CopyCssConfig />
506521
</ModalFooter>
507522
<button onClick$={() => (showSig.value = false)} class="absolute right-6 top-7">

0 commit comments

Comments
 (0)