use super::Icon;
use crate::{theme::color, tokens::ColorRole};
use gpui_kit::{Hsla, rgb};
pub(crate) const ASSET_PREFIX: &str = "u0ui/brands/";
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct BrandMark {
pub slug: &'static str,
pub title: &'static str,
ink: Option<u32>,
svg: &'static str,
}
macro_rules! mark {
($slug:literal, $title:literal, $ink:expr) => {
BrandMark {
slug: $slug,
title: $title,
ink: $ink,
svg: include_str!(concat!("../../assets/brands/", $slug, ".svg")),
}
};
}
pub const BRAND_MARKS: [BrandMark; 28] = [
mark!("claude", "Claude", Some(0xc15f3c)),
mark!("anthropic", "Anthropic", None),
mark!("opencode", "OpenCode", None),
mark!("googlegemini", "Google Gemini", Some(0x1a73e8)),
mark!("google", "Google", Some(0x4285f4)),
mark!("cursor", "Cursor", None),
mark!("githubcopilot", "GitHub Copilot", None),
mark!("mistralai", "Mistral AI", Some(0xfa520f)),
mark!("qwen", "Qwen", Some(0x6950ef)),
mark!("cline", "Cline", None),
mark!("windsurf", "Windsurf", None),
mark!("zedindustries", "Zed Industries", Some(0x084ccf)),
mark!("jetbrains", "JetBrains", None),
mark!("kimi", "Kimi", None),
mark!("moonshotai", "Moonshot AI", None),
mark!("ollama", "Ollama", None),
mark!("deepseek", "DeepSeek", Some(0x5786fe)),
mark!("perplexity", "Perplexity", Some(0x1fb8cd)),
mark!("x", "X", None),
mark!("figma", "Figma", Some(0xf24e1e)),
mark!("github", "GitHub", None),
mark!("gitlab", "GitLab", Some(0xfc6d26)),
mark!("bitbucket", "Bitbucket", Some(0x0052cc)),
mark!("linear", "Linear", Some(0x5e6ad2)),
mark!("tailscale", "Tailscale", None),
mark!("cloudflare", "Cloudflare", Some(0xf38020)),
mark!("apple", "Apple", None),
mark!("android", "Android", Some(0x3ddc84)),
];
const PREFIXES: [(&str, &str); 32] = [
("claude", "claude"),
("anthropic", "anthropic"),
("opencode", "opencode"),
("googlegemini", "googlegemini"),
("gemini", "googlegemini"),
("google", "google"),
("cursor", "cursor"),
("githubcopilot", "githubcopilot"),
("copilot", "githubcopilot"),
("mistral", "mistralai"),
("qwen", "qwen"),
("cline", "cline"),
("windsurf", "windsurf"),
("zed", "zedindustries"),
("jetbrains", "jetbrains"),
("junie", "jetbrains"),
("kimi", "kimi"),
("moonshot", "moonshotai"),
("ollama", "ollama"),
("deepseek", "deepseek"),
("perplexity", "perplexity"),
("grok", "x"),
("xai", "x"),
("figma", "figma"),
("github", "github"),
("gitlab", "gitlab"),
("bitbucket", "bitbucket"),
("linear", "linear"),
("tailscale", "tailscale"),
("cloudflare", "cloudflare"),
("apple", "apple"),
("android", "android"),
];
pub fn brand_mark(name: &str) -> Option<&'static BrandMark> {
let key: String = name
.chars()
.filter(char::is_ascii_alphanumeric)
.map(|c| c.to_ascii_lowercase())
.collect();
let (_, slug) = PREFIXES.iter().find(|(p, _)| key.starts_with(p))?;
BRAND_MARKS.iter().find(|m| m.slug == *slug)
}
pub(crate) fn asset_svg(slug: &str) -> Option<&'static str> {
BRAND_MARKS.iter().find(|m| m.slug == slug).map(|m| m.svg)
}
impl BrandMark {
pub fn path(&self) -> String {
format!("{ASSET_PREFIX}{}.svg", self.slug)
}
pub fn ink(&self) -> Hsla {
match self.ink {
Some(hex) => rgb(hex).into(),
None => color(ColorRole::TextPrimary),
}
}
pub fn icon(&self) -> Icon {
Icon::from_path(self.path()).color(self.ink())
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tokens::CarbonTheme;
fn slug(name: &str) -> Option<&'static str> {
brand_mark(name).map(|m| m.slug)
}
#[test]
fn marks_are_found_by_id_or_display_name() {
assert_eq!(slug("Claude"), Some("claude"));
assert_eq!(slug("Claude Code"), Some("claude"));
assert_eq!(slug("claude-acp"), Some("claude"));
assert_eq!(slug("Gemini CLI"), Some("googlegemini"));
assert_eq!(slug("Google Gemini"), Some("googlegemini"));
assert_eq!(slug("gemini"), Some("googlegemini"));
assert_eq!(slug("GitHub Copilot"), Some("githubcopilot"));
assert_eq!(slug("github-copilot"), Some("githubcopilot"));
assert_eq!(slug("Copilot"), Some("githubcopilot"));
assert_eq!(slug("GitHub"), Some("github"));
assert_eq!(slug("mistral-vibe"), Some("mistralai"));
assert_eq!(slug("Qwen Code"), Some("qwen"));
assert_eq!(slug("cursor-agent"), Some("cursor"));
assert_eq!(slug("OpenCode"), Some("opencode"));
assert_eq!(slug("GitLab"), Some("gitlab"));
assert_eq!(slug("Bitbucket"), Some("bitbucket"));
}
#[test]
fn brands_without_a_vendored_mark_find_none() {
for name in [
"Codex",
"OpenAI",
"Antigravity",
"Azure DevOps",
"Goose",
"Kiro",
"",
] {
assert_eq!(slug(name), None, "{name}");
}
}
#[test]
fn every_mark_and_prefix_is_served() {
for m in &BRAND_MARKS {
assert!(m.svg.starts_with("<svg") && m.svg.contains("viewBox=\"0 0 24 24\""));
assert_eq!(asset_svg(m.slug), Some(m.svg));
assert_eq!(m.path(), format!("u0ui/brands/{}.svg", m.slug));
}
for (_, s) in PREFIXES {
assert!(asset_svg(s).is_some(), "{s}");
}
assert!(asset_svg("openai").is_none());
}
#[test]
fn monochrome_marks_take_text_primary_and_the_rest_their_ink() {
crate::theme::tests_set(CarbonTheme::White);
let hex = |m: &BrandMark| {
let c = m.ink().to_rgb();
let b = |v: f32| (v * 255.).round() as u8;
format!("#{:02x}{:02x}{:02x}", b(c.r), b(c.g), b(c.b))
};
assert_eq!(hex(brand_mark("Claude").unwrap()), "#c15f3c");
assert_eq!(hex(brand_mark("Gemini").unwrap()), "#1a73e8");
assert_eq!(hex(brand_mark("GitLab").unwrap()), "#fc6d26");
assert_eq!(hex(brand_mark("GitHub").unwrap()), "#161616");
crate::theme::tests_set(CarbonTheme::G100);
assert_eq!(hex(brand_mark("GitHub").unwrap()), "#f4f4f4");
}
}