Skip to content

Commit 8b31b20

Browse files
feat(react): add Card component (#49)
Co-authored-by: Apika Luca <[email protected]>
1 parent 054e35f commit 8b31b20

File tree

6 files changed

+73
-0
lines changed

6 files changed

+73
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { PropsWithChildren } from "react";
2+
import { withAs } from "@/utils/hoc";
3+
import { cn } from "@/utils/tw-merge";
4+
5+
export type CardProps = PropsWithChildren & {
6+
clickable?: boolean;
7+
disabled?: boolean;
8+
className?: string;
9+
};
10+
11+
export const Card = withAs((Component, props: CardProps) => {
12+
const { clickable = false, disabled = false, className, ...attr } = props;
13+
14+
return (
15+
<Component
16+
className={cn(
17+
"rustlanges-card",
18+
clickable && "rustlanges-card--clickable",
19+
disabled && "disabled rustlanges-card--disabled",
20+
className
21+
)}
22+
{...attr}
23+
/>
24+
);
25+
}, "div");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./card.component";

js/react/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from "./components/Example";
22
export * from "./components/button";
3+
export * from "./components/card";
34
export * from "./components/contact-form";
45
export * from "./components/chip";
56
export * from "./components/tag";

js/react/showcase/App.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
Radio,
1313
Badge,
1414
DropdownState,
15+
Card,
1516
Calendar,
1617
CalendarRangeDate,
1718
DropdownTree,
@@ -390,6 +391,27 @@ export function App() {
390391
},
391392
}}
392393
/>
394+
<ShowComponent
395+
title="Card"
396+
propsDef={{
397+
clickable: {
398+
type: "boolean",
399+
default: false,
400+
},
401+
disabled: {
402+
type: "boolean",
403+
default: false,
404+
},
405+
className: {
406+
type: "string",
407+
default: "min-w-50 min-h-50",
408+
},
409+
onClick: {
410+
type: "callback",
411+
},
412+
}}
413+
component={Card}
414+
/>
393415
<ShowComponent title="Scroll bar ">
394416
<div className="scrollbar mx-auto h-48 w-full overflow-auto">
395417
<div className="mx-auto flex h-96 w-20 items-center">Container</div>

styles/components.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "./components/avatar.css";
22
@import "./components/badge.css";
33
@import "./components/button.css";
4+
@import "./components/card.css";
45
@import "./components/chip.css";
56
@import "./components/collaborators.css";
67
@import "./components/dropdown.css";

styles/components/card.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@layer components {
2+
.rustlanges-card {
3+
@apply bg-light border-1 shadow-brutal rounded-lg border-black p-4;
4+
@apply dark:bg-neutral-900;
5+
}
6+
7+
.rustlanges-card--clickable {
8+
@apply cursor-pointer;
9+
10+
@variant hover {
11+
@apply shadow-rb-violet-700 border-violet-700;
12+
@apply dark:border-primary-600 dark:shadow-rb-primary-600;
13+
}
14+
15+
@apply active:shadow-none;
16+
}
17+
18+
.rustlanges-card--disabled {
19+
@apply pointer-events-none shadow-none;
20+
@apply border-neutral-200;
21+
@apply dark:border-neutral-600;
22+
}
23+
}

0 commit comments

Comments
 (0)