@brightweblabs/ui 1.4.11 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brightweblabs/ui",
3
3
  "private": false,
4
- "version": "1.4.11",
4
+ "version": "1.5.0",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "files": [
@@ -78,7 +78,7 @@
78
78
  "recharts": "^2.15.4",
79
79
  "sonner": "^2.0.7",
80
80
  "tailwind-merge": "^3.6.0",
81
- "@brightweblabs/theme": "0.8.0"
81
+ "@brightweblabs/theme": "0.8.1"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "lucide-react": "^1.8.0",
@@ -1,28 +1,61 @@
1
+ "use client";
2
+
1
3
  import * as React from "react";
4
+ import { Slot } from "@radix-ui/react-slot";
2
5
  import { cva, type VariantProps } from "class-variance-authority";
3
6
 
4
7
  import { cn } from "../lib/utils";
5
8
 
6
- const cardVariants = cva("bg-card text-card-foreground flex flex-col rounded-xl shadow-sm", {
9
+ const cardVariants = cva("card-root flex flex-col text-card-foreground", {
7
10
  variants: {
8
11
  variant: {
9
- default: "border border-border",
10
- /** Insight/blog card: borderless, overflow-hidden; hover lift handled by motion on parent */
11
- insight: "!border-0 border-transparent shadow-none overflow-hidden bg-card rounded-xl",
12
+ default: "",
13
+ light: "",
14
+ elevated: "",
15
+ interactive: "",
16
+ /** Insight/blog card: the canonical borderless media-card treatment. */
17
+ insight: "",
18
+ },
19
+ density: {
20
+ none: "",
21
+ compact: "p-3",
22
+ default: "p-5",
23
+ },
24
+ motion: {
25
+ none: "",
26
+ enter: "card-enter",
12
27
  },
13
28
  },
14
29
  defaultVariants: {
15
30
  variant: "default",
31
+ density: "none",
32
+ motion: "none",
16
33
  },
17
34
  });
18
35
 
36
+ export type CardProps = React.ComponentProps<"div"> & VariantProps<typeof cardVariants> & {
37
+ asChild?: boolean;
38
+ };
39
+
19
40
  function Card({
41
+ asChild = false,
20
42
  className,
21
43
  variant = "default",
44
+ density = "none",
45
+ motion = "none",
22
46
  ...props
23
- }: React.ComponentProps<"div"> & VariantProps<typeof cardVariants>) {
47
+ }: CardProps) {
48
+ const Component = asChild ? Slot : "div";
49
+
24
50
  return (
25
- <div data-slot="card" data-variant={variant} className={cn(cardVariants({ variant, className }))} {...props} />
51
+ <Component
52
+ data-slot="card"
53
+ data-variant={variant}
54
+ data-density={density}
55
+ data-motion={motion}
56
+ className={cn(cardVariants({ variant, density, motion, className }))}
57
+ {...props}
58
+ />
26
59
  );
27
60
  }
28
61
 
@@ -65,4 +98,4 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
65
98
  return <div data-slot="card-footer" className={cn("flex items-center [.border-t]:pt-6", className)} {...props} />;
66
99
  }
67
100
 
68
- export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
101
+ export { Card, cardVariants, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
@@ -1,11 +1,26 @@
1
1
  import type { HTMLAttributes } from "react";
2
2
 
3
3
  import { cn } from "../lib/utils";
4
+ import { Card, type CardProps } from "./card";
4
5
 
5
6
  export type SurfaceCardProps = HTMLAttributes<HTMLElement> & {
6
7
  isLight?: boolean;
8
+ variant?: CardProps["variant"];
9
+ density?: CardProps["density"];
10
+ motion?: CardProps["motion"];
7
11
  };
8
12
 
9
- export function SurfaceCard({ isLight = false, className, ...props }: SurfaceCardProps) {
10
- return <article className={cn("surface-card", isLight && "is-light", className)} {...props} />;
13
+ export function SurfaceCard({
14
+ isLight = false,
15
+ variant,
16
+ density = "default",
17
+ motion = "enter",
18
+ className,
19
+ ...props
20
+ }: SurfaceCardProps) {
21
+ return (
22
+ <Card asChild variant={variant ?? (isLight ? "light" : "default")} density={density} motion={motion}>
23
+ <article className={cn("surface-card", isLight && "is-light", className)} {...props} />
24
+ </Card>
25
+ );
11
26
  }