feat(button): add plain variant#8305
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRelocated and redefined the Changes
Sequence Diagram(s)(omitted — changes are styling and docs only) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
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. Comment |
|
Preview: https://pf-pr-8305.surge.sh A11y report: https://pf-pr-8305-a11y.surge.sh |
|
@andrew-ronaldson can you confirm that the left/right padding for the notification badge (all variants) should use the plain (sm) spacer token? Looks like everything is using a small spacer in figma. IIRC I thought the plain variant would look like this compared to the default notfication badge
|
|
All the stateful buttons have a sm spacer in Figma. I see the react and core examples have md spacers on org but that feels too wide. |
Looks like it was a change we made in v6, I'm guessing since they look like control buttons by default, they use the control button spacer. If we update the non-plain notification badge to small left/right spacers, wdyt about using the "plain" spacer token versus the "sm" spacer? Another way of asking is, if users customize the plain button spacer (or we do with some new theme or whatever), would we expect the non-plain notification badge spacers to update, too? |
|
I talked to Lucia about this one. |
|
@jcmill fwiw here are the updates I made for the screenshot referenced above.
--#{$button}--m-stateful--PaddingInlineEnd: var(--#{$button}--m-plain--PaddingInlineEnd);
--#{$button}--m-stateful--PaddingInlineStart: var(--#{$button}--m-plain--PaddingInlineStart);
--#{$button}--m-read--hover--BackgroundColor: var(--#{$button}--m-plain--hover--BackgroundColor);
--#{$button}--m-read--m-clicked--BackgroundColor: var(--#{$button}--m-plain--m-clicked--BackgroundColor);
--#{$button}--m-read--BackgroundColor: var(--#{$button}--m-plain--BackgroundColor); |
…riting vars, remove background for read modifier and background and hover background to plain
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/patternfly/components/Button/button.scss`:
- Around line 224-225: The two root stateful custom properties
(--#{$button}--m-stateful--PaddingInlineStart and
--#{$button}--m-stateful--PaddingInlineEnd) are forcing the plain spacer onto
all .pf-m-stateful buttons; change their values back to the normal control
spacing variable used for non-plain controls and then override those two
properties inside the .pf-m-plain rule to the plain spacer. Locate the
declarations for --#{$button}--m-stateful--PaddingInlineStart /
--#{$button}--m-stateful--PaddingInlineEnd and set them to the standard control
spacer token, then add/modify the .pf-m-plain block to explicitly set those two
properties to the plain spacer token.
- Around line 733-738: The .pf-m-read modifier currently only maps border tokens
but not the read background tokens, causing read buttons to fall back to base
backgrounds; update the .pf-m-read block to also forward the background custom
properties by setting --#{$button}--Background to
var(--#{$button}--m-read--Background), --#{$button}--hover--Background to
var(--#{$button}--m-read--hover--Background) and
--#{$button}--m-clicked--Background to
var(--#{$button}--m-read--m-clicked--Background) so the declared read background
tokens are consumed for normal, hover and clicked states.
- Around line 713-717: The overrides that forward stateful/read variables (e.g.,
--#{$button}--m-stateful--PaddingInlineEnd,
--#{$button}--m-stateful--PaddingInlineStart,
--#{$button}--m-read--hover--BackgroundColor,
--#{$button}--m-read--m-clicked--BackgroundColor,
--#{$button}--m-read--BackgroundColor) are currently only applied under the
`.pf-m-no-padding` context; update the selector that contains this block so it
also targets `.pf-m-plain` buttons (for example include `.pf-m-plain` alongside
`.pf-m-no-padding` in the selector) so plain stateful buttons receive the same
padding and read background variable forwarding as the no-padding variant.
🪄 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 (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 3572d7c5-018d-4d5c-a7ab-afa55529e64f
📒 Files selected for processing (1)
src/patternfly/components/Button/button.scss
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/patternfly/components/Button/button.scss (1)
734-738:⚠️ Potential issue | 🟠 MajorNon-plain read buttons lose background styling.
.pf-m-readonly forwards border tokens now;--#{$button}--m-read--BackgroundColor,--#{$button}--m-read--hover--BackgroundColor, and--#{$button}--m-read--m-clicked--BackgroundColor(declared at lines 230/232/234) are no longer consumed on non-plain read buttons, so they fall back to the roottransparentbackground instead of--pf-t--global--background--color--control--default. This regresses the existing (non-plain) notification badge read state shown inButton.md.🎨 Proposed fix
// Read &.pf-m-read { + --#{$button}--BackgroundColor: var(--#{$button}--m-read--BackgroundColor); --#{$button}--BorderColor: var(--#{$button}--m-read--BorderColor); + --#{$button}--hover--BackgroundColor: var(--#{$button}--m-read--hover--BackgroundColor); --#{$button}--hover--BorderColor: var(--#{$button}--m-read--hover--BorderColor); + --#{$button}--m-clicked--BackgroundColor: var(--#{$button}--m-read--m-clicked--BackgroundColor); --#{$button}--m-clicked--BorderColor: var(--#{$button}--m-read--m-clicked--BorderColor); }Because
.pf-m-plainis declared before.pf-m-readin the cascade and both forward into the same--#{$button}--BackgroundColoretc., plain+read composition should still pick up the plain forwarding via the root--#{$button}--m-read--BackgroundColortoken the plain block already overrides (lines 702-704). Worth verifying visually.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/patternfly/components/Button/button.scss` around lines 734 - 738, The .pf-m-read rule only forwards border tokens and omits the read Background tokens, causing non-plain read buttons to lose their background; update the .pf-m-read block to also forward --#{$button}--m-read--BackgroundColor, --#{$button}--m-read--hover--BackgroundColor, and --#{$button}--m-read--m-clicked--BackgroundColor into --#{$button}--BackgroundColor, --#{$button}--hover--BackgroundColor, and --#{$button}--m-clicked--BackgroundColor respectively (preserving existing border forwards), so non-plain read state uses the intended background while plain+read composition still picks up the plain overrides.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/patternfly/components/Button/button.scss`:
- Around line 734-738: The .pf-m-read rule only forwards border tokens and omits
the read Background tokens, causing non-plain read buttons to lose their
background; update the .pf-m-read block to also forward
--#{$button}--m-read--BackgroundColor,
--#{$button}--m-read--hover--BackgroundColor, and
--#{$button}--m-read--m-clicked--BackgroundColor into
--#{$button}--BackgroundColor, --#{$button}--hover--BackgroundColor, and
--#{$button}--m-clicked--BackgroundColor respectively (preserving existing
border forwards), so non-plain read state uses the intended background while
plain+read composition still picks up the plain overrides.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: bc288dd6-eb3c-413a-84e0-37eb61c5c9f7
📒 Files selected for processing (1)
src/patternfly/components/Button/button.scss
…plain with count for each stateful variation
mcoker
left a comment
There was a problem hiding this comment.
Just a few small docs updates to match the existing stateful example. Otherwise LGTM!
mcoker
left a comment
There was a problem hiding this comment.
Also noticed the a11y tests are failing because the plain (without count) need a label or text - https://pf-pr-8305-a11y.surge.sh/
You could add a button--aria-label of something like "All items read" for read, "Unread items" for unread and "Unread items, needs attention" for needs attention.
|
🎉 This PR is included in version 6.5.0-prerelease.76 🎉 The release is available on: Your semantic-release bot 📦🚀 |

Closes #8212
Adds plain variant to stateful buttons.
Changes
button.scss: For stateful buttons, PaddingInlineStart / PaddingInlineEnd now use --pf-t--global--spacer--action--horizontal--plain--default instead of the control horizontal default, so plain stateful controls match plain action padding in figma.
Button.md: Adds a Read Plain demo (read + clicked) next to the existing stateful examples, and extends the .pf-m-plain table description to include stateful use cases.
Summary by CodeRabbit
Style
Documentation