Skip to content

Commit 291eb80

Browse files
feat: add box component (#45)
1 parent 8608cf6 commit 291eb80

File tree

6 files changed

+66
-1
lines changed

6 files changed

+66
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zenml-io/react-component-library": minor
3+
---
4+
5+
add box component

src/components/Box/Box.stories.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Meta } from "@storybook/react";
2+
import { Box } from "./index";
3+
import { StoryObj } from "@storybook/react";
4+
import React from "react";
5+
6+
const meta = {
7+
title: "Elements/Box",
8+
component: Box,
9+
10+
parameters: {
11+
layout: "centered"
12+
},
13+
decorators: [
14+
(Story) => (
15+
<div className="w-[400px] h-[200px]">
16+
<Story />
17+
</div>
18+
)
19+
],
20+
tags: ["autodocs"]
21+
} satisfies Meta<typeof Box>;
22+
23+
export default meta;
24+
25+
type Story = StoryObj<typeof meta>;
26+
27+
export const DefaultVariant: Story = {
28+
name: "Default",
29+
args: {
30+
className: "h-full"
31+
}
32+
};

src/components/Box/Box.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { cva, VariantProps } from "class-variance-authority";
2+
import React, { HTMLAttributes } from "react";
3+
import { cn } from "../../utilities";
4+
5+
export const boxVariants = cva("border rounded-md", {
6+
variants: {
7+
variant: {
8+
default: "border-theme-border-moderate bg-theme-surface-primary"
9+
}
10+
},
11+
defaultVariants: {
12+
variant: "default"
13+
}
14+
});
15+
16+
export interface BoxProps
17+
extends HTMLAttributes<HTMLDivElement>,
18+
VariantProps<typeof boxVariants> {}
19+
20+
export function Box({ children, className, variant, ...rest }: BoxProps) {
21+
return (
22+
<div {...rest} className={cn(boxVariants({ variant }), className)}>
23+
{children}
24+
</div>
25+
);
26+
}

src/components/Box/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./Box";

src/components/Input/Input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { cva, VariantProps } from "class-variance-authority";
22
import React, { forwardRef, InputHTMLAttributes } from "react";
33
import { cn } from "../../utilities";
44

5-
const inputVariants = cva(
5+
export const inputVariants = cva(
66
cn([
77
"transition-all duration-200 rounded-md bg-theme-surface-primary",
88
"border-[#D0D5DD] border",

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from "./Button";
22
export * from "./Input";
33
export * from "./Sidebar";
4+
export * from "./Box";

0 commit comments

Comments
 (0)