Skip to content

Generate letter-icon fallback for icon-less apps#24

Merged
akirk merged 2 commits into
mainfrom
letter-icon-fallback
Apr 24, 2026
Merged

Generate letter-icon fallback for icon-less apps#24
akirk merged 2 commits into
mainfrom
letter-icon-fallback

Conversation

@akirk

@akirk akirk commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Apps that register without an icon_url / dashicon / emoji field were being silently dropped — both in get_apps() (for additional_apps) and at render time (templates/launcher.php's else { continue; }).
  • They now render a letter tile: one letter for single-word names, first letter of each of the first two words otherwise, on a deterministic HSL background hashed from the lowercased name. Rendered as inline SVG with a 0 0 100 100 viewBox so the aspect ratio stays 1:1 regardless of CSS context.
  • ajax_unhide_app now emits a letter_icon payload when the restored app has no icon, so the JS createAppElement can reconstruct the same tile client-side via createElementNS.
  • While in there: dropped the body.my-apps-launcher { margin-top: 32px/46px } rules — WordPress's admin-bar CSS applies the offset on <html>, so ours were stacking on top and leaving a visible gap on mobile.

Test plan

  • Register an app via the my_apps_plugins filter without any icon field and confirm it renders as a letter tile in the launcher (previously it would not appear).
  • Confirm two-word names render both initials ("Google Drive" → GD), single-word names render one ("Gmail" → G).
  • Reload — tile colour is stable for the same name (deterministic hash).
  • Hide a letter-icon app → reopen Hidden Apps → confirm the small variant still shows the correct letters/colour.
  • Unhide the app → confirm it reappears in the grid with the same tile.
  • On mobile, verify no blank margin above the launcher content; the admin bar sits flush at the top.

akirk added 2 commits April 24, 2026 03:46
- Add a static letter-icon helper that renders an SVG tile with one
  letter (single-word names) or two letters (first letter of each of
  the first two words), on a deterministic HSL background derived
  from the name. SVG with a 100×100 viewBox locks the aspect ratio
  at 1:1 regardless of cascade quirks.
- Template and hide/unhide paths use the helper instead of dropping
  icon-less entries.
- get_apps() no longer filters out additional_apps entries missing
  all icon fields — they render with the letter fallback now.
- ajax_unhide_app emits letter_icon data when the restored app has
  no image/dashicon/emoji so the client can reconstruct the tile.
- Drop the hard-coded body margin-top/min-height rules — the WP
  admin-bar CSS already applies the correct offset on html, so our
  rules were doubling up and leaving a mobile gap.
@akirk akirk merged commit 7ffb47f into main Apr 24, 2026
@akirk akirk deleted the letter-icon-fallback branch May 5, 2026 10:34
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.

1 participant