refactor(widget): align theme variant defaults#534
Conversation
Move the Utila and Porto palettes into the base light and dark theme tokens. Expose variant override resolution so theme behavior has direct coverage. Apply dashboard variant styling branches and keep RWA yields first in sorting.
|
📝 WalkthroughWalkthroughThis PR refactors the widget's theme system to support a new ChangesDashboard Variant & Theme Refactor
🎯 4 (Complex) | ⏱️ ~50 minutes Possibly Related PRs
Suggested Reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
There was a problem hiding this comment.
🧹 Nitpick comments (4)
packages/widget/src/pages/details/details-page/styles.css.ts (1)
39-51: Use ofbackground: "text"fortabBorderis consistent with an active-tab underline; only rename for clarityIn
packages/widget/src/pages/details/details-page/components/tab.tsx, thetabBorderelement renders only whenisSelectedistrue, so using the semantic foregroundtexttoken for the underline matches the active tab’s text styling intent. Since the underline no longer uses thetabBordercolor token, consider renaming the style export/class to something likeactiveTabIndicatorto avoid confusion.🤖 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/details/details-page/styles.css.ts` around lines 39 - 51, The export name tabBorder is misleading since it represents the active-tab underline rendered only when isSelected; rename the style export (e.g., to activeTabIndicator) and update all references (notably the usage in the Tab component in details-page/components/tab.tsx) to the new identifier so the semantic purpose is clear—keep the style body unchanged, just change the exported constant name and any imports/usages accordingly.packages/widget/tests/providers/theme-wrapper.test.ts (1)
7-34: ⚡ Quick winAdd direct test coverage for the
fineryoverride branch.Current coverage skips the only variant path with computed logic, so dark/light finery palette regressions can pass unnoticed.
Proposed test addition
import { portoThemeOverrides } from "../../src/styles/theme/variant-overrides/porto"; import { utilaThemeOverrides } from "../../src/styles/theme/variant-overrides/utila"; +import { + fineryDarkPalette, + fineryLightPalette, +} from "../../src/styles/theme/variant-overrides/palettes"; describe("getThemeOverrides", () => { @@ it("keeps the explicit Utila variant override", () => { @@ }); + + it("uses finery dark palette when base theme is dark-like", () => { + const overrides = getThemeOverrides({ + baseTheme: darkTheme, + variant: "finery", + }); + + expect(overrides.color?.background).toBe(fineryDarkPalette.greyOne); + }); + + it("uses finery light palette when base theme is light-like", () => { + const overrides = getThemeOverrides({ + baseTheme: lightTheme, + variant: "finery", + }); + + expect(overrides.color?.background).toBe(fineryLightPalette.greyOne); + }); });🤖 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/tests/providers/theme-wrapper.test.ts` around lines 7 - 34, Add tests for the "finery" branch of getThemeOverrides by invoking getThemeOverrides({ baseTheme: lightTheme, variant: "finery" }) and getThemeOverrides({ baseTheme: darkTheme, variant: "finery" }) and asserting the returned overrides match the expected finery palettes (or saved snapshots) to cover the computed logic path; place these cases inside the existing describe("getThemeOverrides") block and reference getThemeOverrides, "finery", lightTheme and darkTheme so regressions in finery palette computation are caught.packages/widget/src/styles/tokens/colors/values.ts (2)
126-196: ⚡ Quick winConsider extracting hardcoded hex values to
primitiveColorsfor consistency.Multiple new color values (e.g.,
"#4A60FF","#f5f5f6","#C9CFFF") are hardcoded in the theme objects. The file already establishes a pattern of defining primitive colors in theprimitiveColorsobject (lines 5-46) and referencing them in theme definitions. Extracting these values would improve maintainability and make color updates easier to track.♻️ Example refactor pattern
const primitiveColors = { // ... existing colors blue: { + 400: "`#4A60FF`", }, + gray: { + 50: "`#f5f5f6`", + }, + lavender: { + 300: "`#C9CFFF`", + }, } as const;Then reference via
primitiveColors.blue[400]instead of"#4A60FF".🤖 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/styles/tokens/colors/values.ts` around lines 126 - 196, Several hardcoded hex values in the theme object (e.g., accent, tokenSelectBackground, tokenSelectBorder, primaryButtonBackground, tokenSelectHover, dashboardDetailsSectionBackground, etc.) should be extracted into the existing primitiveColors palette and then referenced from values.ts; update primitiveColors with named entries (e.g., blue.400, gray.100, lilac.200) and replace literals in the theme keys (accent, primaryButtonBackground, tokenSelectBackground, tokenSelectBorder, backgroundMuted, dashboardDetailsSectionBackground, summaryItemBackground, smallLightButtonBackground, etc.) to use primitiveColors.<name> so all colors follow the established pattern and maintain consistency with the rest of the file.
202-273: ⚡ Quick winConsider extracting hardcoded hex values to
primitiveColorsfor consistency.Same pattern as light theme: multiple hardcoded hex values (e.g.,
"#171717","#AB95FF","#87899C","#282828","#333333") should be extracted to theprimitiveColorsobject for consistency with the existing pattern and to improve maintainability.🤖 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/styles/tokens/colors/values.ts` around lines 202 - 273, Replace the hardcoded hex literals in this dark color values object with references to the existing primitiveColors constants to match the light theme pattern: replace values for keys such as primary, accent, textMuted, tokenSelectBackground, tokenSelectHoverBackground, tokenSelectBorder, backgroundMuted, tabBorder, skeletonLoaderBase, skeletonLoaderHighlight, warningBoxBackground (if applicable), stakeSectionBackground, dropdownBackground, tooltipBackground, primaryButtonBackground, smallButtonBackground, smallLightButtonBackground, and summary* backgrounds/colors with primitiveColors entries instead of inline hex strings; update connectKit.profileAction/profileActionHover/modalBackground/profileForeground to use primitiveColors or vars.color aliases where appropriate so all hexes like "`#171717`", "`#AB95FF`", "`#87899C`", "`#282828`", "`#333333`" are centralized in primitiveColors and referenced here (keep keys such as primary, accent, tokenSelect, connectKit, modalBodyBackground, etc., unchanged).
🤖 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/details/details-page/styles.css.ts`:
- Around line 39-51: The export name tabBorder is misleading since it represents
the active-tab underline rendered only when isSelected; rename the style export
(e.g., to activeTabIndicator) and update all references (notably the usage in
the Tab component in details-page/components/tab.tsx) to the new identifier so
the semantic purpose is clear—keep the style body unchanged, just change the
exported constant name and any imports/usages accordingly.
In `@packages/widget/src/styles/tokens/colors/values.ts`:
- Around line 126-196: Several hardcoded hex values in the theme object (e.g.,
accent, tokenSelectBackground, tokenSelectBorder, primaryButtonBackground,
tokenSelectHover, dashboardDetailsSectionBackground, etc.) should be extracted
into the existing primitiveColors palette and then referenced from values.ts;
update primitiveColors with named entries (e.g., blue.400, gray.100, lilac.200)
and replace literals in the theme keys (accent, primaryButtonBackground,
tokenSelectBackground, tokenSelectBorder, backgroundMuted,
dashboardDetailsSectionBackground, summaryItemBackground,
smallLightButtonBackground, etc.) to use primitiveColors.<name> so all colors
follow the established pattern and maintain consistency with the rest of the
file.
- Around line 202-273: Replace the hardcoded hex literals in this dark color
values object with references to the existing primitiveColors constants to match
the light theme pattern: replace values for keys such as primary, accent,
textMuted, tokenSelectBackground, tokenSelectHoverBackground, tokenSelectBorder,
backgroundMuted, tabBorder, skeletonLoaderBase, skeletonLoaderHighlight,
warningBoxBackground (if applicable), stakeSectionBackground,
dropdownBackground, tooltipBackground, primaryButtonBackground,
smallButtonBackground, smallLightButtonBackground, and summary*
backgrounds/colors with primitiveColors entries instead of inline hex strings;
update
connectKit.profileAction/profileActionHover/modalBackground/profileForeground to
use primitiveColors or vars.color aliases where appropriate so all hexes like
"`#171717`", "`#AB95FF`", "`#87899C`", "`#282828`", "`#333333`" are centralized in
primitiveColors and referenced here (keep keys such as primary, accent,
tokenSelect, connectKit, modalBodyBackground, etc., unchanged).
In `@packages/widget/tests/providers/theme-wrapper.test.ts`:
- Around line 7-34: Add tests for the "finery" branch of getThemeOverrides by
invoking getThemeOverrides({ baseTheme: lightTheme, variant: "finery" }) and
getThemeOverrides({ baseTheme: darkTheme, variant: "finery" }) and asserting the
returned overrides match the expected finery palettes (or saved snapshots) to
cover the computed logic path; place these cases inside the existing
describe("getThemeOverrides") block and reference getThemeOverrides, "finery",
lightTheme and darkTheme so regressions in finery palette computation are
caught.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7f2bab15-a9ba-4371-a7b8-1a604d1d2b8f
📒 Files selected for processing (35)
packages/widget/src/components/atoms/button/styles.css.tspackages/widget/src/components/atoms/divider/styles.css.tspackages/widget/src/components/atoms/max-button/styles.css.tspackages/widget/src/components/atoms/select-modal/styles.css.tspackages/widget/src/components/molecules/chain-modal/index.tsxpackages/widget/src/components/molecules/estimated-reward-amounts/index.tsxpackages/widget/src/components/molecules/summary-item/index.css.tspackages/widget/src/domain/types/yields.tspackages/widget/src/main.tsxpackages/widget/src/pages-dashboard/common/components/styles.css.tspackages/widget/src/pages-dashboard/common/components/tabs/styles.css.tspackages/widget/src/pages-dashboard/overview/earn-page/index.tsxpackages/widget/src/pages-dashboard/overview/earn-page/styles.css.tspackages/widget/src/pages-dashboard/overview/positions/styles.css.tspackages/widget/src/pages/components/page-cta.tsxpackages/widget/src/pages/components/powered-by/index.tsxpackages/widget/src/pages/details/activity-page/components/activity-filters/index.tsxpackages/widget/src/pages/details/activity-page/components/activity-filters/styles.css.tspackages/widget/src/pages/details/details-page/styles.css.tspackages/widget/src/pages/details/earn-page/components/select-token-section/styles.css.tspackages/widget/src/pages/details/earn-page/components/select-yield-section/index.tsxpackages/widget/src/pages/details/earn-page/components/select-yield-section/select-yield-reward-details.tsxpackages/widget/src/pages/details/earn-page/components/select-yield-section/styles.css.tspackages/widget/src/pages/details/earn-page/state/earn-page-context.tsxpackages/widget/src/pages/position-details/components/amount-block.tsxpackages/widget/src/providers/theme-wrapper.tsxpackages/widget/src/standalone.css.tspackages/widget/src/styles/theme/variant-overrides/finery.tspackages/widget/src/styles/theme/variant-overrides/porto.tspackages/widget/src/styles/theme/variant-overrides/utila.tspackages/widget/src/styles/tokens/colors/contract.tspackages/widget/src/styles/tokens/colors/values.tspackages/widget/src/vite-env.d.tspackages/widget/tests/domain/dashboard-yield-category-types.test.tspackages/widget/tests/providers/theme-wrapper.test.ts


Move the Utila and Porto palettes into the base light and dark theme tokens.
Expose variant override resolution so theme behavior has direct coverage.
Apply dashboard variant styling branches and keep RWA yields first in sorting.
Added
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
Bug Fixes
Style Updates
Tests