fix(webui): normalize provider mark and tile spacing
This commit is contained in:
1 parent
f7902d3e53
commit
e45bedc560
4 files changed
+63
-19
No files matched your search
@@ -1275,6 +1275,7 @@ export function ProviderIcon({
|
|||||||
const { logoUrl, logoLoaded, onLogoError, onLogoLoad } = useLogoFallback(brand?.logoUrls);
|
const { logoUrl, logoLoaded, onLogoError, onLogoLoad } = useLogoFallback(brand?.logoUrls);
|
||||||
const showRemoteLogo = showBrandLogos && Boolean(logoUrl);
|
const showRemoteLogo = showBrandLogos && Boolean(logoUrl);
|
||||||
const showLoadedLogo = showRemoteLogo && logoLoaded;
|
const showLoadedLogo = showRemoteLogo && logoLoaded;
|
||||||
|
const isLogoTile = brand?.logoLayout === "tile" && logoUrl === brand.logoUrl;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
@@ -1304,7 +1305,8 @@ export function ProviderIcon({
|
|||||||
referrerPolicy="no-referrer"
|
referrerPolicy="no-referrer"
|
||||||
draggable={false}
|
draggable={false}
|
||||||
className={cn(
|
className={cn(
|
||||||
"absolute h-7 w-7 object-contain transition-opacity duration-150 motion-reduce:transition-none",
|
"absolute object-contain transition-opacity duration-150 motion-reduce:transition-none",
|
||||||
|
isLogoTile ? "h-8 w-8" : "h-6 w-6",
|
||||||
logoLoaded ? "opacity-100" : "opacity-0",
|
logoLoaded ? "opacity-100" : "opacity-0",
|
||||||
)}
|
)}
|
||||||
onLoad={onLogoLoad}
|
onLoad={onLogoLoad}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ export interface ProviderBrand {
|
|||||||
logoUrls: string[];
|
logoUrls: string[];
|
||||||
color: string;
|
color: string;
|
||||||
initials: string;
|
initials: string;
|
||||||
|
/** The primary asset already includes its own background and safe area. */
|
||||||
|
logoLayout?: "tile";
|
||||||
}
|
}
|
||||||
|
|
||||||
function officialFaviconUrl(domain: string): string {
|
function officialFaviconUrl(domain: string): string {
|
||||||
@@ -149,41 +151,51 @@ const PROVIDER_LABEL_ALIASES: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PROVIDER_BRANDS: Record<string, ProviderBrand> = {
|
const PROVIDER_BRANDS: Record<string, ProviderBrand> = {
|
||||||
aihubmix: brand("aihubmix.com", "#111827", "AH"),
|
aihubmix: { ...brand("aihubmix.com", "#111827", "AH"), logoLayout: "tile" },
|
||||||
ant_ling: brand("ant-ling.com", "#7C3AED", "AL"),
|
ant_ling: brand("ant-ling.com", "#7C3AED", "AL"),
|
||||||
anthropic: brand("anthropic.com", "#D97757", "A"),
|
anthropic: brand("anthropic.com", "#D97757", "A"),
|
||||||
assemblyai: brand("assemblyai.com", "#111827", "AA"),
|
assemblyai: brand("assemblyai.com", "#111827", "AA"),
|
||||||
atomic_chat: brand("atomic.chat", "#111827", "AC"),
|
atomic_chat: brand("atomic.chat", "#111827", "AC"),
|
||||||
azure_openai: brand("azure.microsoft.com", "#0078D4", "AZ"),
|
azure_openai: brand("azure.microsoft.com", "#0078D4", "AZ"),
|
||||||
bedrock: brand("aws.amazon.com", "#FF9900", "AWS"),
|
bedrock: { ...brand("aws.amazon.com", "#FF9900", "AWS"), logoLayout: "tile" },
|
||||||
bocha: brand("bochaai.com", "#2563EB", "B"),
|
bocha: brand("bochaai.com", "#2563EB", "B"),
|
||||||
brave: brand("brave.com", "#FB542B", "B"),
|
brave: brand("brave.com", "#FB542B", "B"),
|
||||||
byteplus: brand("byteplus.com", "#325CFF", "BP"),
|
byteplus: brand("byteplus.com", "#325CFF", "BP"),
|
||||||
dashscope: brand("dashscope.aliyun.com", "#FF6A00", "DS"),
|
dashscope: brand("dashscope.aliyun.com", "#FF6A00", "DS"),
|
||||||
deepseek: brand("deepseek.com", "#4D6BFE", "DS"),
|
deepseek: brand("deepseek.com", "#4D6BFE", "DS"),
|
||||||
duckduckgo: brand("duckduckgo.com", "#DE5833", "DDG"),
|
duckduckgo: brand("duckduckgo.com", "#DE5833", "DDG"),
|
||||||
exa: brand("exa.ai", "#5B5BF6", "E"),
|
exa: { ...brand("exa.ai", "#5B5BF6", "E"), logoLayout: "tile" },
|
||||||
gemini: brand("gemini.google.com", "#4285F4", "G"),
|
gemini: brand("gemini.google.com", "#4285F4", "G"),
|
||||||
github_copilot: brand("github.com", "#24292F", "GH"),
|
github_copilot: brand("github.com", "#24292F", "GH"),
|
||||||
groq: brand("groq.com", "#F55036", "GQ"),
|
groq: {
|
||||||
|
...brand("groq.com", "#F55036", "GQ", ["https://groq.com/favicon.svg"]),
|
||||||
|
logoLayout: "tile",
|
||||||
|
},
|
||||||
huggingface: brand("huggingface.co", "#FF9D00", "HF"),
|
huggingface: brand("huggingface.co", "#FF9D00", "HF"),
|
||||||
jina: brand("jina.ai", "#7C3AED", "J"),
|
jina: brand("jina.ai", "#7C3AED", "J"),
|
||||||
kagi: brand("kagi.com", "#FFB319", "K"),
|
kagi: brand("kagi.com", "#FFB319", "K"),
|
||||||
keenable: brand("keenable.ai", "#0EA5E9", "K"),
|
keenable: brand("keenable.ai", "#0EA5E9", "K"),
|
||||||
lm_studio: brand("lmstudio.ai", "#111827", "LM"),
|
lm_studio: { ...brand("lmstudio.ai", "#111827", "LM"), logoLayout: "tile" },
|
||||||
longcat: brand("longcat.ai", "#4F8CFF", "LC", [
|
longcat: brand("longcat.ai", "#4F8CFF", "LC", [
|
||||||
"https://s3plus.meituan.net/aigc-media-resources/longcat/yeqian-logo.svg",
|
"https://s3plus.meituan.net/aigc-media-resources/longcat/yeqian-logo.svg",
|
||||||
]),
|
]),
|
||||||
minimax: brand("minimax.io", "#111827", "MM"),
|
minimax: { ...brand("minimax.io", "#111827", "MM"), logoLayout: "tile" },
|
||||||
mistral: brand("mistral.ai", "#FA520F", "M"),
|
mistral: brand("mistral.ai", "#FA520F", "M"),
|
||||||
modelscope: brand("modelscope.cn", "#5B5BF6", "MS"),
|
modelscope: { ...brand("modelscope.cn", "#5B5BF6", "MS"), logoLayout: "tile" },
|
||||||
moonshot: brand("moonshot.ai", "#111827", "MS"),
|
moonshot: {
|
||||||
|
...brand("moonshot.ai", "#111827", "MS", [
|
||||||
|
"https://statics.kimi.ai/moonshot-ai/favicon.ico",
|
||||||
|
]),
|
||||||
|
logoLayout: "tile",
|
||||||
|
},
|
||||||
novita: brand("novita.ai", "#7C3AED", "N"),
|
novita: brand("novita.ai", "#7C3AED", "N"),
|
||||||
olostep: brand("olostep.com", "#111827", "O"),
|
olostep: { ...brand("olostep.com", "#111827", "O"), logoLayout: "tile" },
|
||||||
nvidia: brand("nvidia.com", "#76B900", "NV"),
|
nvidia: brand("nvidia.com", "#76B900", "NV"),
|
||||||
ollama: brand("ollama.com", "#111827", "O"),
|
ollama: brand("ollama.com", "#111827", "O"),
|
||||||
openai: brand("openai.com", "#111827", "AI"),
|
openai: brand("openai.com", "#111827", "AI"),
|
||||||
openrouter: brand("openrouter.ai", "#111827", "OR"),
|
openrouter: brand("openrouter.ai", "#111827", "OR", [
|
||||||
|
"https://openrouter.ai/brand/logos/transparent/glyph/svg/glyph-grape.svg",
|
||||||
|
]),
|
||||||
orcarouter: brand("orcarouter.ai", "#111827", "OR"),
|
orcarouter: brand("orcarouter.ai", "#111827", "OR"),
|
||||||
ovms: brand("openvino.ai", "#0071C5", "OV"),
|
ovms: brand("openvino.ai", "#0071C5", "OV"),
|
||||||
qianfan: brand("cloud.baidu.com", "#2932E1", "QF"),
|
qianfan: brand("cloud.baidu.com", "#2932E1", "QF"),
|
||||||
@@ -193,17 +205,21 @@ const PROVIDER_BRANDS: Record<string, ProviderBrand> = {
|
|||||||
stepfun: brand("stepfun.com", "#2F6BFF", "SF", [
|
stepfun: brand("stepfun.com", "#2F6BFF", "SF", [
|
||||||
"https://www.stepfun.com/step_favicon.svg",
|
"https://www.stepfun.com/step_favicon.svg",
|
||||||
]),
|
]),
|
||||||
tavily: brand("tavily.com", "#111827", "T"),
|
tavily: { ...brand("tavily.com", "#111827", "T"), logoLayout: "tile" },
|
||||||
volcengine: brand("volcengine.com", "#1664FF", "VE"),
|
volcengine: brand("volcengine.com", "#1664FF", "VE"),
|
||||||
vllm: brand("vllm.ai", "#2563EB", "VL"),
|
vllm: brand("vllm.ai", "#2563EB", "VL"),
|
||||||
xiaomi_mimo: brand("mimo.xiaomi.com", "#FF6900", "MI", [
|
xiaomi_mimo: brand("mimo.xiaomi.com", "#FF6900", "MI", [
|
||||||
"https://mimo.xiaomi.com/mimo-v2-pro/assets/logo.svg",
|
"https://mimo.xiaomi.com/mimo-v2-pro/assets/logo.svg",
|
||||||
]),
|
]),
|
||||||
xai: brand("x.ai", "#111827", "xAI"),
|
xai: brand("x.ai", "#111827", "xAI"),
|
||||||
zhipu: brand("z.ai", "#155EEF", "Z", [
|
zhipu: {
|
||||||
"https://z-cdn.chatglm.cn/z-ai/static/logo.svg",
|
...brand("z.ai", "#155EEF", "Z", [
|
||||||
"https://www.google.com/s2/favicons?domain=z.ai&sz=64",
|
"https://mintcdn.com/zhipu-32152247/B_E8wI-eiNa1QlPV/logo/dark.svg",
|
||||||
]),
|
"https://z-cdn.chatglm.cn/z-ai/static/logo.svg",
|
||||||
|
"https://www.google.com/s2/favicons?domain=z.ai&sz=64",
|
||||||
|
]),
|
||||||
|
logoLayout: "tile",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function providerBrand(provider: string | null | undefined): ProviderBrand | null {
|
export function providerBrand(provider: string | null | undefined): ProviderBrand | null {
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ describe("provider brand logos", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("keeps Zhipu on the current Z.ai brand domain", () => {
|
it("keeps Zhipu on the current Z.ai brand domain", () => {
|
||||||
expect(providerBrand("zhipu")?.logoUrls[0]).toBe("https://z-cdn.chatglm.cn/z-ai/static/logo.svg");
|
expect(providerBrand("zhipu")?.logoUrls[0]).toBe("https://mintcdn.com/zhipu-32152247/B_E8wI-eiNa1QlPV/logo/dark.svg");
|
||||||
|
expect(providerBrand("zhipu")?.logoUrls).toContain("https://z-cdn.chatglm.cn/z-ai/static/logo.svg");
|
||||||
expect(providerBrand("zhipu")?.logoUrls).toContain("https://www.google.com/s2/favicons?domain=z.ai&sz=64");
|
expect(providerBrand("zhipu")?.logoUrls).toContain("https://www.google.com/s2/favicons?domain=z.ai&sz=64");
|
||||||
expect(providerBrand("zhipu")?.logoUrls).toContain("https://z.ai/favicon.ico");
|
expect(providerBrand("zhipu")?.logoUrls).toContain("https://z.ai/favicon.ico");
|
||||||
expect(providerBrand("zhipu")?.initials).toBe("Z");
|
expect(providerBrand("zhipu")?.initials).toBe("Z");
|
||||||
@@ -78,6 +79,7 @@ describe("provider brand logos", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("keeps OpenRouter voice settings on the first-party brand domain", () => {
|
it("keeps OpenRouter voice settings on the first-party brand domain", () => {
|
||||||
|
expect(providerBrand("openrouter")?.logoUrl).toBe("https://openrouter.ai/brand/logos/transparent/glyph/svg/glyph-grape.svg");
|
||||||
expect(providerBrand("openrouter")?.logoUrls).toContain("https://openrouter.ai/favicon.ico");
|
expect(providerBrand("openrouter")?.logoUrls).toContain("https://openrouter.ai/favicon.ico");
|
||||||
expect(providerBrand("openrouter")?.initials).toBe("OR");
|
expect(providerBrand("openrouter")?.initials).toBe("OR");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ describe("settings provider icons", () => {
|
|||||||
expect(icon.className.split(/\s+/).some((value) => value.startsWith("border"))).toBe(false);
|
expect(icon.className.split(/\s+/).some((value) => value.startsWith("border"))).toBe(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
it.each(["openai_codex", "anthropic", "deepseek", "gemini", "xai_grok", "longcat"])(
|
it.each(["openai_codex", "anthropic", "deepseek", "gemini", "xai_grok", "longcat", "openrouter"])(
|
||||||
"shows %s on a single white tile with a small inset after loading",
|
"shows %s on a single white tile with a small inset after loading",
|
||||||
(provider) => {
|
(provider) => {
|
||||||
const { container } = render(<ProviderIcon provider={provider} showBrandLogos />);
|
const { container } = render(<ProviderIcon provider={provider} showBrandLogos />);
|
||||||
@@ -26,7 +26,7 @@ describe("settings provider icons", () => {
|
|||||||
expect(icon).toHaveClass("bg-muted");
|
expect(icon).toHaveClass("bg-muted");
|
||||||
expect(fallback).toHaveTextContent(providerBrand(provider)!.initials);
|
expect(fallback).toHaveTextContent(providerBrand(provider)!.initials);
|
||||||
expect(fallback).toHaveClass("opacity-100");
|
expect(fallback).toHaveClass("opacity-100");
|
||||||
expect(image).toHaveClass("h-7", "w-7", "object-contain", "opacity-0");
|
expect(image).toHaveClass("h-6", "w-6", "object-contain", "opacity-0");
|
||||||
expect(image).toHaveAttribute("alt", "");
|
expect(image).toHaveAttribute("alt", "");
|
||||||
|
|
||||||
fireEvent.load(image);
|
fireEvent.load(image);
|
||||||
@@ -41,6 +41,30 @@ describe("settings provider icons", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it.each(["aihubmix", "bedrock", "exa", "groq", "lm_studio", "minimax", "minimax_anthropic", "modelscope", "moonshot", "olostep", "tavily", "zhipu"])(
|
||||||
|
"does not double-frame %s's primary tile, but preserves unknown fallback assets",
|
||||||
|
(provider) => {
|
||||||
|
const { container } = render(<ProviderIcon provider={provider} showBrandLogos />);
|
||||||
|
const icon = container.firstElementChild!;
|
||||||
|
const image = icon.querySelector("img")!;
|
||||||
|
expectFootprint(icon);
|
||||||
|
expect(image).toHaveAttribute("src", providerBrand(provider)!.logoUrl);
|
||||||
|
expect(image).toHaveClass("h-8", "w-8", "object-contain", "opacity-0");
|
||||||
|
|
||||||
|
fireEvent.load(image);
|
||||||
|
expect(image).toHaveClass("opacity-100");
|
||||||
|
expect(icon).toHaveClass("bg-white");
|
||||||
|
|
||||||
|
fireEvent.error(image);
|
||||||
|
expect(image).toHaveAttribute("src", providerBrand(provider)!.logoUrls[1]);
|
||||||
|
expect(image).toHaveClass("h-6", "w-6", "object-contain", "opacity-0");
|
||||||
|
expect(icon).toHaveClass("bg-muted");
|
||||||
|
fireEvent.load(image);
|
||||||
|
expectFootprint(icon);
|
||||||
|
expect(image).toHaveClass("h-6", "w-6", "opacity-100");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
it("keeps its placeholder through alternate URLs and complete image failure", () => {
|
it("keeps its placeholder through alternate URLs and complete image failure", () => {
|
||||||
const { container } = render(<ProviderIcon provider="openai_codex" showBrandLogos />);
|
const { container } = render(<ProviderIcon provider="openai_codex" showBrandLogos />);
|
||||||
const icon = container.firstElementChild!;
|
const icon = container.firstElementChild!;
|
||||||
|
|||||||
Reference in new issue
Block a user