Skip to content

Hero banner: move heading copy to configurable text in hero banner JSON#3335

Merged
tom2drum merged 2 commits intomainfrom
tom2drum/issue-3290
Apr 2, 2026
Merged

Hero banner: move heading copy to configurable text in hero banner JSON#3335
tom2drum merged 2 commits intomainfrom
tom2drum/issue-3290

Conversation

@tom2drum
Copy link
Copy Markdown
Collaborator

@tom2drum tom2drum commented Apr 2, 2026

Description and Related Issue(s)

Resolves #3290

The hero banner heading was always derived from the chain name plus a fixed "explorer" / "blockchain explorer" suffix. This change adds an optional text field to the existing NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG JSON so deployments can override the full heading string for richer customization, while preserving the previous default when text is omitted.

Proposed Changes

  • Add optional text to HeroBannerConfig and validate it in the envs validator.
  • In HeroBanner.tsx, use config.UI.homepage.heroBanner?.text when set; otherwise keep the same defaults as before ({chain} explorer vs {chain} blockchain explorer when SEO enhanced data is enabled).
  • In deploy/scripts/og_image_generator.js, use bannerConfig.text for the OG title when present so Open Graph previews match the customized heading.
  • Update Playwright coverage and screenshots for the customized banner text case.
  • Document the new text field in docs/ENVS.md (hero banner config table).

Environment variable changes

  • Extended NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG: added optional nested field text (string). When set, it replaces the default hero heading (and the OG generator uses it for the title). When omitted, behavior matches the previous hardcoded {network} explorer / {network} blockchain explorer logic.

Breaking or Incompatible Changes

None. Existing configs without text behave as before.

Additional Information

Issue reference: Hero banner: move 'explorer' to new ENV.

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added a feature or functionality that is not privacy-compliant (e.g., tracking, analytics, third-party services), I have disabled it for private mode.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

@tom2drum tom2drum added the ENVs label Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 2, 2026

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include @coderabbitai review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9fd70f3c-e70a-4045-8080-a9115e0deb54

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (1)
docs/ENVS.md (1)

151-156: ⚠️ Potential issue | 🟡 Minor

Doc table now conflicts with its own note and fallback behavior.

Line 151 says all hero banner properties are arrays, but Line 155 introduces text as a scalar string. Also, the default should mention both runtime fallbacks ({ chain_name } explorer and { chain_name } blockchain explorer when SEO enhanced data is enabled).

📝 Suggested doc fix
-_Note_ Here, all values are arrays of up to two strings. The first string represents the value for the light color mode, and the second string represents the value for the dark color mode. If the array contains only one string, it will be used for both color modes.
+_Note_ Most values below are arrays of up to two strings for light/dark modes. The `text` property is a plain string.

-| text | `string` | The text on the banner | - | `{ chain_name } explorer` | `Duck migration observer` |
+| text | `string` | The text on the banner | - | `{ chain_name } explorer` (or `{ chain_name } blockchain explorer` when `NEXT_PUBLIC_SEO_ENHANCED_DATA_ENABLED=true`) | `Duck migration observer` |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/ENVS.md` around lines 151 - 156, Update the docs to make the hero banner
schema consistent with the note and fallback behavior: change the "text" row to
indicate it accepts either `string` or `[string]` (or explicitly state "string
or array of up to two strings") to match the note about arrays, clarify that all
banner properties (e.g., `text`, `background`) can be an array of up to two
strings, and update the "Default value" for `text` to show both runtime
fallbacks (`{ chain_name } explorer` and `{ chain_name } blockchain explorer`
when SEO enhanced data is enabled) so the table and the preceding note are
aligned.
🧹 Nitpick comments (1)
ui/home/HeroBanner.pw.tsx (1)

27-27: Extract the hero banner ENV payload into a reusable mock fixture.

The long inline JSON at Line 27 hurts readability and reuse in Playwright tests. Please move it to a mocks/ export and import it here.

Based on learnings: Applies to **/*.pw.tsx : In Playwright tests, import mock values from existing files in mocks/ rather than hardcoding them.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/home/HeroBanner.pw.tsx` at line 27, Replace the long inline JSON ENV
payload used in HeroBanner.pw.tsx with a reusable mock export: create or update
a mocks file (e.g., export const HERO_BANNER_MOCK = {...}) that contains the
JSON for NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG and then import that mock into
HeroBanner.pw.tsx and use it where the inline array/object is currently
provided; update the test to reference the imported HERO_BANNER_MOCK instead of
the hardcoded string so other Playwright tests under *.pw.tsx can reuse the same
fixture.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@deploy/scripts/og_image_generator.js`:
- Line 26: The title assignment uses the logical OR which treats an explicit
empty string as falsy; change the fallback logic in the title expression so it
uses nullish coalescing (referencing bannerConfig.text and the title property) —
replace the `||` fallback with `??` so an explicitly provided empty string is
preserved and the environment-based default `${
process.env.NEXT_PUBLIC_NETWORK_NAME } explorer` is only used when
bannerConfig.text is null or undefined.

In `@deploy/tools/envs-validator/test/.env.multichain`:
- Line 13: The env value for NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG is not
quoted and triggers dotenv/lint warnings; wrap the entire JSON-like value in
quotes (use single quotes to follow repo convention) so the line becomes
NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG='{"background":[...],"text_color":[...],"text":"..."}'—ensure
you preserve the inner JSON structure and single-quote the whole value for
consistent parsing and linting.

In `@ui/home/HeroBanner.tsx`:
- Around line 52-60: The current IIFE for const text treats an empty string as
absent; replace the IIFE with a nullish-coalescing expression so an explicitly
provided value (including empty string) is preserved: use
config.UI.homepage.heroBanner?.text ?? (config.meta.seo.enhancedDataEnabled ?
`${config.chain.name} blockchain explorer` : `${config.chain.name} explorer`) to
compute text, referencing the existing config.UI.homepage.heroBanner?.text,
config.meta.seo.enhancedDataEnabled and config.chain.name symbols.

---

Outside diff comments:
In `@docs/ENVS.md`:
- Around line 151-156: Update the docs to make the hero banner schema consistent
with the note and fallback behavior: change the "text" row to indicate it
accepts either `string` or `[string]` (or explicitly state "string or array of
up to two strings") to match the note about arrays, clarify that all banner
properties (e.g., `text`, `background`) can be an array of up to two strings,
and update the "Default value" for `text` to show both runtime fallbacks (`{
chain_name } explorer` and `{ chain_name } blockchain explorer` when SEO
enhanced data is enabled) so the table and the preceding note are aligned.

---

Nitpick comments:
In `@ui/home/HeroBanner.pw.tsx`:
- Line 27: Replace the long inline JSON ENV payload used in HeroBanner.pw.tsx
with a reusable mock export: create or update a mocks file (e.g., export const
HERO_BANNER_MOCK = {...}) that contains the JSON for
NEXT_PUBLIC_HOMEPAGE_HERO_BANNER_CONFIG and then import that mock into
HeroBanner.pw.tsx and use it where the inline array/object is currently
provided; update the test to reference the imported HERO_BANNER_MOCK instead of
the hardcoded string so other Playwright tests under *.pw.tsx can reuse the same
fixture.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: beba6fd9-22a1-4f63-a2e1-a76e156f8967

📥 Commits

Reviewing files that changed from the base of the PR and between 2d9c87f and 5be1c6f.

⛔ Files ignored due to path filters (2)
  • ui/home/__screenshots__/HeroBanner.pw.tsx_dark-color-mode_customization-dark-mode-1.png is excluded by !**/*.png
  • ui/home/__screenshots__/HeroBanner.pw.tsx_default_customization-dark-mode-1.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • deploy/scripts/og_image_generator.js
  • deploy/tools/envs-validator/schemas/ui.ts
  • deploy/tools/envs-validator/test/.env.multichain
  • docs/ENVS.md
  • types/homepage.ts
  • ui/home/HeroBanner.pw.tsx
  • ui/home/HeroBanner.tsx

Comment thread deploy/scripts/og_image_generator.js
Comment thread deploy/tools/envs-validator/test/.env.multichain
Comment thread ui/home/HeroBanner.tsx
@tom2drum tom2drum merged commit 829141d into main Apr 2, 2026
2 checks passed
@tom2drum tom2drum deleted the tom2drum/issue-3290 branch April 2, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hero banner: move 'explorer' to new ENV

1 participant