Skip to content

Commit c9eb3c9

Browse files
committed
refactor(styled radio-group): to dot notation
1 parent 4205136 commit c9eb3c9

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { component$ } from '@builder.io/qwik';
2-
import { Label, RadioGroup, RadioGroupItem } from '@qwik-ui/styled';
2+
import { Label, RadioGroup } from '~/components/ui';
33

44
export default component$(() => {
55
return (
6-
<RadioGroup>
6+
<RadioGroup.Root>
77
<div class="flex items-center space-x-2">
8-
<RadioGroupItem name="size" value="default" id="r1" />
8+
<RadioGroup.Item name="size" value="default" id="r1" />
99
<Label for="r1">Default</Label>
1010
</div>
1111
<div class="flex items-center space-x-2">
12-
<RadioGroupItem name="size" value="comfortable" id="r2" />
12+
<RadioGroup.Item name="size" value="comfortable" id="r2" />
1313
<Label for="r2">Comfortable</Label>
1414
</div>
1515
<div class="flex items-center space-x-2">
16-
<RadioGroupItem name="size" value="compact" id="r3" />
16+
<RadioGroup.Item name="size" value="compact" id="r3" />
1717
<Label for="r3">Compact</Label>
1818
</div>
19-
</RadioGroup>
19+
</RadioGroup.Root>
2020
);
2121
});

apps/website/src/routes/docs/styled/radio-group/index.mdx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,47 +28,52 @@ qwik-ui add radio-group
2828
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
2929
import { cn } from '@qwik-ui/utils';
3030

31-
export const RadioGroup = component$<PropsOf<'div'>>(({ ...props }) => {
31+
const Root = component$<PropsOf<'div'>>(({ ...props }) => {
3232
return (
3333
<div class={cn('grid gap-2', props.class)} {...props}>
3434
<Slot />
3535
</div>
3636
);
3737
});
3838

39-
export const RadioGroupItem = component$<PropsOf<'input'>>(({ ...props }) => {
39+
const Item = component$<PropsOf<'input'>>(({ ...props }) => {
4040
return (
4141
<input
4242
type="radio"
4343
{...props}
4444
class={cn(
45-
'accent-primary h-4 w-4 disabled:cursor-not-allowed disabled:opacity-50',
45+
'h-4 w-4 accent-primary disabled:cursor-not-allowed disabled:opacity-50',
4646
props.class,
4747
)}
4848
/>
4949
);
5050
});
51+
52+
export const RadioGroup = {
53+
Root,
54+
Item,
55+
};
5156
```
5257

5358
## Usage
5459

5560
```tsx
56-
import { Label, RadioGroup, RadioGroupItem } from '@qwik-ui/styled';
61+
import { Label, RadioGroup } from '~/components/ui';
5762
```
5863

5964
```tsx
60-
<RadioGroup>
65+
<RadioGroup.Root>
6166
<div class="flex items-center space-x-2">
62-
<RadioGroupItem name="size" value="default" id="r1" />
67+
<RadioGroup.Item name="size" value="default" id="r1" />
6368
<Label for="r1">Default</Label>
6469
</div>
6570
<div class="flex items-center space-x-2">
66-
<RadioGroupItem name="size" value="comfortable" id="r2" />
71+
<RadioGroup.Item name="size" value="comfortable" id="r2" />
6772
<Label for="r2">Comfortable</Label>
6873
</div>
6974
<div class="flex items-center space-x-2">
70-
<RadioGroupItem name="size" value="compact" id="r3" />
75+
<RadioGroup.Item name="size" value="compact" id="r3" />
7176
<Label for="r3">Compact</Label>
7277
</div>
73-
</RadioGroup>
78+
</RadioGroup.Root>
7479
```

packages/kit-styled/src/components/radio-group/radio-group.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
22
import { cn } from '@qwik-ui/utils';
33

4-
export const RadioGroup = component$<PropsOf<'div'>>(({ ...props }) => {
4+
const Root = component$<PropsOf<'div'>>(({ ...props }) => {
55
return (
66
<div class={cn('grid gap-2', props.class)} {...props}>
77
<Slot />
88
</div>
99
);
1010
});
1111

12-
export const RadioGroupItem = component$<PropsOf<'input'>>(({ ...props }) => {
12+
const Item = component$<PropsOf<'input'>>(({ ...props }) => {
1313
return (
1414
<input
1515
type="radio"
@@ -21,3 +21,8 @@ export const RadioGroupItem = component$<PropsOf<'input'>>(({ ...props }) => {
2121
/>
2222
);
2323
});
24+
25+
export const RadioGroup = {
26+
Root,
27+
Item,
28+
};

0 commit comments

Comments
 (0)