Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

4.1 KB
Raw Blame
<script lang="ts">
  /**
   * LibreGet navigation icon with high-resolution multi-density penguin artwork.
   */
  let {
    icon,
    iconSvg,
    size = 26,
    active = false,
  }: { icon: string; iconSvg?: string; size?: number; active?: boolean } = $props();

  const PENGUIN_ICONS: Record<string, string> = {
    home: "home",
    downloads: "downloads",
    tools: "tools",
    nami: "nami",
    marketplace: "marketplace",
    settings: "settings",
    about: "about",
    convert: "convert",
    courses: "courses",
    telegram: "telegram",
  };

  const TILES: Record<string, { glyph: string; from: string; to: string }> = {
    chat: { glyph: "chats-circle", from: "#4CD964", to: "#2AA845" },
    misc: { glyph: "wrench", from: "#9B9BA3", to: "#63636B" },
    plugin: { glyph: "puzzle-piece", from: "#8E8E93", to: "#5C5C60" },
  };

  let penguin = $derived(PENGUIN_ICONS[icon]);
  let tile = $derived(TILES[icon] ?? TILES.plugin);
  let glyphSize = $derived(Math.round(size * 0.64));
</script>

{#if penguin}
  <span
    class="nav-icon nav-penguin"
    class:nav-icon-active={active}
    style:--icon-size="{size}px"
    aria-hidden="true"
  >
    <img
      src="/icons/nav/{penguin}-32.png"
      srcset="/icons/nav/{penguin}-32.png 1x, /icons/nav/{penguin}-64.png 2x"
      alt=""
      width={size}
      height={size}
      class="nav-penguin-img"
      draggable="false"
      decoding="async"
    />
  </span>
{:else if iconSvg}
  <span
    class="nav-icon nav-tile"
    class:nav-icon-active={active}
    style:--tile-from={tile.from}
    style:--tile-to={tile.to}
    style:--tile-size="{size}px"
    aria-hidden="true"
  >
    <svg viewBox="0 0 24 24" width={glyphSize} height={glyphSize} fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
      {#each iconSvg.split(" M").map((d, i) => (i === 0 ? d : "M" + d)) as pathD}
        <path d={pathD} />
      {/each}
    </svg>
  </span>
{:else}
  <span
    class="nav-icon nav-tile"
    class:nav-icon-active={active}
    style:--tile-from={tile.from}
    style:--tile-to={tile.to}
    style:--tile-size="{size}px"
    aria-hidden="true"
  >
    <span class="nav-glyph" style:--glyph="url(/icons/{tile.glyph}.svg)" style:width="{glyphSize}px" style:height="{glyphSize}px"></span>
  </span>
{/if}

<style>
  .nav-penguin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-size);
    height: var(--icon-size);
    flex-shrink: 0;
  }

  .nav-penguin-img {
    width: var(--icon-size);
    height: var(--icon-size);
    object-fit: contain;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transition: transform 0.15s var(--ease-out, ease-out);
  }

  .nav-icon-active .nav-penguin-img {
    transform: scale(1.08);
  }

  :global(.mac-nav-item:hover) .nav-penguin-img:not(.nav-icon-active) {
    transform: scale(1.08);
  }

  .nav-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tile-size);
    height: var(--tile-size);
    flex-shrink: 0;
    border-radius: calc(var(--tile-size) * 0.28);
    background: linear-gradient(180deg, var(--tile-from), var(--tile-to));
    box-shadow:
      inset 0 0 0 0.5px rgba(255, 255, 255, 0.25),
      inset 0 -1px 1px rgba(0, 0, 0, 0.12),
      0 0.5px 1px rgba(0, 0, 0, 0.25);
    color: #fff;
    transition: transform 0.15s var(--ease-out, ease-out);
  }

  .nav-glyph {
    display: block;
    background: #fff;
    -webkit-mask: var(--glyph) center / contain no-repeat;
    mask: var(--glyph) center / contain no-repeat;
    filter: drop-shadow(0 0.5px 0 rgba(0, 0, 0, 0.18));
  }

  .nav-icon-active.nav-tile {
    transform: scale(1.05);
  }

  :global(.mac-nav-item:hover) .nav-tile:not(.nav-icon-active) {
    transform: scale(1.05);
  }

  @media (prefers-reduced-motion: reduce) {
    .nav-penguin-img,
    .nav-tile {
      transition: none;
    }
    :global(.mac-nav-item:hover) .nav-penguin-img:not(.nav-icon-active),
    :global(.mac-nav-item:hover) .nav-tile:not(.nav-icon-active) {
      transform: none;
    }
  }
</style>