Vectrum
Sign In
165 lines · 3.4 KB · Rust
//! Icons beyond gpui-component's default set, picked from the bundled Lucide
//! catalog so only these SVGs end up in the binary.

use std::borrow::Cow;

use gpui_kit::*;

pub use gpui_kit::assets::IconName as Lucide;

gpui_kit::assets::icon_assets!(ExtraIcons, [
    AlarmClock,
    AlarmClockOff,
    Archive,
    ArchiveX,
    ArchiveRestore,
    Bell,
    Blocks,
    Brain,
    ChevronsDownUp,
    ChevronsUpDown,
    Code,
    Feather,
    CornerDownRight,
    FileCode,
    FileDiff,
    FolderGit2,
    FolderPlus,
    Gauge,
    Github,
    HardDrive,
    GitBranch,
    GitCommitHorizontal,
    GitPullRequest,
    Image,
    Keyboard,
    Laptop,
    Layers,
    Link2,
    ListOrdered,
    Lock,
    MonitorSmartphone,
    Network,
    LockOpen,
    MessageCircleQuestionMark,
    PanelLeftClose,
    PanelLeftOpen,
    PanelRightClose,
    PanelRightOpen,
    Paperclip,
    Pencil,
    Pi,
    Pin,
    PinOff,
    Plug,
    Plus,
    RotateCcw,
    Server,
    Settings2,
    ShieldCheck,
    SquareDashed,
    SquareSlash,
    SlidersHorizontal,
    Space,
    Sparkles,
    SquarePen,
    SwatchBook,
    Star,
    Trash,
    Undo2,
    Zap,
    Bookmark,
    Bot,
    CircleDot,
    Clock3,
    CornerUpRight,
    FolderGit,
    GripVertical,
    ListPlus,
    ListTodo,
    MessageSquareDashed,
    Minimize2,
    Monitor,
    PenLine,
    PencilRuler,
    RotateCcwClock,
    Scale,
    Shield,
    Hammer,
    MessageCircle,
    Terminal,
    Wrench,
    Quote,
    Download,
    Clock,
    CircleDashed,
    ShieldQuestionMark,
    Timer,
    FolderTree,
    Hash,
    MailOpen,
    MessageSquarePlus,
    ChartNoAxesColumn,
    SquareMenu,
    Maximize2,
    MessageSquare,
    Link,
    ArrowUpDown,
    X,
    ArrowRightLeft,
    GitPullRequestArrow,
    GitMerge,
    GitPullRequestClosed,
    GitPullRequestDraft,
    ListFilter,
    CloudUpload,
    CloudDownload,
    Square,
    SquareSplitHorizontal,
    SquareSplitVertical,
    SquareTerminal,
    Smartphone,
    House,
    Type,
    Camera,
    PictureInPicture2,
    Power,
    GripHorizontal,
    CircleArrowUp,
    RotateCw,
]);

/// Forge logos Lucide doesn't have, from Simple Icons (CC0).
pub const GITLAB: &str = "icons/brands/gitlab.svg";
pub const AZURE_DEVOPS: &str = "icons/brands/azuredevops.svg";
pub const BITBUCKET: &str = "icons/brands/bitbucket.svg";
pub const FORGEJO: &str = "icons/brands/forgejo.svg";

const BRANDS: &[(&str, &[u8])] = &[
    (GITLAB, include_bytes!("../../assets/icons/brands/gitlab.svg")),
    (AZURE_DEVOPS, include_bytes!("../../assets/icons/brands/azuredevops.svg")),
    (BITBUCKET, include_bytes!("../../assets/icons/brands/bitbucket.svg")),
    (FORGEJO, include_bytes!("../../assets/icons/brands/forgejo.svg")),
];

/// The app's asset source: the forge logos, the extra icons, then
/// gpui-component's defaults.
pub struct AppAssets;

impl AssetSource for AppAssets {
    fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
        if let Some((_, data)) = BRANDS.iter().find(|(brand, _)| *brand == path) {
            return Ok(Some(Cow::Borrowed(data)));
        }
        if let Some(data) = ExtraIcons.load(path)? {
            return Ok(Some(data));
        }
        gpui_kit::assets::Assets.load(path)
    }

    fn list(&self, path: &str) -> Result<Vec<SharedString>> {
        let mut paths = ExtraIcons.list(path)?;
        paths.extend(gpui_kit::assets::Assets.list(path)?);
        Ok(paths)
    }
}