Skip to content

Commit 45cedfe

Browse files
authored
fix(mobile): no-project threads show a chat bubble instead of a monogram (#21546)
1 parent c14cda1 commit 45cedfe

2 files changed

Lines changed: 53 additions & 19 deletions

File tree

‎apps/mobile/src/components/ProjectFavicon.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
projectAutoMonogram,
1818
projectIconColorClassNames,
1919
resolveProjectIconGlyph,
20+
resolveProjectIconSymbol,
2021
type ProjectIconGlyph,
2122
} from "../lib/projectIcon";
2223

@@ -40,6 +41,7 @@ export const ProjectFavicon = memo(function ProjectFavicon(props: {
4041
readonly projectIcon?: ProjectIconOverride | null;
4142
}) {
4243
const size = props.size ?? 42;
44+
const symbol = resolveProjectIconSymbol(props.projectIcon);
4345
const glyph = resolveProjectIconGlyph(props.projectIcon, props.projectTitle);
4446
const faviconUrl = useAtomValue(
4547
props.workspaceRoot == null || glyph !== null
@@ -74,6 +76,17 @@ export const ProjectFavicon = memo(function ProjectFavicon(props: {
7476
[renderableFaviconUrl, props.environmentId, props.workspaceRoot, props.faviconPath],
7577
);
7678

79+
if (symbol !== null) {
80+
return (
81+
<SymbolView
82+
name={symbol.name}
83+
size={size}
84+
tintColorClassName={projectIconColorClassNames(symbol.color).tint}
85+
type="monochrome"
86+
/>
87+
);
88+
}
89+
7790
if (glyph !== null) {
7891
return <ProjectIconGlyphView glyph={glyph} size={size} />;
7992
}

‎apps/mobile/src/lib/projectIcon.ts‎

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
22
import { ProjectIconColor, type ProjectIconOverride } from "@t3tools/contracts";
33
import { isProjectFaviconFallbackUrl } from "@t3tools/shared/projectFavicon";
4+
import type { AppSymbolName } from "../components/ui/AppSymbol";
45

56
export type ProjectIconGlyph =
67
| { readonly kind: "emoji"; readonly emoji: string }
@@ -66,6 +67,18 @@ export function resolveProjectIconGlyph(
6667
}
6768
}
6869

70+
const SYMBOL_BY_LUCIDE_NAME: Partial<Record<string, AppSymbolName>> = {
71+
"message-square-dashed": "text.bubble",
72+
};
73+
74+
export function resolveProjectIconSymbol(
75+
projectIcon: ProjectIconOverride | null | undefined,
76+
): { readonly name: AppSymbolName; readonly color: ProjectIconColor } | null {
77+
if (projectIcon?.kind !== "lucide") return null;
78+
const name = SYMBOL_BY_LUCIDE_NAME[projectIcon.name];
79+
return name ? { name, color: projectIcon.color } : null;
80+
}
81+
6982
export type ProjectChipIcon = { readonly kind: "favicon"; readonly uri: string } | ProjectIconGlyph;
7083

7184
export function resolveProjectChipIcon(
@@ -87,26 +100,34 @@ export function resolveProjectChipIcon(
87100

88101
const PROJECT_ICON_COLOR_CLASSES: Record<
89102
ProjectIconColor,
90-
{ readonly text: string; readonly background: string }
103+
{ readonly text: string; readonly tint: string; readonly background: string }
91104
> = {
92-
gray: { text: "text-gray-500", background: "bg-gray-500/15" },
93-
red: { text: "text-red-500", background: "bg-red-500/15" },
94-
orange: { text: "text-orange-500", background: "bg-orange-500/15" },
95-
amber: { text: "text-amber-500", background: "bg-amber-500/15" },
96-
yellow: { text: "text-yellow-500", background: "bg-yellow-500/15" },
97-
lime: { text: "text-lime-500", background: "bg-lime-500/15" },
98-
green: { text: "text-green-500", background: "bg-green-500/15" },
99-
emerald: { text: "text-emerald-500", background: "bg-emerald-500/15" },
100-
teal: { text: "text-teal-500", background: "bg-teal-500/15" },
101-
cyan: { text: "text-cyan-500", background: "bg-cyan-500/15" },
102-
sky: { text: "text-sky-500", background: "bg-sky-500/15" },
103-
blue: { text: "text-blue-500", background: "bg-blue-500/15" },
104-
indigo: { text: "text-indigo-500", background: "bg-indigo-500/15" },
105-
violet: { text: "text-violet-500", background: "bg-violet-500/15" },
106-
purple: { text: "text-purple-500", background: "bg-purple-500/15" },
107-
fuchsia: { text: "text-fuchsia-500", background: "bg-fuchsia-500/15" },
108-
pink: { text: "text-pink-500", background: "bg-pink-500/15" },
109-
rose: { text: "text-rose-500", background: "bg-rose-500/15" },
105+
gray: { text: "text-gray-500", tint: "accent-gray-500", background: "bg-gray-500/15" },
106+
red: { text: "text-red-500", tint: "accent-red-500", background: "bg-red-500/15" },
107+
orange: { text: "text-orange-500", tint: "accent-orange-500", background: "bg-orange-500/15" },
108+
amber: { text: "text-amber-500", tint: "accent-amber-500", background: "bg-amber-500/15" },
109+
yellow: { text: "text-yellow-500", tint: "accent-yellow-500", background: "bg-yellow-500/15" },
110+
lime: { text: "text-lime-500", tint: "accent-lime-500", background: "bg-lime-500/15" },
111+
green: { text: "text-green-500", tint: "accent-green-500", background: "bg-green-500/15" },
112+
emerald: {
113+
text: "text-emerald-500",
114+
tint: "accent-emerald-500",
115+
background: "bg-emerald-500/15",
116+
},
117+
teal: { text: "text-teal-500", tint: "accent-teal-500", background: "bg-teal-500/15" },
118+
cyan: { text: "text-cyan-500", tint: "accent-cyan-500", background: "bg-cyan-500/15" },
119+
sky: { text: "text-sky-500", tint: "accent-sky-500", background: "bg-sky-500/15" },
120+
blue: { text: "text-blue-500", tint: "accent-blue-500", background: "bg-blue-500/15" },
121+
indigo: { text: "text-indigo-500", tint: "accent-indigo-500", background: "bg-indigo-500/15" },
122+
violet: { text: "text-violet-500", tint: "accent-violet-500", background: "bg-violet-500/15" },
123+
purple: { text: "text-purple-500", tint: "accent-purple-500", background: "bg-purple-500/15" },
124+
fuchsia: {
125+
text: "text-fuchsia-500",
126+
tint: "accent-fuchsia-500",
127+
background: "bg-fuchsia-500/15",
128+
},
129+
pink: { text: "text-pink-500", tint: "accent-pink-500", background: "bg-pink-500/15" },
130+
rose: { text: "text-rose-500", tint: "accent-rose-500", background: "bg-rose-500/15" },
110131
};
111132

112133
export function projectIconColorClassNames(color: ProjectIconColor) {

0 commit comments

Comments
 (0)