Skip to content

Commit

Permalink
Aric sparkle for ffrag (#2086)
Browse files Browse the repository at this point in the history
* Add background colors to Avatar and Citation

* Bumping Sparkle to version 0.2.6
  • Loading branch information
lasryaric authored Oct 12, 2023
1 parent 7695226 commit 4f3e74a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 7 additions & 1 deletion sparkle/src/components/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type AvatarProps = {
onClick?: () => void;
busy?: boolean;
isRounded?: boolean;
backgroundColor?: string;
};

const colors = [
Expand Down Expand Up @@ -86,6 +87,7 @@ export function Avatar({
clickable = false,
busy = false,
isRounded = false,
backgroundColor,
}: AvatarProps) {
const getColor = (name: string) => {
if (/\+/.test(name)) {
Expand Down Expand Up @@ -120,7 +122,11 @@ export function Avatar({
const avatarClass = classNames(
sizeClasses[size],
isRounded ? "s-rounded-full" : roundedClasses[size],
name ? getColor(name) : "s-bg-slate-200",
backgroundColor
? backgroundColor
: name
? getColor(name)
: "s-bg-slate-200",
"s-flex s-flex-shrink-0 s-items-center s-justify-center s-overflow-hidden",
clickableStyles,
busyStyles
Expand Down
12 changes: 7 additions & 5 deletions sparkle/src/components/Citation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface CitationProps {
description?: string;
index?: ReactNode;
isBlinking?: boolean;
href: string;
href?: string;
}

const typeIcons = {
Expand All @@ -34,7 +34,7 @@ export function Citation({
return (
<div
className={classNames(
"w-48 s-flex s-flex-none s-flex-col s-gap-1 s-rounded-xl s-border s-border-structure-100 s-p-3 s-shadow-sm sm:s-w-64",
"w-48 s-flex s-flex-none s-flex-col s-gap-1 s-rounded-xl s-border s-border-structure-100 s-bg-white s-p-3 s-shadow-sm sm:s-w-64",
isBlinking ? "animate-[bgblink_500ms_3]" : ""
)}
>
Expand All @@ -46,9 +46,11 @@ export function Citation({
)}
<Icon visual={typeIcons[type]} size="sm" />
<div className="s-flex-grow s-text-xs" />
<a target="_blank" rel="noopener noreferrer" href={href}>
<IconButton icon={ExternalLinkIcon} size="sm" variant="primary" />
</a>
{href && (
<a target="_blank" rel="noopener noreferrer" href={href}>
<IconButton icon={ExternalLinkIcon} size="sm" variant="primary" />
</a>
)}
</div>
<div className="s-text-sm s-font-bold s-text-element-900">{title}</div>
{description && (
Expand Down

0 comments on commit 4f3e74a

Please sign in to comment.