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.

2.8 KB
Raw Blame
<script lang="ts">
  /**
   * Tile de ícone da seção Tools: quadrado arredondado com gradiente e um
   * glifo branco em máscara. Aceita `brand:<nome>` (static/brands, Simple
   * Icons) ou `glyph:<nome>` (static/icons, Phosphor Fill), o mesmo esquema
   * do NavIcon da sidebar, só que em tamanho de Launchpad.
   */
  let {
    icon,
    from,
    to,
    via,
    size = 96,
    muted = false,
  }: { icon: string; from: string; to: string; via?: string; size?: number; muted?: boolean } = $props();

  let kind = $derived(icon.startsWith("brand:") ? "brand" : icon.startsWith("app:") ? "app" : "glyph");
  let name = $derived(icon.slice(icon.indexOf(":") + 1));
  let url = $derived(kind === "brand" ? `/brands/${name}.svg` : kind === "app" ? `/apps/${name}.png` : `/icons/${name}.svg`);
  let glyphSize = $derived(Math.round(size * (kind === "brand" ? 0.52 : 0.58)));
  let gradient = $derived(
    via ? `linear-gradient(135deg, ${from} 0%, ${via} 55%, ${to} 100%)` : `linear-gradient(180deg, ${from}, ${to})`,
  );
</script>

{#if kind === "app"}
  <img class="tool-app" class:muted src={url} alt="" width={size} height={size} draggable="false" aria-hidden="true" />
{:else}
  <span
    class="tool-icon"
    class:muted
    style:width="{size}px"
    style:height="{size}px"
    style:border-radius="{Math.round(size * 0.225)}px"
    style:background={gradient}
    aria-hidden="true"
  >
    <img
      class="tool-glyph-img"
      src={url}
      alt=""
      width={glyphSize}
      height={glyphSize}
      draggable="false"
      loading="lazy"
      decoding="async"
    />
  </span>
{/if}

<style>
  .tool-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.25),
      0 2px 8px -2px rgba(0, 0, 0, 0.25);
    transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
  }

  /* brilho de topo, como os ícones de app do macOS */
  .tool-icon::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0) 55%);
    pointer-events: none;
  }

  .tool-app {
    display: block;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
    transition: transform var(--duration-fast) var(--ease-out);
  }

  .tool-app.muted {
    filter: saturate(0.55) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.3));
    opacity: 0.72;
  }

  .tool-icon.muted {
    filter: saturate(0.55);
    opacity: 0.72;
  }

  .tool-glyph-img {
    display: block;
    object-fit: contain;
    filter: brightness(0) invert(1);
    pointer-events: none;
    -webkit-user-drag: none;
  }
</style>