Skip to content

Commit

Permalink
Updating
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncid committed Dec 16, 2024
1 parent ef1940d commit ad44607
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 26 deletions.
44 changes: 31 additions & 13 deletions sparkle/src/components/Citation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { ReactNode } from "react";

import {
Button, Card, CardProps,
Button,
Card,
CardProps,
Spinner,
Tooltip,
} from "@sparkle/components/";
Expand All @@ -16,7 +18,14 @@ type CitationProps = CardProps & {

const Citation = React.forwardRef<HTMLDivElement, CitationProps>(
(
{ children, variant = "primary", isLoading, className, tooltip, ...props },
{
children,
variant = "secondary",
isLoading,
className,
tooltip,
...props
},
ref
) => {
const cardButton = (
Expand All @@ -25,7 +34,7 @@ const Citation = React.forwardRef<HTMLDivElement, CitationProps>(
variant={variant}
size="sm"
className={cn(
"s-relative s-flex s-aspect-[2/1] s-min-w-[140px] s-flex-none s-flex-col s-justify-end",
"s-relative s-flex s-aspect-[2/1] s-min-w-[140px] s-flex-none s-flex-col s-justify-end s-overflow-hidden",
className
)}
{...props}
Expand Down Expand Up @@ -71,7 +80,7 @@ const CitationGrid = React.forwardRef<
>(({ children, className, ...props }, ref) => {
return (
<div ref={ref} className={cn("s-@container", className)} {...props}>
<div className="s-grid s-grid-cols-1 s-gap-2 @sm:s-grid-cols-2 @2xl:s-grid-cols-4 @3xl:s-grid-cols-5 @xl:s-grid-cols-3">
<div className="s-grid s-grid-cols-1 s-gap-2 @xxs:s-grid-cols-2 @xs:s-grid-cols-3 @sm:s-grid-cols-4 @md:s-grid-cols-5 @lg:s-grid-cols-6">
{children}
</div>
</div>
Expand All @@ -91,12 +100,8 @@ const CitationClose = React.forwardRef<HTMLButtonElement, CitationCloseProps>(
<Button
ref={ref}
variant="ghost"
size="xs"
className={cn(
"s-z-10",
"s-absolute s-right-2 s-top-2 s-z-10",
className
)}
size="mini"
className={className}
icon={XMarkIcon}
onClick={(e) => {
e.stopPropagation();
Expand All @@ -122,14 +127,27 @@ const CitationImage = React.forwardRef<HTMLDivElement, CitationImageProps>(
className={cn(
"s-absolute s-inset-0",
"s-bg-cover s-bg-center",
"s-rounded-xl",
"s-overflow-hidden",
"[mask-image:radial-gradient(white,black)]",
className
)}
style={{
backgroundImage: `url(${imgSrc})`,
}}
{...props}
>
<div className="s-z-0 s-h-full s-w-full s-bg-primary-100/80 s-transition s-duration-200 group-hover:s-bg-primary-200/70 group-active:s-bg-primary-100/60" />
<div
className={cn(
"s-absolute s-inset-0",
"s-z-0 s-h-full s-w-full",
"s-bg-primary-100/80",
"s-backdrop-blur-sm",
"s-transition s-duration-200",
"group-hover:s-bg-primary-200/70 group-hover:s-backdrop-blur-none",
"group-active:s-bg-primary-100/60"
)}
/>
</div>
);
}
Expand Down Expand Up @@ -165,7 +183,7 @@ const CitationLoading = React.forwardRef<
<div
ref={ref}
className={cn(
"s-absolute s-inset-0 s-z-20 s-flex s-h-full s-w-full s-items-center s-justify-center s-bg-primary-100/80",
"s-absolute s-inset-0 s-z-20 s-flex s-h-full s-w-full s-items-center s-justify-center s-rounded-xl s-bg-primary-100/80 s-backdrop-blur-sm",
className
)}
{...props}
Expand Down Expand Up @@ -235,4 +253,4 @@ export {
CitationImage,
CitationIndex,
CitationTitle,
};
};
3 changes: 2 additions & 1 deletion sparkle/src/stories/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
PlanetIcon,
ScanIcon,
TableIcon,
XMarkIcon,
} from "@sparkle/icons";

const meta = {
Expand Down Expand Up @@ -129,7 +130,7 @@ export const ActionCardDemo: React.FC = () => (
onClick={() => {
alert(`You clicked on ${card.title}`);
}}
action={<CardActionButton size="mini" icon={CommandLineIcon} />}
action={<CardActionButton size="mini" icon={XMarkIcon} />}
>
<div className="s-flex s-w-full s-flex-col s-gap-1 s-text-sm">
<div className="s-flex s-w-full s-gap-1 s-font-medium s-text-foreground">
Expand Down
36 changes: 24 additions & 12 deletions sparkle/src/stories/Citation.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default meta;
export const CitationsExample = () => (
<div className="s-flex s-flex-col s-gap-8">
Example of attachement
<div className="s-flex s-gap-2">
<CitationGrid>
<Citation onClick={() => alert("Card clicked")} className="s-w-48">
<CitationIcons>
<Icon visual={SlackLogo} size="sm" />
Expand Down Expand Up @@ -69,43 +69,55 @@ export const CitationsExample = () => (
</CitationIcons>
<CitationTitle>screenshot.png</CitationTitle>
</Citation>
</div>
</CitationGrid>
Example of dissmissable attachements
<div className="s-flex s-gap-8">
<Citation onClick={() => alert("Card clicked")} className="s-w-48">
<CitationGrid>
<Citation
onClick={() => alert("Card clicked")}
className="s-w-48"
action={<CitationClose onClick={() => alert("Close clicked")} />}
>
<CitationIcons>
<Icon visual={SlackLogo} size="sm" />
</CitationIcons>
<CitationTitle>Slack thread</CitationTitle>
<CitationClose onClick={() => alert("Close clicked")} />
<CitationDescription>
@ed at 16:32 This is the latest ve
</CitationDescription>
</Citation>
<Citation onClick={() => alert("Card clicked")} className="s-w-48">
<Citation
onClick={() => alert("Card clicked")}
className="s-w-48"
action={<CitationClose onClick={() => alert("Close clicked")} />}
>
<CitationIcons>
<Icon visual={TableIcon} size="sm" />
</CitationIcons>
<CitationClose onClick={() => alert("Close clicked")} />
<CitationTitle>extract_financa.csv</CitationTitle>
</Citation>
<Citation onClick={() => alert("Card clicked")} className="s-w-48">
<Citation
onClick={() => alert("Card clicked")}
className="s-w-48"
action={<CitationClose onClick={() => alert("Close clicked")} />}
>
<CitationIcons>
<Icon visual={GlobeAltIcon} size="sm" />
</CitationIcons>
<CitationClose onClick={() => alert("Close clicked")} />
<CitationTitle>Linkedin, Edouard Wautier</CitationTitle>
</Citation>

<Citation onClick={() => alert("Card clicked")} className="s-w-48">
<Citation
onClick={() => alert("Card clicked")}
className="s-w-48"
action={<CitationClose onClick={() => alert("Close clicked")} />}
>
<CitationImage imgSrc="https://dust.tt/static/droidavatar/Droid_Lime_3.jpg" />
<CitationIcons>
<Icon visual={ImageIcon} size="sm" />
</CitationIcons>
<CitationClose onClick={() => alert("Close clicked")} />
<CitationTitle>screenshot.png</CitationTitle>
</Citation>
</div>
</CitationGrid>
Example of citations in markdown
<div>
<Popover
Expand Down

0 comments on commit ad44607

Please sign in to comment.