Skip to content

Commit

Permalink
Export radio indicator (#768)
Browse files Browse the repository at this point in the history
* Export indicator

* Add changeset

* Export component in index.ts

* Remove propWithBox
  • Loading branch information
Droniu authored Mar 15, 2024
1 parent 3bced6d commit 512c39b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-owls-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/macaw-ui": patch
---

Export radio group indicator
32 changes: 32 additions & 0 deletions src/components/RadioGroup/Indicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as RadioGroup from "@radix-ui/react-radio-group";
import { forwardRef } from "react";
import { indicator } from "./Item.css";

export interface RadioGroupIndicatorProps {
disabled?: boolean;
asChild?: boolean;
}

export const RadioGroupIndicator = forwardRef<
HTMLDivElement,
RadioGroupIndicatorProps
>(({ disabled, asChild }, ref) => {
return (
<RadioGroup.Indicator
className={indicator({ disabled })}
asChild={asChild}
ref={ref}
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="6"
height="6"
fill="currentColor"
>
<circle cx="3" cy="3" r="3" fill="currentColor" />
</svg>
</RadioGroup.Indicator>
);
});

RadioGroupIndicator.displayName = "RadioGroupIndicator";
14 changes: 3 additions & 11 deletions src/components/RadioGroup/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { forwardRef, ReactNode } from "react";

import { Box, PropsWithBox } from "../Box";
import { DataAttributes } from "../types";
import { indicator, item } from "./Item.css";
import { RadioGroupIndicator } from "./Indicator";
import { item } from "./Item.css";

export type RadioGroupItemProps = PropsWithBox<
{
Expand Down Expand Up @@ -34,16 +35,7 @@ export const RadioGroupItem = forwardRef<HTMLDivElement, RadioGroupItemProps>(
id={id}
disabled={disabled}
>
<RadioGroup.Indicator className={indicator({ disabled })} asChild>
<svg
xmlns="http://www.w3.org/2000/svg"
width="6"
height="6"
fill="currentColor"
>
<circle cx="3" cy="3" r="3" fill="currentColor" />
</svg>
</RadioGroup.Indicator>
<RadioGroupIndicator disabled={disabled} asChild />
</RadioGroup.Item>
<Box
as="label"
Expand Down
4 changes: 3 additions & 1 deletion src/components/RadioGroup/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { RadioGroupRoot } from "./Group";
import { RadioGroupItem as Item } from "./Item";
import { RadioGroupIndicator as Indicator } from "./Indicator";

export type { RadioGroupRootProps } from "./Group";
export type { RadioGroupItemProps } from "./Item";
export type { RadioGroupIndicatorProps } from "./Indicator";

export const RadioGroup = Object.assign(RadioGroupRoot, { Item });
export const RadioGroup = Object.assign(RadioGroupRoot, { Item, Indicator });

0 comments on commit 512c39b

Please sign in to comment.