-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f91343
commit ccc043b
Showing
7 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@zenml-io/react-component-library": minor | ||
--- | ||
|
||
add radio group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Meta } from "@storybook/react"; | ||
import React from "react"; | ||
import { RadioGroup, RadioGroupItem } from "./index"; | ||
import { StoryObj } from "@storybook/react"; | ||
|
||
const meta = { | ||
title: "Elements/Radio Group", | ||
component: RadioGroup, | ||
decorators: [ | ||
(Story) => ( | ||
<div className="w-[400px] flex items-center justify-center bg-theme-surface-primary h-[200px]"> | ||
<Story /> | ||
</div> | ||
) | ||
], | ||
parameters: { | ||
layout: "centered" | ||
}, | ||
|
||
tags: ["autodocs"] | ||
} satisfies Meta<typeof RadioGroup>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const DefaultVariant: Story = { | ||
name: "Default", | ||
render: () => ( | ||
<RadioGroup defaultValue="option-one"> | ||
<div className="flex items-center space-x-2"> | ||
<RadioGroupItem value="option-one" id="option-one" /> | ||
<label htmlFor="option-one">Option One</label> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<RadioGroupItem value="option-two" id="option-two" /> | ||
<label htmlFor="option-two">Option Two</label> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<RadioGroupItem disabled value="option-three" id="option-three" /> | ||
<label htmlFor="option-three">Option disabled</label> | ||
</div> | ||
</RadioGroup> | ||
) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as React from "react"; | ||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"; | ||
import { cn } from "../../utilities"; | ||
|
||
const RadioGroup = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> | ||
>(({ className, ...props }, ref) => { | ||
return <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />; | ||
}); | ||
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName; | ||
|
||
const RadioGroupItem = React.forwardRef< | ||
React.ElementRef<typeof RadioGroupPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> | ||
>(({ className, ...props }, ref) => { | ||
return ( | ||
<RadioGroupPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
"aspect-square h-3 w-3 bg-theme-surface-primary rounded-rounded border border-theme-border-bold text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:data-[state=unchecked]:opacity-30 disabled:data-[state=checked]:bg-neutral-300", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<RadioGroupPrimitive.Indicator className="flex text-theme-surface-strong items-center justify-center data-[state=checked]:data-[disabled]:text-theme-surface-primary"> | ||
<svg | ||
className="h-[10px] w-[10px] fill-current text-current" | ||
viewBox="0 0 100 100" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<circle cx="50" cy="50" r="50" /> | ||
</svg> | ||
</RadioGroupPrimitive.Indicator> | ||
</RadioGroupPrimitive.Item> | ||
); | ||
}); | ||
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName; | ||
|
||
export { RadioGroup, RadioGroupItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./RadioGroup"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters