Skip to content

Implementacion de cardComponent #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions js/react/lib/components/card/card.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PropsWithChildren } from "react";
import { withAs } from "@/utils/hoc";
import { cn } from "@/utils/tw-merge";

export type CardProps = PropsWithChildren & {
clickable?: boolean;
disabled?: boolean;
className?: string;
};

export const Card = withAs((Component, props: CardProps) => {
const { clickable = false, disabled = false, className, ...attr } = props;

return (
<Component
className={cn(
"rustlanges-card",
clickable && "rustlanges-card--clickable",
disabled && "disabled rustlanges-card--disabled",
className
)}
{...attr}
/>
);
}, "div");
1 change: 1 addition & 0 deletions js/react/lib/components/card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./card.component";
1 change: 1 addition & 0 deletions js/react/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./components/Example";
export * from "./components/button";
export * from "./components/card";
export * from "./components/contact-form";
export * from "./components/chip";
export * from "./components/tag";
Expand Down
22 changes: 22 additions & 0 deletions js/react/showcase/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Radio,
Badge,
DropdownState,
Card,
Calendar,
CalendarRangeDate,
DropdownTree,
Expand Down Expand Up @@ -369,6 +370,27 @@ export function App() {
},
}}
/>
<ShowComponent
title="Card"
propsDef={{
clickable: {
type: "boolean",
default: false,
},
disabled: {
type: "boolean",
default: false,
},
className: {
type: "string",
default: "min-w-50 min-h-50",
},
onClick: {
type: "callback",
},
}}
component={Card}
/>
<ShowComponent title="Scroll bar ">
<div className="scrollbar mx-auto h-48 w-full overflow-auto">
<div className="mx-auto flex h-96 w-20 items-center">Container</div>
Expand Down
1 change: 1 addition & 0 deletions styles/components.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "./components/avatar.css";
@import "./components/badge.css";
@import "./components/button.css";
@import "./components/card.css";
@import "./components/chip.css";
@import "./components/collaborators.css";
@import "./components/dropdown.css";
Expand Down
23 changes: 23 additions & 0 deletions styles/components/card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@layer components {
.rustlanges-card {
@apply bg-light border-1 shadow-brutal rounded-lg border-black p-4;
@apply dark:bg-neutral-900;
}

.rustlanges-card--clickable {
@apply cursor-pointer;

@variant hover {
@apply shadow-rb-violet-700 border-violet-700;
@apply dark:border-primary-600 dark:shadow-rb-primary-600;
}

@apply active:shadow-none;
}

.rustlanges-card--disabled {
@apply pointer-events-none shadow-none;
@apply border-neutral-200;
@apply dark:border-neutral-600;
}
}