diff --git a/sparkle/src/components/AssistantCard.tsx b/sparkle/src/components/AssistantCard.tsx
index aca107a178d15..bb204f61a08cb 100644
--- a/sparkle/src/components/AssistantCard.tsx
+++ b/sparkle/src/components/AssistantCard.tsx
@@ -1,6 +1,11 @@
import React from "react";
-import { Avatar, Button, ButtonProps, Card } from "@sparkle/components/";
+import {
+ Avatar,
+ ButtonProps,
+ Card,
+ CardActionButton,
+} from "@sparkle/components/";
import { MoreIcon } from "@sparkle/icons/";
import { cn } from "@sparkle/lib/utils";
@@ -13,76 +18,13 @@ interface BaseAssistantCardProps {
onClick?: () => void;
}
-interface MetaAssistantCardProps {
- className?: string;
- variant: "sm" | "lg";
- onClick?: () => void;
- children: React.ReactNode;
- action?: React.ReactNode;
-}
-
-const MetaAssistantCard = React.forwardRef<
- HTMLDivElement,
- MetaAssistantCardProps
->(({ className, variant, action, onClick, children }, ref) => {
- return (
-
-
- {children}
-
- {action &&
{action}}
-
- );
-});
-MetaAssistantCard.displayName = "MetaAssistantCard";
-
-const AssistantCardAction = React.forwardRef<
- HTMLDivElement,
- React.ComponentPropsWithoutRef<"div"> & {
- children: React.ReactNode;
- }
->(({ children, ...props }, ref) => {
- return (
-
- {children}
-
- );
-});
-
-AssistantCardAction.displayName = "AssistantCardAction";
-
type AssistantCardMore = ButtonProps;
export const AssistantCardMore = React.forwardRef<
HTMLButtonElement,
- AssistantCardMore & {
- className?: string;
- }
->(({ className }, ref) => {
- return (
-
- );
+ AssistantCardMore
+>(({ ...props }, ref) => {
+ return ;
});
AssistantCardMore.displayName = "AssistantCardMore";
@@ -99,10 +41,10 @@ export const AssistantCard = React.forwardRef<
ref
) => {
return (
-
@@ -124,7 +66,7 @@ export const AssistantCard = React.forwardRef<
{description}
)}
-
+
);
}
);
@@ -137,12 +79,7 @@ export const LargeAssistantCard = React.forwardRef<
LargeAssistantCardProps
>(({ className, onClick, title, description, pictureUrl }, ref) => {
return (
-
+
@@ -150,7 +87,7 @@ export const LargeAssistantCard = React.forwardRef<
{description}
-
+
);
});
LargeAssistantCard.displayName = "LargeAssistantCard";
diff --git a/sparkle/src/components/Button.tsx b/sparkle/src/components/Button.tsx
index 03bfe73e30243..1932c93cdc7de 100644
--- a/sparkle/src/components/Button.tsx
+++ b/sparkle/src/components/Button.tsx
@@ -112,7 +112,7 @@ type CommonButtonProps = Omit &
tooltip?: string;
};
-type MiniButtonProps = CommonButtonProps & {
+export type MiniButtonProps = CommonButtonProps & {
size: "mini";
icon: React.ComponentType;
label?: never;
diff --git a/sparkle/src/components/Card.tsx b/sparkle/src/components/Card.tsx
index 017fcd8909a1a..b556adabd10e9 100644
--- a/sparkle/src/components/Card.tsx
+++ b/sparkle/src/components/Card.tsx
@@ -1,12 +1,13 @@
import { cva } from "class-variance-authority";
import React from "react";
-import { LinkWrapperProps } from "@sparkle/components/";
+import { Button, ButtonProps, LinkWrapperProps } from "@sparkle/components/";
import {
noHrefLink,
SparkleContext,
SparkleContextLinkType,
} from "@sparkle/context";
+import { XMarkIcon } from "@sparkle/icons";
import { cn } from "@sparkle/lib/utils";
export const CARD_VARIANTS = ["primary", "secondary", "tertiary"] as const;
@@ -24,9 +25,9 @@ export const CARD_VARIANTS_SIZES = ["sm", "md", "lg"] as const;
export type CardSizeType = (typeof CARD_VARIANTS_SIZES)[number];
const sizeVariants: Record = {
- sm: "s-p-3 s-rounded-2xl",
- md: "s-p-4 s-rounded-3xl",
- lg: "s-p-5 s-rounded-4xl",
+ sm: "s-p-3 s-rounded-xl",
+ md: "s-p-4 s-rounded-2xl",
+ lg: "s-p-5 s-rounded-3xl",
};
const cardVariants = cva(
@@ -49,11 +50,11 @@ interface CommonProps {
className?: string;
}
-interface LinkProps extends CommonProps, LinkWrapperProps {
+interface CardLinkProps extends CommonProps, LinkWrapperProps {
onClick?: never;
}
-interface ButtonProps
+interface CardButtonProps
extends CommonProps,
React.ButtonHTMLAttributes {
href?: never;
@@ -63,9 +64,9 @@ interface ButtonProps
shallow?: never;
}
-export type CardProps = LinkProps | ButtonProps;
+type InnerCardProps = CardLinkProps | CardButtonProps;
-export const Card = React.forwardRef(
+const InnerCard = React.forwardRef(
(
{
children,
@@ -120,8 +121,95 @@ export const Card = React.forwardRef(
}
);
+interface CardPropsBase {
+ action?: React.ReactNode;
+ containerClassName?: string;
+ className?: string;
+ variant?: CardVariantType;
+ size?: CardSizeType;
+}
+
+interface CardPropsWithLink
+ extends CardPropsBase,
+ Omit {
+ href: string;
+ onClick?: never;
+}
+
+interface CardPropsWithButton
+ extends CardPropsBase,
+ Omit {
+ href?: never;
+}
+
+export type CardProps = CardPropsWithLink | CardPropsWithButton;
+
+export const Card = React.forwardRef(
+ ({ containerClassName, className, action, ...props }, ref) => {
+ return (
+
+
+ {action && {action}}
+
+ );
+ }
+);
Card.displayName = "Card";
+const CardActions = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentPropsWithoutRef<"div"> & {
+ children: React.ReactNode;
+ }
+>(({ children, ...props }, ref) => {
+ return (
+
+ {children}
+
+ );
+});
+
+CardActions.displayName = "CardActions";
+
+export const CardActionButton = React.forwardRef<
+ HTMLButtonElement,
+ ButtonProps
+>(
+ (
+ {
+ className,
+ size = "mini",
+ variant = "outline",
+ icon = XMarkIcon,
+ ...props
+ },
+ ref
+ ) => {
+ return (
+
+ );
+ }
+);
+
+CardActionButton.displayName = "CardActionButton";
+
export const CardGrid = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes
diff --git a/sparkle/src/components/index.ts b/sparkle/src/components/index.ts
index 96bc837973660..97ffa62db27d8 100644
--- a/sparkle/src/components/index.ts
+++ b/sparkle/src/components/index.ts
@@ -9,10 +9,14 @@ export { AssistantPreview } from "./AssistantPreview";
export { Avatar } from "./Avatar";
export { BarHeader } from "./BarHeader";
export { Breadcrumbs } from "./Breadcrumbs";
-export type { ButtonProps, RegularButtonProps } from "./Button";
+export type {
+ ButtonProps,
+ MiniButtonProps,
+ RegularButtonProps,
+} from "./Button";
export { Button } from "./Button";
export type { CardProps } from "./Card";
-export { Card, CardGrid } from "./Card";
+export { Card, CardActionButton, CardGrid } from "./Card";
export type { CheckboxProps } from "./Checkbox";
export {
Checkbox,
diff --git a/sparkle/src/stories/AssistantCard.stories.tsx b/sparkle/src/stories/AssistantCard.stories.tsx
index ffe4a2afe1769..aa0779616c3f0 100644
--- a/sparkle/src/stories/AssistantCard.stories.tsx
+++ b/sparkle/src/stories/AssistantCard.stories.tsx
@@ -35,7 +35,7 @@ const ddMenu = (
export const AssistantCardExample = () => (
List
-
+
(
-
+
{cardData.map((card, index) => (
{
alert(`You clicked on ${card.title}`);
}}
+ action={}
>
-
-
-
+
+
+
{card.title}
-
{card.description}
@@ -146,5 +142,5 @@ export const ActionCardDemo: React.FC = () => (
))}
-
+
);