Skip to content

refactor: unify platform icons across homepage, APIStatus, and PlatformSvg#1082

Merged
Huxpro merged 5 commits into
mainfrom
feat/unify-platform-icons
Jun 3, 2026
Merged

refactor: unify platform icons across homepage, APIStatus, and PlatformSvg#1082
Huxpro merged 5 commits into
mainfrom
feat/unify-platform-icons

Conversation

@Huxpro

@Huxpro Huxpro commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Platform icons used to live in three places with three rendering strategies:

Surface Source Strategy
Homepage feature card @assets/home/home-icon-*.svg SVGR ?react + per-icon fill overrides
APIStatus / APISummary Inline JSX SVGs + createMaskIcon for macOS / Windows Mixed
PlatformSvg / PlatformTabs / ChoiceTabs / PlatformBadge @assets/home/* (mostly) mask-image + currentColor
APITable headers compat-table/assets/icons/* mask-image via _icon.scss

This PR routes every surface through a single <PlatformSvg /> that reads from the compat-table icon set. New platforms now mean "add one SVG and one entry in ICON_NAME_TO_URL" instead of touching three files.

What changed

  • PlatformIcon.tsx: dropped the @assets/home/* imports; one ICON_NAME_TO_URL table backed by compat-table/assets/icons/. The mapping reuses compat-table's mapPlatformNameToIconName so homepage and APITable stay in lockstep when platforms are added.
  • home-comps/features/icon.tsx: per-platform SVGR imports replaced with thin <PlatformSvg /> wrappers and a shared .platform-icon size class.
  • api-status/constants.tsx: inline JSX SVGs and the createMaskIcon helper replaced with one makeIcon(platformName) factory that delegates to <PlatformSvg />.

Visible change

The homepage Android icon switches from the half-dome face to the full Bugdroid body that APITable / APISummary already showed, so the two surfaces now match. iOS / HarmonyOS / Web / macOS / Windows render the same glyph on every surface.

Test plan

  • Visit / — feature card platform row shows iOS, Android (Bugdroid), HarmonyOS, Web (HTML5), Desktop (macOS + Windows)
  • Visit a page with <APITable /> (e.g. /guide/devtool) — column headers show the same glyphs
  • Visit /guide/start/integrate-with-existing-apps.html — platform tabs match
  • Visit /api-status or any APISummary surface — platform badges match
  • Toggle light / dark — every surface inherits the right color for the mask

Consolidate platform icon rendering into single canonical source

  • Unify platform icon rendering across lynx-ui surfaces by routing all consumers through PlatformSvg backed by compat-table/assets/icons/
  • Replace per-platform SVGR imports and inline SVGs with PlatformSvg wrappers in src/components/home-comps/features/icon.tsx and api-status constants
  • Centralize icon name → URL mapping in PlatformIcon.tsx via ICON_NAME_TO_URL and mapPlatformNameToIconName
  • Remove @assets/home/* SVG usage and per-platform CSS overrides; add .platform-icon sizing rule in home-comps/features/index.module.less
  • Ensure icon mask-based coloring uses mask-image/currentColor to preserve light/dark and per-platform tinting
  • Harmonize glyphs across homepage, APITable/APISummary, APIStatus (homepage Android now uses Bugdroid full-body glyph)

Copilot AI review requested due to automatic review settings June 3, 2026 16:32
@Huxpro Huxpro requested a review from SoonIter as a code owner June 3, 2026 16:32
@netlify

netlify Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploy Preview for lynx-doc ready!

Name Link
🔨 Latest commit 0ab02c7
🔍 Latest deploy log https://app.netlify.com/projects/lynx-doc/deploys/6a207460ab6a850008b73165
😎 Deploy Preview https://deploy-preview-1082--lynx-doc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b36f434f-d3bb-4d33-a6e2-32c8bdfa2c1d

📥 Commits

Reviewing files that changed from the base of the PR and between ae72f12 and fb6b699.

⛔ Files ignored due to path filters (8)
  • docs/public/assets/home/clay.svg is excluded by !**/*.svg
  • docs/public/assets/home/harmony.svg is excluded by !**/*.svg
  • docs/public/assets/home/home-icon-android.svg is excluded by !**/*.svg
  • docs/public/assets/home/home-icon-apple-dark.svg is excluded by !**/*.svg
  • docs/public/assets/home/home-icon-apple.svg is excluded by !**/*.svg
  • docs/public/assets/home/home-icon-web.svg is excluded by !**/*.svg
  • docs/public/assets/home/windows.svg is excluded by !**/*.svg
  • src/components/api-table/compat-table/assets/icons/android.svg is excluded by !**/*.svg
📒 Files selected for processing (4)
  • src/components/api-status/constants.tsx
  • src/components/home-comps/features/icon.tsx
  • src/components/home-comps/features/index.module.less
  • src/components/platform-navigation/PlatformIcon.tsx
✅ Files skipped from review due to trivial changes (1)
  • src/components/home-comps/features/index.module.less
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/components/platform-navigation/PlatformIcon.tsx
  • src/components/api-status/constants.tsx

Walkthrough

Centralizes platform icon rendering by moving PlatformSvg to a lookup-table-based icon URL mapper, then replaces per-platform icon components and CSS with a makeIcon factory and a PlatformIconWrapper using a generic .platform-icon class.

Changes

Platform Icon System Refactor

Layer / File(s) Summary
PlatformSvg core refactor with icon URL lookup
src/components/platform-navigation/PlatformIcon.tsx
PlatformSvg switches from inline icon-selection logic to a centralized ICON_NAME_TO_URL lookup and toIconUrl mapper, updates imports to compat-table assets, and retains toPlatformName normalization.
API status constants icon factory
src/components/api-status/constants.tsx
Replaces per-platform inline SVG icon components with a makeIcon factory that returns PlatformSvg wrappers; removes prior inline/masked SVG implementations while preserving exported names.
Home features icon wrapper and unified styling
src/components/home-comps/features/icon.tsx, src/components/home-comps/features/index.module.less
Adds PlatformIconWrapper and PLATFORM_TINT, updates exported Icon* components to render PlatformSvg by platformName, and replaces per-platform .ios-icon/.web-icon fills with a generic .platform-icon size variable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • SoonIter
  • colinaaa
  • gaoachao
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: unify platform icons across homepage, APIStatus, and PlatformSvg' directly matches the PR's main objective of consolidating platform icon rendering into a single component and canonical icon source across these three areas.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/unify-platform-icons

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 3, 2026

Copy link
Copy Markdown

Deploying lynx-website-next with  Cloudflare Pages  Cloudflare Pages

Latest commit: baa075a
Status: ✅  Deploy successful!
Preview URL: https://6b8ebd3e.lynx-website-next.pages.dev
Branch Preview URL: https://feat-unify-platform-icons.lynx-website-next.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors platform icon rendering so homepage feature cards, API status surfaces, and the platform navigation components all route through the shared <PlatformSvg /> implementation backed by the compat-table icon set, reducing duplication and keeping icons consistent when new platforms are added.

Changes:

  • Centralized platform icon asset mapping in PlatformIcon.tsx (compat-table icons + mapPlatformNameToIconName).
  • Replaced homepage per-platform SVGR icon components with thin <PlatformSvg /> wrappers and a shared .platform-icon style.
  • Replaced API status inline JSX SVGs / createMaskIcon with a makeIcon(platformName) factory that delegates to <PlatformSvg />.

Reviewed changes

Copilot reviewed 4 out of 11 changed files in this pull request and generated 2 comments.

File Description
src/components/platform-navigation/PlatformIcon.tsx Centralizes icon URL mapping and reuses compat-table platform→icon-name mapping.
src/components/home-comps/features/index.module.less Replaces per-icon fill/size overrides with a single .platform-icon rule.
src/components/home-comps/features/icon.tsx Swaps SVGR-per-icon components for <PlatformSvg /> wrappers.
src/components/api-status/constants.tsx Removes inline SVG icon components in favor of <PlatformSvg />-based factory icons.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 48 to 56
export const PlatformSvg = ({
platformName,
className,
key,
}: {
// Accept extra string ids ('clay', 'macos', 'macos-arm64', 'macos-intel',
// 'windows') alongside the canonical PlatformName so PlatformTabs and
// ChoiceTabs can use the homepage-aligned icon set without TS friction.
platformName: PlatformName | string;
className?: string;
key?: string;
}) => {
Comment on lines +70 to +85
const toPlatformName = (platform: string): PlatformName => {
switch (platform) {
case 'ios':
case 'ios-simulator':
case 'macos':
case 'macos-arm64':
case 'macos-intel':
return 'ios';
case 'android':
return 'android';
case 'web':
return 'web_lynx';
default:
return 'web_lynx';
}
};

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/platform-navigation/PlatformIcon.tsx (1)

70-106: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Fix macOS icon rendering in PlatformIcon (toPlatformName incorrectly maps macos*ios)
src/components/platform-navigation/PlatformIcon.tsx currently normalizes macos / macos-arm64 / macos-intel to 'ios', so PlatformTabs (which passes platforms={[option.id]} where option.id can be macos*) ends up showing the Apple icon. PlatformSvg/toIconUrl already has explicit handling to resolve macos* to the macOS SVG, so this normalization layer breaks consistency.

Update toPlatformName so macos* resolves to a value that toIconUrl can render as macOS (instead of 'ios'). If you consider passing platform through directly, also handle ios-simulator (since the current fallback mapping would otherwise render the wrong icon).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/platform-navigation/PlatformIcon.tsx` around lines 70 - 106,
toPlatformName currently maps macos, macos-arm64, macos-intel to 'ios', causing
PlatformIcon -> PlatformSvg to render the wrong Apple iOS icon; update
toPlatformName so macos* values map to a macOS-identifying value that
toIconUrl/PlatformSvg recognize (e.g., return 'macos' for 'macos',
'macos-arm64', 'macos-intel'), and keep ios-simulator handled explicitly (either
map 'ios-simulator' to 'ios-simulator' or to 'ios' depending on how toIconUrl
expects it) so PlatformIcon/PlatformSvg render the correct macOS and iOS
simulator icons.
🧹 Nitpick comments (1)
src/components/platform-navigation/PlatformIcon.tsx (1)

29-46: 💤 Low value

toIconUrl's explicit clay/web/windows branches are redundant.

mapPlatformNameToIconName returns its argument unchanged in the default case, so clay, web, and windows already resolve to the correct ICON_NAME_TO_URL entries via the fallback path. Only the macos/macos-arm64/macos-intel branch is genuinely needed (none map to a macos key in the table). The duplicated branches add a maintenance hazard if the table and the inline checks drift.

♻️ Suggested simplification
 const toIconUrl = (platformName: PlatformName | string): string => {
-  // Extra string ids used by tabs/badges that aren't in BCD.PlatformName.
-  if (platformName === 'clay') return ClayIcon;
-  if (
-    platformName === 'macos' ||
-    platformName === 'macos-arm64' ||
-    platformName === 'macos-intel'
-  ) {
-    return MacosIcon;
-  }
-  if (platformName === 'web') return WebIcon;
-  if (platformName === 'windows') return WindowsIcon;
-
+  // macOS variant ids aren't in BCD.PlatformName and don't map to a table key.
+  if (
+    platformName === 'macos' ||
+    platformName === 'macos-arm64' ||
+    platformName === 'macos-intel'
+  ) {
+    return MacosIcon;
+  }
   // BCD-known platform names route through compat-table's mapping so we stay
   // consistent with the APITable headers (clay_macos → macos-text etc.).
   const iconName = mapPlatformNameToIconName(platformName as PlatformName);
   return ICON_NAME_TO_URL[iconName] ?? ClayIcon;
 };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/platform-navigation/PlatformIcon.tsx` around lines 29 - 46,
The toIconUrl function has redundant explicit branches for 'clay', 'web', and
'windows' because mapPlatformNameToIconName returns its input by default and
ICON_NAME_TO_URL already covers those names; remove the explicit checks for
'clay', 'web', and 'windows' and let the iconName =
mapPlatformNameToIconName(platformName as PlatformName) →
ICON_NAME_TO_URL[iconName] ?? ClayIcon path handle them, while preserving the
special-case branch that consolidates 'macos'/'macos-arm64'/'macos-intel' to
return MacosIcon; keep the final fallback to ClayIcon intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/home-comps/features/index.module.less`:
- Around line 38-41: The Stylelint rule wants a blank line before the `color`
declaration in the `.platform-icon` block; update the `.platform-icon` rule in
index.module.less (the block containing `--icon-size` and `color`) by inserting
a single empty line between the `--icon-size: 18px;` custom property and the
`color: var(--home-blog-btn-color);` declaration so the
`declaration-empty-line-before` rule is satisfied.

---

Outside diff comments:
In `@src/components/platform-navigation/PlatformIcon.tsx`:
- Around line 70-106: toPlatformName currently maps macos, macos-arm64,
macos-intel to 'ios', causing PlatformIcon -> PlatformSvg to render the wrong
Apple iOS icon; update toPlatformName so macos* values map to a
macOS-identifying value that toIconUrl/PlatformSvg recognize (e.g., return
'macos' for 'macos', 'macos-arm64', 'macos-intel'), and keep ios-simulator
handled explicitly (either map 'ios-simulator' to 'ios-simulator' or to 'ios'
depending on how toIconUrl expects it) so PlatformIcon/PlatformSvg render the
correct macOS and iOS simulator icons.

---

Nitpick comments:
In `@src/components/platform-navigation/PlatformIcon.tsx`:
- Around line 29-46: The toIconUrl function has redundant explicit branches for
'clay', 'web', and 'windows' because mapPlatformNameToIconName returns its input
by default and ICON_NAME_TO_URL already covers those names; remove the explicit
checks for 'clay', 'web', and 'windows' and let the iconName =
mapPlatformNameToIconName(platformName as PlatformName) →
ICON_NAME_TO_URL[iconName] ?? ClayIcon path handle them, while preserving the
special-case branch that consolidates 'macos'/'macos-arm64'/'macos-intel' to
return MacosIcon; keep the final fallback to ClayIcon intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aed8d0e7-b4c5-4742-b9f4-4e6d11d6afa2

📥 Commits

Reviewing files that changed from the base of the PR and between 3e0cb7e and 3069377.

📒 Files selected for processing (4)
  • src/components/api-status/constants.tsx
  • src/components/home-comps/features/icon.tsx
  • src/components/home-comps/features/index.module.less
  • src/components/platform-navigation/PlatformIcon.tsx

Comment thread src/components/home-comps/features/index.module.less
Huxpro added 4 commits June 3, 2026 11:27
…rmSvg

Platform icons used to live in three places with three different rendering
strategies: SVGR `?react` imports with `fill` overrides on the homepage,
inline JSX SVGs with `currentColor` in api-status, and mask-image with
currentColor in PlatformIcon. APITable already used mask-image from the
compat-table icon set.

Consolidate around the compat-table set as the canonical icon source and
route every consumer through `<PlatformSvg />`:

- `PlatformIcon.tsx`: drop the `@assets/home/*` imports, route through one
  `ICON_NAME_TO_URL` table backed by `compat-table/assets/icons/`. The
  mapping reuses compat-table's `mapPlatformNameToIconName` so the
  homepage and APITable stay in lockstep when new platforms are added.
- `home-comps/features/icon.tsx`: replace per-platform SVGR imports with
  thin `<PlatformSvg />` wrappers and a shared `.platform-icon` size class.
- `api-status/constants.tsx`: replace inline JSX SVGs and the
  `createMaskIcon` helper with a single `makeIcon(platformName)` factory
  that delegates to `<PlatformSvg />`.

Visible change: the homepage Android icon switches from the half-dome face
to the full Bugdroid body that APITable / APISummary already used, so the
two surfaces match.

Change-Id: I63a57690e19a7bedee6a6a8c0838a873668b73bd
All consumers route through PlatformSvg backed by the compat-table icon
set after the previous commit, so the home/ duplicates have no references
left. Removes home-icon-android.svg, home-icon-apple.svg,
home-icon-apple-dark.svg, home-icon-web.svg, plus the harmony/windows/clay
copies that lived in two places.

Change-Id: I477373262facabc57ce574b3a0e6c309bb0f1b00
Replace the full Bugdroid body with the half-dome face that the homepage
used to ship, retained as a single fill-rule="evenodd" path so the eyes
become cutouts in the silhouette. Because every consumer renders the
icon through mask-image + currentColor, the result is fully monochrome
and inherits whatever color the parent sets, so callers can recolor it
programmatically per surface (e.g. style={{ color }} or a scoped CSS
rule) when needed.

Change-Id: I666a542e9aa8005e804127a1851291e9206665c6
Drop the uniform dark-grey wash on the homepage feature card and tint
each platform icon with a hue that reads as native to the platform:
zinc for Apple (iOS / macOS), emerald for Android, rose for HarmonyOS,
orange for Web (HTML5), sky for Windows. All sit at Tailwind ~600 in
light mode and ~400 in dark mode so saturation and tonal weight stay
matched even though the hues span the wheel.

Change-Id: Id6ca10297a8e6b38092ac4b5faff55d70f3b40f8
@Huxpro Huxpro force-pushed the feat/unify-platform-icons branch from ae72f12 to fb6b699 Compare June 3, 2026 18:27
Change-Id: I0273c96570f5ac0df26d29521fe26e7a4544e31e
@Huxpro Huxpro merged commit 9df7f70 into main Jun 3, 2026
12 of 13 checks passed
@Huxpro Huxpro deleted the feat/unify-platform-icons branch June 3, 2026 18:58
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.

2 participants