Skip to content

Scale CTALinkOrButton chevron with size prop#2423

Merged
Will-Howard merged 1 commit into
masterfrom
wh-cta-chevron-size-2026-05
May 6, 2026
Merged

Scale CTALinkOrButton chevron with size prop#2423
Will-Howard merged 1 commit into
masterfrom
wh-cta-chevron-size-2026-05

Conversation

@Will-Howard

@Will-Howard Will-Howard commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Description

The chevron rendered by withChevron / withBackChevron was hardcoded to size-2 (8px), which looks fine on the default medium CTA but too small next to a size="large" hero CTA.

(Noticed while reviewing #2417)

Issue

N/A

Developer checklist

@render render Bot temporarily deployed to wh-cta-chevron-size-2026-05 - bluedot-preview PR #2423 May 6, 2026 08:31 Destroyed
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Will-Howard has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 8 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6d7bb0a7-be51-4907-bb9a-f98d5ddee477

📥 Commits

Reviewing files that changed from the base of the PR and between c27f558 and 68e9ffb.

📒 Files selected for processing (3)
  • libraries/ui/src/CTALinkOrButton.stories.tsx
  • libraries/ui/src/CTALinkOrButton.test.tsx
  • libraries/ui/src/CTALinkOrButton.tsx
📝 Walkthrough

Walkthrough

This pull request introduces dynamic chevron sizing to the CTALinkOrButton component. A new internal constant CTA_CHEVRON_SIZE_STYLES maps size variants to chevron icon size classes, replacing hard-coded chevron sizes. The changes include updates to both forward and back chevron rendering logic, a new "LargeWithChevron" story example, and a test case verifying that chevron icons scale correctly across small, medium, and large button sizes.

Possibly related PRs

  • bluedotimpact/bluedot#2373: Modifies CTALinkOrButton component's size-related functionality, introducing size-aware styling for chevron icons
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and concisely summarises the main change: making the chevron icon scale dynamically based on the button size prop.
Description check ✅ Passed The description covers the motivation, explains the problem, documents the solution, and confirms the developer checklist items; all required sections are addressed.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wh-cta-chevron-size-2026-05

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.

@greptile-apps

greptile-apps Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes the hardcoded size-2 chevron in CTALinkOrButton so it scales with the size prop — large now renders a size-3 chevron while small and medium remain on size-2, preserving all existing visual output.

  • Introduces CTA_CHEVRON_SIZE_STYLES lookup table and applies it to both FaChevronLeft and FaChevronRight via cn.
  • Adds a re-render test covering all three sizes and a LargeWithChevron Storybook story.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to chevron icon sizing and does not affect any existing visual output.

All three size keys are covered in the new lookup table, the default size (medium) maps to the same class as before, tests verify each size variant, and the Storybook story covers the new large case. No existing callers combine size=large with a chevron, so there is no risk of unintended visual regression.

No files require special attention.

Important Files Changed

Filename Overview
libraries/ui/src/CTALinkOrButton.tsx Adds CTA_CHEVRON_SIZE_STYLES lookup and wires it into both chevron icons; small/medium keep size-2, large gets size-3. All size keys are covered, default remains medium.
libraries/ui/src/CTALinkOrButton.test.tsx Adds a test that re-renders across all three sizes and asserts the correct Tailwind size class on the chevron icon element.
libraries/ui/src/CTALinkOrButton.stories.tsx Adds a LargeWithChevron Storybook story to visually verify the new large-chevron size.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[CTALinkOrButton\nsize prop] --> B{CTA_CHEVRON_SIZE_STYLES lookup}
    B -->|small| C[size-2 — 8px]
    B -->|medium| C
    B -->|large| D[size-3 — 12px]
    C --> E[FaChevronLeft / FaChevronRight\ncn className]
    D --> E
Loading

Reviews (1): Last reviewed commit: "Scale CTALinkOrButton chevron with size ..." | Re-trigger Greptile

The chevron rendered by withChevron / withBackChevron was hardcoded to
size-2 (8px), which looks fine at the default medium size but appears
tiny next to a size="large" hero CTA. Map the chevron size to the CTA
size so large gets size-3 (12px). Small and medium are unchanged, so no
existing usage shifts visually.
@Will-Howard Will-Howard force-pushed the wh-cta-chevron-size-2026-05 branch from c27f558 to 68e9ffb Compare May 6, 2026 08:34
@render render Bot temporarily deployed to wh-cta-chevron-size-2026-05 - bluedot-preview PR #2423 May 6, 2026 08:34 Destroyed

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

🧹 Nitpick comments (1)
libraries/ui/src/CTALinkOrButton.test.tsx (1)

127-134: ⚡ Quick win

Optional: assert element existence before accessing className for a clearer failure message.

If the chevron icon element is ever not rendered, ?.className silently produces undefined, and the assertion error reads expected undefined to include 'size-2' — harder to diagnose than a dedicated existence check.

♻️ Proposed refactor
  test('chevron scales with size', () => {
    const { rerender } = render(<CTALinkOrButton size="small" withChevron>Click me</CTALinkOrButton>);
-   expect(document.querySelector('.cta-button__chevron-icon')?.className).includes('size-2');
+   const getIcon = () => document.querySelector('.cta-button__chevron-icon');
+   expect(getIcon()).toBeTruthy();
+   expect(getIcon()!.className).includes('size-2');
    rerender(<CTALinkOrButton size="medium" withChevron>Click me</CTALinkOrButton>);
-   expect(document.querySelector('.cta-button__chevron-icon')?.className).includes('size-2');
+   expect(getIcon()!.className).includes('size-2');
    rerender(<CTALinkOrButton size="large" withChevron>Click me</CTALinkOrButton>);
-   expect(document.querySelector('.cta-button__chevron-icon')?.className).includes('size-3');
+   expect(getIcon()!.className).includes('size-3');
  });
🤖 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 `@libraries/ui/src/CTALinkOrButton.test.tsx` around lines 127 - 134, The test
'chevron scales with size' accesses
document.querySelector('.cta-button__chevron-icon')?.className without
confirming the element exists; update the assertions to first select the chevron
element (using querySelector/getByRole/getByTestId) and assert its presence
(e.g., expect(el).toBeTruthy() or toBeInTheDocument()) before checking its
className includes the expected size, so each rerender uses a non-null element
when verifying sizes for CTALinkOrButton.
🤖 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 `@libraries/ui/src/CTALinkOrButton.test.tsx`:
- Around line 127-134: The test 'chevron scales with size' accesses
document.querySelector('.cta-button__chevron-icon')?.className without
confirming the element exists; update the assertions to first select the chevron
element (using querySelector/getByRole/getByTestId) and assert its presence
(e.g., expect(el).toBeTruthy() or toBeInTheDocument()) before checking its
className includes the expected size, so each rerender uses a non-null element
when verifying sizes for CTALinkOrButton.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 27e8aaa7-c7e5-400a-b02f-e16474112c31

📥 Commits

Reviewing files that changed from the base of the PR and between 787056b and c27f558.

📒 Files selected for processing (3)
  • libraries/ui/src/CTALinkOrButton.stories.tsx
  • libraries/ui/src/CTALinkOrButton.test.tsx
  • libraries/ui/src/CTALinkOrButton.tsx

@Will-Howard Will-Howard merged commit b1063a6 into master May 6, 2026
8 checks passed
@Will-Howard Will-Howard deleted the wh-cta-chevron-size-2026-05 branch May 6, 2026 08:37
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