Skip to content

fix(static): add safe-area padding to PWA icons for macOS dock#2256

Open
rahilmavani wants to merge 2 commits into
huggingface:mainfrom
rahilmavani:fix/pwa-icon-padding
Open

fix(static): add safe-area padding to PWA icons for macOS dock#2256
rahilmavani wants to merge 2 commits into
huggingface:mainfrom
rahilmavani:fix/pwa-icon-padding

Conversation

@rahilmavani
Copy link
Copy Markdown

Closes #1439

Problem

The PWA icons in static/huggingchat/ were rasterized from the favicon SVG with the artwork filling the entire canvas. When Chrome on macOS installs the site as an app via Save and Share > Install, it uses the highest resolution icon from manifest.json as the dock icon. Because native macOS app icons follow Apple's convention of leaving roughly 12 to 15 percent transparent margin around the artwork, the HuggingChat icon visibly overshoots the dock baseline and looks oversized next to other apps.

Change

Regenerated the nine icon-NxN.png files plus apple-touch-icon.png from the same favicon.svg source artwork, but with the artwork scaled to 75 percent and centered inside the canvas. This leaves 12.5 percent transparent padding on each side, which matches macOS native dock icon spacing.

manifest.json icon entries also now declare \"purpose\": \"any maskable\" so PWA platforms that apply mask cropping (Android adaptive icons, some Chromium contexts) recognize them as safe to mask.

icon.svg and favicon.svg are intentionally left unchanged. Those are used by the browser tab favicon where filling the canvas is correct, and changing them would shrink the tab favicon for no reason.

Files touched

  • static/huggingchat/icon-36x36.png through icon-512x512.png (9 files)
  • static/huggingchat/apple-touch-icon.png
  • static/huggingchat/manifest.json (added purpose field to each icon entry)

No code logic, build config, or runtime behavior is modified.

How it was generated

The artwork was wrapped in <g transform=\"translate(4 4) scale(0.75)\"> over the existing 32 unit viewBox, then rasterized at each manifest size with sharp using a density that scales with target resolution to keep edges crisp. Same source artwork, same colors, same file paths, only padding and purpose changed.

Testing

  • All ten output files have correct dimensions (file *.png confirms 36, 48, 72, 96, 128, 144, 192, 256, 512, and 180 for apple-touch-icon).
  • Background is transparent so the icon behaves correctly on both light and dark dock backgrounds.
  • File sizes shrunk slightly (transparent pixels compress better) but the visual artwork and color profile are unchanged.

The PWA icons under static/huggingchat were rasterized from the
favicon SVG with the artwork filling the full canvas. When Chrome
on macOS installs the site as an app, it uses the highest
resolution manifest icon as the dock icon, which renders visibly
larger than native macOS apps because those follow Apple's
convention of leaving roughly 12 to 15 percent safe area around
the artwork.

Regenerated icon-36x36 through icon-512x512 and apple-touch-icon
from the same favicon.svg source, but with the artwork scaled to
75 percent and centered, leaving 12.5 percent transparent padding
on each side. Also added "purpose": "any maskable" to each
manifest icon entry so PWA platforms that apply mask cropping
recognize them as safe to mask.

icon.svg and favicon.svg are unchanged because the browser tab
favicon should still fill its canvas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chrome app icon on macOS

1 participant