feat: 최근 게시물 관리 작업
This commit is contained in:
@@ -2,11 +2,11 @@ import "./button-group.css";
|
||||
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
|
||||
import { RadioGroup, RadioGroupItem } from "../radio-group";
|
||||
import { ButtonGroup, ButtonGroupItem } from "../button-group";
|
||||
|
||||
const meta: Meta<typeof RadioGroup> = {
|
||||
const meta: Meta<typeof ButtonGroup> = {
|
||||
title: "Elements/ButtonGroup",
|
||||
component: RadioGroup,
|
||||
component: ButtonGroup,
|
||||
parameters: {
|
||||
docs: {
|
||||
description: {
|
||||
@@ -19,49 +19,49 @@ ButtonGroup 컴포넌트는 RadioGroup 컴포넌트를 기반으로 버튼 모
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof RadioGroup>;
|
||||
type Story = StoryObj<typeof ButtonGroup>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroup defaultValue="comfortable" variant="button">
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const Secondary: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button" color="secondary">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroup defaultValue="comfortable" variant="button" color="secondary">
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const Rounded: Story = {
|
||||
render: () => (
|
||||
<RadioGroup defaultValue="comfortable" variant="button" shape="rounded">
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroup defaultValue="comfortable" variant="button" shape="rounded">
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
export const SecondaryRounded: Story = {
|
||||
render: () => (
|
||||
<RadioGroup
|
||||
<ButtonGroup
|
||||
defaultValue="comfortable"
|
||||
variant="button"
|
||||
color="secondary"
|
||||
shape="rounded"
|
||||
>
|
||||
<RadioGroupItem value="default">Default</RadioGroupItem>
|
||||
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
|
||||
<RadioGroupItem value="compact">Compact</RadioGroupItem>
|
||||
</RadioGroup>
|
||||
<ButtonGroupItem value="default">Default</ButtonGroupItem>
|
||||
<ButtonGroupItem value="comfortable">Comfortable</ButtonGroupItem>
|
||||
<ButtonGroupItem value="compact">Compact</ButtonGroupItem>
|
||||
</ButtonGroup>
|
||||
),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import "./button-group.css";
|
||||
|
||||
import * as React from "react";
|
||||
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
||||
|
||||
const ButtonGroup = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> & {
|
||||
variant?: "radio" | "button";
|
||||
color?: "primary" | "secondary";
|
||||
shape?: "square" | "rounded";
|
||||
}
|
||||
>(
|
||||
(
|
||||
{ variant = "radio", color = "primary", shape = "square", ...props },
|
||||
ref,
|
||||
) => {
|
||||
return (
|
||||
<RadioGroupPrimitive.Root
|
||||
{...props}
|
||||
ref={ref}
|
||||
data-variant={variant}
|
||||
data-color={color}
|
||||
data-shape={shape}
|
||||
/>
|
||||
);
|
||||
},
|
||||
);
|
||||
ButtonGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
||||
|
||||
const ButtonGroupItem = React.forwardRef<
|
||||
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
||||
>(({ ...props }, ref) => {
|
||||
return <RadioGroupPrimitive.Item ref={ref} {...props} />;
|
||||
});
|
||||
ButtonGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
||||
|
||||
export { ButtonGroup, ButtonGroupItem };
|
||||
Reference in New Issue
Block a user