Skip to content

fix(widget): clean up icon fallbacks and pending action labels#531

Open
sandy-yield wants to merge 1 commit into
mainfrom
fix/widget-dashboard-position-fallback-icons
Open

fix(widget): clean up icon fallbacks and pending action labels#531
sandy-yield wants to merge 1 commit into
mainfrom
fix/widget-dashboard-position-fallback-icons

Conversation

@sandy-yield

@sandy-yield sandy-yield commented Jun 9, 2026

Copy link
Copy Markdown

BEFORE:
image

AFTER:
image

  • Render a grey circle with the chain initial when a network logo is missing or fails to load, on a white badge so dark chain logos (e.g. Ethereum) stay visible.
  • Use a white background with black text for the token icon monogram fallback.
  • Humanize unmapped pending action types (e.g. RWA actions) so the position details "Action required" card, action button, and review heading never render raw translation keys.

Added

Description of new functionality, feature, or content that has been added in this pull request.

Changed

Description of the modifications made to existing functionality, feature, or content in this pull request. This could include changes to code, CI, documentation, etc.

Summary by CodeRabbit

  • New Features

    • Added fallback UI for network logos that fail to load—displays network initials as a placeholder.
    • Improved pending action type display with automatic fallback formatting when translations are unavailable.
  • Style

    • Updated network icon styling with white background, adjusted padding, and subtle shadow effect.

- Render a grey circle with the chain initial when a network logo is
  missing or fails to load, on a white badge so dark chain logos (e.g.
  Ethereum) stay visible.
- Use a white background with black text for the token icon monogram
  fallback.
- Humanize unmapped pending action types (e.g. RWA actions) so the
  position details "Action required" card, action button, and review
  heading never render raw translation keys.
@changeset-bot

changeset-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ebe34bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces two independent features: a network logo image fallback system that displays chain initials when logo images fail to load, and a pending action type humanization utility that provides readable i18n defaults when translation keys are missing.

Changes

Network Logo Fallback System

Layer / File(s) Summary
Network logo image component refactor and fallback rendering
packages/widget/src/components/atoms/token-icon/network-icon-image/index.tsx
NetworkLogoImage transitions from stateless to stateful using useState to track image load errors. Conditionally renders ChainInitial fallback when networkLogoUri is empty or errored; otherwise renders the image with onError handler for failure detection.
Container style refactor for logo and fallback
packages/widget/src/components/atoms/token-icon/network-icon-image/style.css.ts
Shared baseContainer style introduced for positioning and centering. logoContainer updated to white background (#ffffff) with subtle box shadow ring and 3px padding. fallbackContainer updated to gray background (#9ca3af).
Network name prop wiring to logo consumers
packages/widget/src/components/atoms/token-icon/index.tsx, packages/widget/src/components/atoms/token-icon/provider-icon/index.tsx
TokenIcon and ProviderIcon now pass networkName derived from token.network to NetworkLogoImage, enabling fallback initial character rendering.
Monogram SVG styling simplification
packages/widget/src/components/atoms/image/index.tsx
getBackgroundColor import removed; monogram SVG generation replaced with fixed white circle and light gray stroke instead of dynamic background color calculation.

Pending Action Type Humanization

Layer / File(s) Summary
Humanize pending action type formatter
packages/widget/src/utils/formatters.ts
New humanizePendingActionType utility converts underscore-delimited API action types to human-readable title-cased strings for use as i18n default fallback.
Position details pending action humanization
packages/widget/src/pages-dashboard/position-details/position-details-model.tsx, packages/widget/src/pages-dashboard/position-details/components/position-details-actions.tsx
New formatPendingActionLabel helper in position-details-model; getStatusSummary refactored to use it. Button label in position-details-actions updated to supply humanized pending action type as defaultValue.
Static action block pending action humanization
packages/widget/src/pages/position-details/components/static-action-block.tsx
"Available to" and button label translations updated to use humanizePendingActionType as defaultValue fallback for pending action i18n keys.
Reward token details pending action defaults
packages/widget/src/components/molecules/reward-token-details/index.tsx
Conditionally computes i18nDefaults for pending action types and passes to Trans component defaults prop for i18n fallback support.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • dnehl
  • jdomingos

A widget's logos now gracefully fade to initials,
Humanized text flows where translations fail,
The chain displays, the UI prevails! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description includes visual examples and bullet points summarizing the changes, but the template sections 'Added' and 'Changed' are largely empty. Fill in the 'Added' and 'Changed' sections with detailed descriptions of the new functionality and modifications made in this PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: cleaning up icon fallbacks and pending action labels, matching the PR objectives.
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 fix/widget-dashboard-position-fallback-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.

@aws-amplify-eu-central-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-531.d2ribjy8evqo6h.amplifyapp.com

@aws-amplify-eu-central-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-531.df4xyoi0xyeak.amplifyapp.com

@xhakti xhakti 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.

LGTM

@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.

🧹 Nitpick comments (1)
packages/widget/src/pages-dashboard/position-details/position-details-model.tsx (1)

632-641: Align pending-action label fallback with humanizePendingActionType (match existing files; it’s slightly more defensive).

formatEnumValue and humanizePendingActionType are equivalent for current pending-action strings (both split on _ and capitalize segments). The difference is humanizePendingActionType filters out empty segments (filter(Boolean)), which avoids odd spacing if the API ever includes double/trailing underscores.

🔄 Proposed fix to use consistent formatter
+import { humanizePendingActionType } from "../../utils/formatters";
 import {
   formatCooldownDays,
-  formatEnumValue,
   formatMinStake,
   formatNetworkName,
   formatOptionalDays,
   formatRewardClaiming,
   formatRewardRateLabel,
   formatRewardTokenLabel,
 } from "../overview/earn-details/earn-details-formatters";
 const formatPendingActionLabel = (
   type: YieldPendingActionDto["type"],
   t: TFunction
 ) =>
   t(`position_details.pending_action.${type.toLowerCase()}`, {
-    defaultValue: formatEnumValue(type),
+    defaultValue: humanizePendingActionType(type),
   });
🤖 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
`@packages/widget/src/pages-dashboard/position-details/position-details-model.tsx`
around lines 632 - 641, Replace the use of formatEnumValue in
formatPendingActionLabel with humanizePendingActionType so the fallback matches
other files and defensively filters out empty segments; update the import/usage
in the formatPendingActionLabel function (referencing
YieldPendingActionDto["type"], formatPendingActionLabel,
humanizePendingActionType, and formatEnumValue) so the t(...) defaultValue calls
humanizePendingActionType(type) instead of formatEnumValue(type).
🤖 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.

Nitpick comments:
In
`@packages/widget/src/pages-dashboard/position-details/position-details-model.tsx`:
- Around line 632-641: Replace the use of formatEnumValue in
formatPendingActionLabel with humanizePendingActionType so the fallback matches
other files and defensively filters out empty segments; update the import/usage
in the formatPendingActionLabel function (referencing
YieldPendingActionDto["type"], formatPendingActionLabel,
humanizePendingActionType, and formatEnumValue) so the t(...) defaultValue calls
humanizePendingActionType(type) instead of formatEnumValue(type).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2df8c815-e4db-4a91-9fa9-fa095d72599d

📥 Commits

Reviewing files that changed from the base of the PR and between 2468076 and ebe34bd.

📒 Files selected for processing (10)
  • packages/widget/src/components/atoms/image/index.tsx
  • packages/widget/src/components/atoms/token-icon/index.tsx
  • packages/widget/src/components/atoms/token-icon/network-icon-image/index.tsx
  • packages/widget/src/components/atoms/token-icon/network-icon-image/style.css.ts
  • packages/widget/src/components/atoms/token-icon/provider-icon/index.tsx
  • packages/widget/src/components/molecules/reward-token-details/index.tsx
  • packages/widget/src/pages-dashboard/position-details/components/position-details-actions.tsx
  • packages/widget/src/pages-dashboard/position-details/position-details-model.tsx
  • packages/widget/src/pages/position-details/components/static-action-block.tsx
  • packages/widget/src/utils/formatters.ts

const backgroundColor = getBackgroundColor(name);

const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100"><circle cx="50" cy="50" r="50" fill="${backgroundColor}" /><text x="50" y="50" fill="#FFFFFF" font-family="Arial, sans-serif" font-size="48" font-weight="700" text-anchor="middle" dominant-baseline="central">${initial}</text></svg>`;
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100"><circle cx="50" cy="50" r="49" fill="#FFFFFF" stroke="rgba(0,0,0,0.08)" stroke-width="2" /><text x="50" y="50" fill="#000000" font-family="Arial, sans-serif" font-size="48" font-weight="700" text-anchor="middle" dominant-baseline="central">${initial}</text></svg>`;

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.

hm, with this we have white fallbacks on white background. why not color backgrounds?

Comment on lines +18 to +31
const [erroredUri, setErroredUri] = useState<string | null>(null);

const hasError = erroredUri === networkLogoUri;

if (!networkLogoUri || hasError) {
const initial = networkName?.trim()?.[0]?.toUpperCase() ?? "?";

return (
<Box className={fallbackContainer} data-rk="token-network-logo-fallback">
<Box hw={tokenNetworkLogoHw} display="flex">
<ChainInitial initial={initial} />
</Box>
</Box>
);

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.

we already have image error handling with Image component
e.g. <Image fallbackName={networkName} />

Comment on lines +3 to +12
const baseContainer = {
position: "absolute",
bottom: -2,
right: -2,
borderRadius: "50%",
padding: "4px",
backgroundColor: "rgba(37,37,37, 0.95)",
padding: "3px",
display: "flex",
alignItems: "center",
justifyContent: "center",
} as const;

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.

this loses style type safety. compose styles with style utility. e.g.

const base = style({ padding: 12 });

const primary = style([base, { background: 'blue' }]);

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.

3 participants