mirror of
https://github.com/block/buzz.git
synced 2026-11-27 11:41:21 +00:00
desktop: improve projects header and avatar contrast
Bring project navigation closer to its page heading and give fallback avatars distinct, readable colors on light backgrounds. Signed-off-by: Thomas Petersen <thomasp@squareup.com>
This commit is contained in:
@@ -761,7 +761,7 @@ export function ProjectsView() {
|
||||
|
||||
const projectsHeader = (
|
||||
<PageHeader
|
||||
className="pointer-events-auto mb-8"
|
||||
className="pointer-events-auto mb-4"
|
||||
description="Set up and manage your projects."
|
||||
title="Projects"
|
||||
/>
|
||||
|
||||
@@ -14,6 +14,24 @@ const sizeClasses: Record<UserAvatarSize, string> = {
|
||||
md: "h-9 w-9 text-xs",
|
||||
};
|
||||
|
||||
const fallbackColorClasses = [
|
||||
"bg-blue-500 text-white",
|
||||
"bg-emerald-500 text-white",
|
||||
"bg-amber-400 text-amber-950",
|
||||
"bg-rose-500 text-white",
|
||||
"bg-cyan-400 text-cyan-950",
|
||||
"bg-violet-500 text-white",
|
||||
"bg-orange-500 text-white",
|
||||
] as const;
|
||||
|
||||
function fallbackColorClass(displayName: string) {
|
||||
const hash = Array.from(displayName.trim().toLowerCase()).reduce(
|
||||
(value, character) => (value * 31 + (character.codePointAt(0) ?? 0)) >>> 0,
|
||||
0,
|
||||
);
|
||||
return fallbackColorClasses[hash % fallbackColorClasses.length];
|
||||
}
|
||||
|
||||
type UserAvatarProps = {
|
||||
avatarUrl: string | null;
|
||||
displayName: string;
|
||||
@@ -66,7 +84,7 @@ export function UserAvatar({
|
||||
"font-semibold",
|
||||
accent
|
||||
? "bg-primary text-primary-foreground"
|
||||
: "bg-secondary text-secondary-foreground",
|
||||
: fallbackColorClass(displayName),
|
||||
)}
|
||||
data-testid={testId ? `${testId}-fallback` : undefined}
|
||||
delayMs={fallbackDelayMs}
|
||||
|
||||
Reference in New Issue
Block a user