Skip to content

Add global button border-radius control to Style Cards#6152

Open
kyrapieterse wants to merge 3 commits intomasterfrom
codex/implement-global-border-radius-control
Open

Add global button border-radius control to Style Cards#6152
kyrapieterse wants to merge 3 commits intomasterfrom
codex/implement-global-border-radius-control

Conversation

@kyrapieterse
Copy link
Copy Markdown
Contributor

@kyrapieterse kyrapieterse commented Jan 7, 2026

Motivation

  • Provide a single global control to set button border radius across all style cards to improve design consistency.
  • Avoid the need to set radius per-button or rely on custom CSS site-wide.
  • Ensure the global setting can override individual button styles when enabled.

Description

  • Add new defaults border-radius-general and border-radius-global to the style card JSON for button groups (light/dark) in core/defaults/defaultSC.json.
  • Add editor UI controls (toggle and numeric input) to the Button globals panel in src/editor/style-cards/maxiStyleCardsTab.js to set and enable the global radius.
  • Extend variable extraction in src/extensions/style-cards/getSCVariablesObject.js to emit --maxi-<style>-button-border-radius-general (value in px) and a --maxi-<style>-button-border-radius-global flag when applicable.
  • Update style generation in src/extensions/style-cards/getSCStyles.js to apply border-radius: var(--maxi-<style>-button-border-radius-general) !important to both Maxi button blocks and native .wp-element-button when the global toggle is active.

Testing

  • No automated tests were executed as part of this change.
  • Existing test suites were not modified by this PR.

fixes #5236

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Adds button border-radius support: new default properties, editor controls to toggle/set a global/general radius, and style-generation logic that emits CSS/custom properties to apply the radius to Maxi and WordPress-native buttons.

Changes

Cohort / File(s) Summary
Configuration Defaults
core/defaults/defaultSC.json
Adds border-radius-global (boolean, default false) and border-radius-general (numeric, default 0) to Maxi Default button settings for dark and light themes
Editor UI Controls
src/editor/style-cards/maxiStyleCardsTab.js
When groupAttr === "button" and breakpoint is general, renders a ToggleSwitch (border-radius-global) and AdvancedNumberControl (border-radius-general); derives borderRadiusGlobal and borderRadiusValue and updates via onChangeValue
Style Variables
src/extensions/style-cards/getSCVariablesObject.js
In the button case, emits CSS variables --maxi-{style}-button-border-radius-general: <value>px and --maxi-{style}-button-border-radius-global: 1 when values are valid
CSS Generation / Styles
src/extensions/style-cards/getSCStyles.js
getMaxiSCStyles now accepts styleCard; when global flag and general value exist, appends border-radius: var(--maxi-...-border-radius-general) !important; rules for Maxi button selectors and WP-native button/post-comments-form submit input

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Editor as Editor UI
  participant Store as SC Variables Store
  participant Generator as Style Generator
  participant Browser as Runtime CSS

  Editor->>Store: toggle `border-radius-global` / set `border-radius-general`
  Store-->>Editor: acknowledge updated values (CSS vars)
  Store->>Generator: supply styleCard + variables for generation
  Generator->>Browser: emit CSS rules using vars (Maxi & WP-native selectors) with !important
  Browser->>Browser: apply border-radius to targeted button elements
  note right of Generator `#DDEBF7`: Conditional: only when global flag && general value present
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Issue 5869 #5914 — Touches style-cards UI logic; likely related to the editor/style-card attribute handling changes.

Suggested labels

🌟 enhancement, size:M

Suggested reviewers

  • elzadj
  • Olekrut

Poem

🐰 With whiskers twitching, I declare,
A tiny toggle, a numeric flair.
Buttons rounded, corners glide,
Global switch and value applied. 😊

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description provides motivation, technical implementation details, and testing notes, but does not follow the required template structure with explicit 'How Has This Been Tested?' section or completed test checklists. Follow the repository's PR description template: add a 'How Has This Been Tested?' section with detailed testing steps, and complete the relevant test checklist items to demonstrate verification of the changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding global button border-radius control to Style Cards. It is concise, specific, and directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0c55024a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/extensions/style-cards/getSCStyles.js
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

🤖 Fix all issues with AI agents
In @src/extensions/style-cards/getSCStyles.js:
- Around line 805-812: The addedResponse block in getWPNativeStyles references
hasGlobalButtonRadius and buttonRadiusValue which are not declared in that
function; declare and initialize these two variables at the start of
getWPNativeStyles using the same logic used in getMaxiSCStyles (where they are
declared) so the condition and CSS string concatenation can run without a
ReferenceError—locate the hasGlobalButtonRadius and buttonRadiusValue
definitions in getMaxiSCStyles and replicate that initialization (same names)
inside getWPNativeStyles before the if (hasGlobalButtonRadius &&
buttonRadiusValue) block.
- Around line 444-456: getMaxiSCStyles currently reads styleCard but doesn't
receive it; update the getMaxiSCStyles function signature to accept a styleCard
parameter and replace internal references to styleCard accordingly, then pass
the existing styleCard when calling getMaxiSCStyles from within getSCStyles (and
update any other callers of getMaxiSCStyles to provide the new parameter);
ensure variable names match (e.g., hasGlobalButtonRadius, buttonRadiusValue) so
the border-radius logic uses the passed-in styleCard.

In @src/extensions/style-cards/getSCVariablesObject.js:
- Around line 278-294: The switch case declares the constant borderRadiusValue
(from getLastBreakpointAttribute) directly in the case which violates
noSwitchDeclarations; wrap the case body in a block (add { } around the case's
statements) so borderRadiusValue and any other declarations are scoped to that
block, or alternatively move the declaration outside the switch; update the case
that uses getIsValid and response[...]
(`--maxi-${style}-${element}-border-radius-general` and
`--maxi-${style}-${element}-border-radius-global`) to live inside the new block
to prevent leaking the constant to other cases.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d673c0 and d0c5502.

📒 Files selected for processing (4)
  • core/defaults/defaultSC.json
  • src/editor/style-cards/maxiStyleCardsTab.js
  • src/extensions/style-cards/getSCStyles.js
  • src/extensions/style-cards/getSCVariablesObject.js
🧰 Additional context used
🧬 Code graph analysis (1)
src/extensions/style-cards/getSCStyles.js (1)
src/extensions/style-cards/getSCVariablesObject.js (1)
  • prefix (20-20)
🪛 Biome (2.1.2)
src/extensions/style-cards/getSCVariablesObject.js

[error] 278-282: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Safe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: e2e-js
  • GitHub Check: e2e-js-playwright
  • GitHub Check: unit-js
🔇 Additional comments (4)
src/editor/style-cards/maxiStyleCardsTab.js (2)

260-267: LGTM! Derived values follow existing patterns.

The conditional extraction of button border radius attributes is consistent with how other button-specific attributes are handled in this component.


321-351: LGTM! UI controls are properly wired.

The border radius controls are correctly placed and follow the established pattern for button-specific settings. The unconditional rendering of the number control (regardless of toggle state) appears intentional and allows users to set values before enabling the global override.

core/defaults/defaultSC.json (2)

405-406: LGTM! Sensible default values.

The defaults for button border radius (disabled toggle, 0px radius) are appropriate and consistent with the feature being opt-in.


988-989: LGTM! Consistent with dark theme.

The light theme defaults mirror the dark theme settings, maintaining consistency across both style card variants.

Comment thread src/extensions/style-cards/getSCStyles.js
Comment thread src/extensions/style-cards/getSCVariablesObject.js Outdated
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

🤖 Fix all issues with AI agents
In @src/extensions/style-cards/getSCStyles.js:
- Around line 444-447: getMaxiSCStyles currently references styleCard (used to
compute hasGlobalButtonRadius and buttonRadiusValue) but styleCard is not
defined in its scope; update getMaxiSCStyles to accept a styleCard parameter
(e.g., function getMaxiSCStyles(style, styleCard, ...) or add styleCard to its
existing params) and then update every call site that invokes getMaxiSCStyles to
pass the appropriate styleCard object so hasGlobalButtonRadius and
buttonRadiusValue can read from styleCard without causing a ReferenceError.
- Around line 805-812: The code in getWPNativeStyles references
hasGlobalButtonRadius and buttonRadiusValue which are only defined in
getMaxiSCStyles; declare and compute these variables inside getWPNativeStyles
(or extract the shared logic into a helper used by both functions).
Specifically, copy or refactor the logic that sets hasGlobalButtonRadius and
buttonRadiusValue from getMaxiSCStyles (lines where they are derived) into
getWPNativeStyles so those symbols exist in that function scope before the block
that appends addedResponse for .wp-element-button and .comment-form input.

In @src/extensions/style-cards/getSCVariablesObject.js:
- Around line 278-290: The switch case currently declares the constant
borderRadiusValue (and uses obj, getIsValid, response, style, element) directly
in the case body, which violates the noSwitchDeclarations rule; fix it by
wrapping that case’s body in a block (add { ... } around the existing statements
for the case) so the declaration is scoped to the block and the logic that sets
--maxi-...-border-radius-general and --maxi-...-border-radius-global remains
unchanged.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0c5502 and 015f535.

📒 Files selected for processing (2)
  • src/extensions/style-cards/getSCStyles.js
  • src/extensions/style-cards/getSCVariablesObject.js
🧰 Additional context used
🧬 Code graph analysis (1)
src/extensions/style-cards/getSCVariablesObject.js (1)
src/editor/style-cards/maxiStyleCardsTab.js (1)
  • borderRadiusValue (264-267)
🪛 Biome (2.1.2)
src/extensions/style-cards/getSCVariablesObject.js

[error] 278-278: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.

The declaration is defined in this switch clause:

Safe fix: Wrap the declaration in a block.

(lint/correctness/noSwitchDeclarations)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: e2e-js-playwright
  • GitHub Check: e2e-js
  • GitHub Check: unit-js

Comment thread src/extensions/style-cards/getSCStyles.js Outdated
Comment thread src/extensions/style-cards/getSCStyles.js
Comment thread src/extensions/style-cards/getSCVariablesObject.js
@kyrapieterse kyrapieterse self-assigned this Jan 7, 2026
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.

Add global button radius customization to MaxiBlocks style cards

1 participant