Skip to content

Commit aeb4a58

Browse files
committed
Pass the org title into the Avatar
1 parent bf2fead commit aeb4a58

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function ProjectSelector({
304304
)}
305305
>
306306
<span className="flex items-center gap-1.5 overflow-hidden">
307-
<Avatar avatar={organization.avatar} size={1.25} />
307+
<Avatar avatar={organization.avatar} size={1.25} orgName={organization.title} />
308308
<SelectorDivider />
309309
<span className="truncate text-2sm font-normal text-text-bright">
310310
{project.name ?? "Select a project"}
@@ -319,7 +319,7 @@ function ProjectSelector({
319319
<div className="flex flex-col gap-2 bg-charcoal-750 p-2">
320320
<div className="flex items-center gap-2.5">
321321
<div className="box-content size-10 overflow-clip rounded-sm bg-charcoal-800">
322-
<Avatar avatar={organization.avatar} size={2.5} includePadding />
322+
<Avatar avatar={organization.avatar} size={2.5} orgName={organization.title} />
323323
</div>
324324
<div className="space-y-0.5">
325325
<Paragraph variant="small/bright">{organization.title}</Paragraph>
@@ -483,7 +483,7 @@ function SwitchOrganizations({
483483
key={org.id}
484484
to={organizationPath(org)}
485485
title={org.title}
486-
icon={<Avatar size={1} avatar={org.avatar} />}
486+
icon={<Avatar size={1} avatar={org.avatar} orgName={org.title} />}
487487
leadingIconClassName="text-text-dimmed"
488488
isSelected={org.id === organization.id}
489489
/>

apps/webapp/app/components/primitives/Avatar.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from "@heroicons/react/20/solid";
99
import { type Prisma } from "@trigger.dev/database";
1010
import { z } from "zod";
11-
import { useOrganization } from "~/hooks/useOrganizations";
1211
import { logger } from "~/services/logger.server";
1312
import { cn } from "~/utils/cn";
1413

@@ -54,17 +53,26 @@ export function Avatar({
5453
avatar,
5554
size,
5655
includePadding,
56+
orgName,
5757
}: {
5858
avatar: Avatar;
5959
/** Size in rems of the icon */
6060
size: number;
6161
includePadding?: boolean;
62+
orgName: string;
6263
}) {
6364
switch (avatar.type) {
6465
case "icon":
6566
return <AvatarIcon avatar={avatar} size={size} includePadding={includePadding} />;
6667
case "letters":
67-
return <AvatarLetters avatar={avatar} size={size} includePadding={includePadding} />;
68+
return (
69+
<AvatarLetters
70+
avatar={avatar}
71+
size={size}
72+
includePadding={includePadding}
73+
orgName={orgName}
74+
/>
75+
);
6876
case "image":
6977
return <AvatarImage avatar={avatar} size={size} />;
7078
}
@@ -110,13 +118,14 @@ function AvatarLetters({
110118
avatar,
111119
size,
112120
includePadding,
121+
orgName,
113122
}: {
114123
avatar: LettersAvatar;
115124
size: number;
116125
includePadding?: boolean;
126+
orgName: string;
117127
}) {
118-
const organization = useOrganization();
119-
const letters = organization.title.slice(0, 2);
128+
const letters = orgName.slice(0, 2);
120129

121130
const style = {
122131
backgroundColor: avatar.hex,

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings._index/route.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ export default function Page() {
374374
);
375375
}
376376

377-
function LogoForm({ organization }: { organization: { avatar: Avatar } }) {
377+
function LogoForm({ organization }: { organization: { avatar: Avatar; title: string } }) {
378378
const navigation = useNavigation();
379379

380380
const isSubmitting =
@@ -392,7 +392,7 @@ function LogoForm({ organization }: { organization: { avatar: Avatar } }) {
392392
<Label>Icon</Label>
393393
<div className="flex w-full items-end justify-between gap-2">
394394
<div className="grid place-items-center overflow-hidden rounded-sm border border-charcoal-750 bg-background-bright">
395-
<Avatar avatar={avatar} size={5} includePadding />
395+
<Avatar avatar={avatar} size={5} includePadding orgName={organization.title} />
396396
</div>
397397
{/* Letters */}
398398
<Form method="post">
@@ -418,6 +418,7 @@ function LogoForm({ organization }: { organization: { avatar: Avatar } }) {
418418
}}
419419
size={2.5}
420420
includePadding
421+
orgName={organization.title}
421422
/>
422423
</button>
423424
</Form>
@@ -449,6 +450,7 @@ function LogoForm({ organization }: { organization: { avatar: Avatar } }) {
449450
}}
450451
size={2.5}
451452
includePadding
453+
orgName={organization.title}
452454
/>
453455
</button>
454456
</Form>

apps/webapp/app/routes/storybook.avatar/route.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function Story() {
2020
<h2 className="mb-4 text-lg font-semibold text-white">Size 8</h2>
2121
<div className="flex flex-wrap gap-2">
2222
{avatars.map((avatar, index) => (
23-
<Avatar key={`small-${index}`} avatar={avatar} size={2} />
23+
<Avatar key={`small-${index}`} avatar={avatar} size={2} orgName={`Org ${index}`} />
2424
))}
2525
</div>
2626
</div>
@@ -30,7 +30,7 @@ export default function Story() {
3030
<h2 className="mb-4 text-lg font-semibold text-white">Size 12</h2>
3131
<div className="flex flex-wrap gap-4">
3232
{avatars.map((avatar, index) => (
33-
<Avatar key={`large-${index}`} avatar={avatar} size={3} />
33+
<Avatar key={`large-${index}`} avatar={avatar} size={3} orgName={`Org ${index}`} />
3434
))}
3535
</div>
3636
</div>

0 commit comments

Comments
 (0)