Skip to content

Commit 40c170c

Browse files
authored
Merge pull request #786 from maiieul/docs-small-fixes
Docs-small-fixes
2 parents 4caacd1 + 02a4910 commit 40c170c

File tree

8 files changed

+72
-93
lines changed

8 files changed

+72
-93
lines changed

apps/website/src/routes/docs/styled/accordion/index.mdx

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import { cn } from '@qwik-ui/utils';
2828

2929
import { LuChevronDown } from '@qwikest/icons/lucide';
3030

31-
const Root = component$<PropsOf<typeof HeadlessAccordion.Root>>((props) => (
32-
<HeadlessAccordion.Root animated {...props}>
33-
<Slot />
31+
const Root = (props: PropsOf<typeof HeadlessAccordion.Root>) => (
32+
<HeadlessAccordion.Root {...props} accordionItemComponent={Item}>
33+
{props.children}
3434
</HeadlessAccordion.Root>
35-
));
35+
);
3636

3737
const Item = component$<PropsOf<typeof HeadlessAccordion.Item>>((props) => {
3838
return (
@@ -52,7 +52,7 @@ const Trigger = component$<
5252
<HeadlessAccordion.Trigger
5353
{...props}
5454
class={cn(
55-
'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
55+
'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-open]>svg]:rotate-180',
5656
props.class,
5757
)}
5858
>
@@ -68,7 +68,7 @@ const Content = component$<PropsOf<typeof HeadlessAccordion.Content>>((props) =>
6868
<HeadlessAccordion.Content
6969
{...props}
7070
class={cn(
71-
'overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down',
71+
'overflow-hidden text-sm data-[closed]:animate-accordion-up data-[open]:animate-accordion-down',
7272
props.class,
7373
)}
7474
>
@@ -87,24 +87,6 @@ export const Accordion = {
8787
};
8888
```
8989

90-
### 2. Update your 'tailwind.config.cjs'
91-
92-
Add the following animations to your tailwind.config.js file:
93-
94-
```tsx
95-
/** @type {import('tailwindcss').Config} */
96-
module.exports = {
97-
theme: {
98-
extend: {
99-
animation: {
100-
'accordion-down': '0.2s ease-out 0s 1 normal forwards accordion-open',
101-
'accordion-up': '0.2s ease-out 0s 1 normal forwards accordion-close',
102-
},
103-
},
104-
},
105-
};
106-
```
107-
10890
## Usage
10991

11092
```tsx

apps/website/src/routes/docs/styled/button/index.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ import { cn } from '@qwik-ui/utils';
1616
import { cva, type VariantProps } from 'class-variance-authority';
1717

1818
export const buttonVariants = cva(
19-
'inline-flex items-center justify-center rounded text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
19+
'inline-flex items-center justify-center rounded text-sm font-medium transition-all duration-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
2020
{
2121
variants: {
2222
look: {
2323
primary:
24-
'border-base bg-primary text-primary-foreground shadow-sm transition-all duration-100 hover:bg-primary/90 active:shadow-base active:press',
24+
'border-base bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 active:shadow-base active:press',
2525
secondary:
26-
'border-base bg-secondary text-secondary-foreground shadow-sm transition-all duration-100 hover:bg-secondary/90 active:shadow-base active:press',
26+
'border-base bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/90 active:shadow-base active:press',
2727
alert:
28-
'border-base bg-alert text-alert-foreground shadow-sm transition-all duration-100 hover:bg-alert/90 active:shadow-base active:press',
28+
'border-base bg-alert text-alert-foreground shadow-sm hover:bg-alert/90 active:shadow-base active:press',
2929
outline:
30-
'border bg-background text-foreground shadow-sm transition-all duration-100 hover:bg-accent active:shadow-base active:press',
30+
'border bg-background text-foreground shadow-sm hover:bg-accent active:shadow-base active:press',
3131
ghost: 'text-accent-foreground hover:bg-accent',
3232
link: 'text-foreground hover:bg-transparent hover:text-foreground/80 hover:underline hover:underline-offset-2',
3333
},

apps/website/src/routes/docs/styled/checkbox/index.mdx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,29 @@ qwik-ui add checkbox
2525
```
2626

2727
```tsx
28-
import { PropsOf, component$ } from '@builder.io/qwik';
28+
import { $, PropsOf, component$ } from '@builder.io/qwik';
2929
import { cn } from '@qwik-ui/utils';
3030

31-
export const Checkbox = component$<PropsOf<'input'>>(({ name, ...props }) => {
32-
return (
33-
<input
34-
type="checkbox"
35-
{...props}
36-
class={cn(
37-
'peer peer h-4 w-4 shrink-0 border-primary text-primary accent-primary ring-offset-background focus:ring-ring focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
38-
props.class,
39-
)}
40-
name={name}
41-
id={name}
42-
/>
43-
);
44-
});
31+
export const Checkbox = component$<PropsOf<'input'>>(
32+
({ id, name, ['bind:checked']: checkedSig, checked, onInput$, ...props }) => {
33+
const inputId = id || name;
34+
return (
35+
<input
36+
type="checkbox"
37+
{...props}
38+
// workaround to support two way data-binding on the Input component (https://github.com/QwikDev/qwik/issues/3926)
39+
checked={checkedSig ? checkedSig.value : checked}
40+
onInput$={checkedSig ? $((_, el) => (checkedSig.value = el.checked)) : onInput$}
41+
data-checked={checked || checkedSig?.value || ''}
42+
class={cn(
43+
'peer h-4 w-4 shrink-0 border-primary text-primary accent-primary ring-offset-background focus:ring-ring focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
44+
props.class,
45+
)}
46+
id={inputId}
47+
/>
48+
);
49+
},
50+
);
4551
```
4652

4753
## Examples

apps/website/src/routes/docs/styled/input/index.mdx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,34 @@ qwik-ui add input
2121
```
2222

2323
```tsx
24-
import { component$, type PropsOf } from '@builder.io/qwik';
24+
import { $, component$, type PropsOf } from '@builder.io/qwik';
2525
import { cn } from '@qwik-ui/utils';
2626

2727
type InputProps = PropsOf<'input'> & {
2828
error?: string;
2929
};
3030

3131
export const Input = component$<InputProps>(
32-
({
33-
name,
34-
error,
35-
'bind:value': valueSig,
36-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
37-
'bind:checked': checkedSig,
38-
...props
39-
}) => {
32+
({ name, error, id, ['bind:value']: valueSig, value, onInput$, ...props }) => {
33+
const inputId = id || name;
34+
4035
return (
4136
<>
4237
<input
4338
{...props}
44-
aria-errormessage={`${name}-error`}
45-
aria-invalid={!!error}
46-
bind:value={valueSig}
39+
aria-errormessage={`${inputId}-error`}
40+
aria-invaid={!!error}
41+
// workaround to support two way data-binding on the Input component (https://github.com/QwikDev/qwik/issues/3926)
42+
value={valueSig ? valueSig.value : value}
43+
onInput$={valueSig ? $((__, el) => (valueSig.value = el.value)) : onInput$}
4744
class={cn(
4845
'flex h-12 w-full rounded-base border border-input bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
4946
props.class,
5047
)}
51-
id={name}
48+
id={inputId}
5249
/>
5350
{error && (
54-
<div id={`${name}-error`} class="text-destructive mt-1 text-sm">
51+
<div id={`${inputId}-error`} class="text-destructive mt-1 text-sm">
5552
{error}
5653
</div>
5754
)}

apps/website/src/routes/docs/styled/popover/index.mdx

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ qwik-ui add popover
2121
```
2222

2323
```tsx
24-
import { PropsOf, Slot, component$, useStyles$ } from '@builder.io/qwik';
24+
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
2525
import { Popover as HeadlessPopover } from '@qwik-ui/headless';
2626
import { cn } from '@qwik-ui/utils';
2727

@@ -36,26 +36,13 @@ const Root = component$<PropsOf<typeof HeadlessPopover.Root>>(({ ...props }) =>
3636
const Trigger = HeadlessPopover.Trigger;
3737

3838
const Panel = component$<PropsOf<typeof HeadlessPopover.Panel>>(({ ...props }) => {
39-
useStyles$(`
40-
.my-transition {
41-
transition: opacity 150ms, display 150ms, overlay 150ms;
42-
transition-behavior: allow-discrete;
43-
}
44-
45-
.popover-showing {
46-
opacity: 1;
47-
}
48-
49-
.popover-closing {
50-
opacity: 0;
51-
}
52-
`);
53-
5439
return (
5540
<HeadlessPopover.Panel
5641
{...props}
5742
class={cn(
58-
'my-transition w-72 rounded-md border bg-popover p-4 text-popover-foreground opacity-0 shadow-md outline-none',
43+
'my-transition w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none',
44+
'data-[open]:animate-in data-[closing]:animate-out data-[closing]:fade-out data-[open]:fade-in data-[closing]:zoom-out-95 data-[open]:zoom-in-95',
45+
'data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
5946
props.class,
6047
)}
6148
>

apps/website/src/routes/docs/styled/textarea/index.mdx

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,34 @@ qwik-ui add textarea
2121
```
2222

2323
```tsx
24-
import { component$, PropsOf } from '@builder.io/qwik';
24+
import { $, component$, PropsOf } from '@builder.io/qwik';
2525
import { cn } from '@qwik-ui/utils';
2626

2727
type TextareaProps = PropsOf<'textarea'> & {
2828
error?: string;
2929
};
3030

31-
export const Textarea = component$<TextareaProps>(({ name, error, ...props }) => {
32-
return (
33-
<>
34-
<textarea
35-
{...props}
36-
class={cn(
37-
'flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
38-
props.class,
39-
)}
40-
/>
41-
{error && <div id={`${name}-error`}>{error}</div>}
42-
</>
43-
);
44-
});
31+
export const Textarea = component$<TextareaProps>(
32+
({ id, name, error, ['bind:value']: valueSig, value, onInput$, ...props }) => {
33+
const textareaId = id || name;
34+
return (
35+
<>
36+
<textarea
37+
{...props}
38+
// workaround to support two way data-binding on the Input component (https://github.com/QwikDev/qwik/issues/3926)
39+
value={valueSig ? valueSig.value : value}
40+
onInput$={valueSig ? $((__, el) => (valueSig.value = el.value)) : onInput$}
41+
class={cn(
42+
'[&::-webkit-scrollbar-track]:bg-blue flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
43+
props.class,
44+
)}
45+
id={textareaId}
46+
/>
47+
{error && <div id={`${textareaId}-error`}>{error}</div>}
48+
</>
49+
);
50+
},
51+
);
4552
```
4653

4754
## Usage

packages/kit-styled/src/components/accordion/accordion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { cn } from '@qwik-ui/utils';
66
import { LuChevronDown } from '@qwikest/icons/lucide';
77

88
const Root = (props: PropsOf<typeof HeadlessAccordion.Root>) => (
9-
<HeadlessAccordion.Root {...props} accordionItemComponent={Item} animated>
9+
<HeadlessAccordion.Root {...props} accordionItemComponent={Item}>
1010
{props.children}
1111
</HeadlessAccordion.Root>
1212
);

packages/kit-styled/src/components/checkbox/checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ export const Checkbox = component$<PropsOf<'input'>>(
66
const inputId = id || name;
77
return (
88
<input
9+
type="checkbox"
10+
{...props}
911
// workaround to support two way data-binding on the Input component (https://github.com/QwikDev/qwik/issues/3926)
1012
checked={checkedSig ? checkedSig.value : checked}
1113
onInput$={checkedSig ? $((_, el) => (checkedSig.value = el.checked)) : onInput$}
1214
data-checked={checked || checkedSig?.value || ''}
13-
type="checkbox"
14-
{...props}
1515
class={cn(
1616
'peer h-4 w-4 shrink-0 border-primary text-primary accent-primary ring-offset-background focus:ring-ring focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
1717
props.class,

0 commit comments

Comments
 (0)