Skip to content

feat(theme): render Button blocks as the theme's default button - #77

Merged
koechkevin merged 1 commit into
developfrom
feat/block-button-default-styles
Nov 12, 2026
Merged

koechkevin merged 1 commit into
developfrom
feat/block-button-default-styles

Conversation

@koechkevin

Copy link
Copy Markdown
Contributor

Problem

Buttons added with the block editor's Button block didn't match the site:

  • Outside lessons they rendered as WordPress's default grey pill, or in whatever colour the author picked.
  • Inside WPBakery lesson tabs, div.vc_tta-panel-body a:link { color: navy !important } (the course-content link style) painted the label navy, so it was invisible on a navy background. It also added underline/bold and a red hover.
  • Most topics wrap content in WPBakery shortcodes, which runs it through wpautop and strips WP's generated button-group layout classes, so grouped buttons touched each other and the stray empty <p> added a phantom gap.

Change

  • components/_block-buttons.scss (new, in main.css): every .wp-block-button__link renders as the theme's .button.primary.medium. That's navy #0C1A81, white uppercase 800-weight text, square corners, 12px/16px padding, inverting to primary-50/navy on hover, plus a focus-visible ring.
    • Colour, gradient, border, radius, padding, typography and the Outline style are overridden with !important. WP's palette classes are !important themselves and custom values are inline styles, so this is the only way to keep buttons uniform. Authors control only alignment and width, which live on the wrapper and aren't touched.
    • .wp-block-buttons gets a flex / gap: 8px fallback and hides wpautop's empty <p>/<br>.
  • _wpbakery.scss: the course-content link rules now use :not(.wp-block-button__link), so they keep styling text links only.
  • Editor preview: the same rules compile to dist/editor/editor-style.css, loaded in the block editor via enqueue_block_assets (admin only), so authors see the real button. That sheet imports only the colour variables, so it doesn't leak .button/.wysiwyg into wp-admin.
  • ACADEMY_AFRICA_VERSION bumped to 1.7.21 for cache busting.

main.css only gains the new rules. The only selectors changed are the two vc_tta-panel-body link rules.

Testing (local Docker)

On Advanced Fact-checking Technology (inside a WPBakery tour tab), I injected buttons with: no styles, the Outline style, a palette colour (orange), inline custom colour/border/radius/padding/font-size, and a gradient. In headless Chrome all of them computed identically: white text on #0C1A81, 1px navy border, 0 radius, 12px/16px, 16px/800 uppercase, no underline. I also took a screenshot to confirm visually.

php -l passes on functions.php.

Not yet verified: the button's appearance inside the block editor and the hover state on screen. Please check both on staging.

Note for content editors

Colour and style pickers on the Button block no longer have any effect on the front end. Buttons always use the house style. A button still needs a link (⌘K) to do anything; the existing Download button on that topic has no href.

Buttons inserted with the block editor's Button block rendered as WP's
default grey pill, or in whatever colour the author picked, and inside
WPBakery lesson tabs the course-content link rule (navy, bold, underline,
!important) painted their label navy-on-navy.

- New components/_block-buttons.scss: every .wp-block-button__link renders
  as .button.primary.medium (navy, white uppercase 800 text, square,
  12px/16px, inverting on hover). Colour, gradient, border, radius, padding,
  typography and the Outline style are overridden with !important so
  buttons stay uniform; authors only control alignment and width.
- .wp-block-buttons gets a flex/gap fallback (and hides wpautop's stray
  empty <p>/<br>), since WPBakery-wrapped content loses WP's generated
  layout classes.
- div.vc_tta-panel-body link rules now skip .wp-block-button__link.
- Same rules compiled to dist/editor/editor-style.css and loaded in the
  block editor via enqueue_block_assets, so authors see the real button.
- Bump ACADEMY_AFRICA_VERSION to 1.7.21 for cache busting.
@koechkevin
koechkevin merged commit 50841c3 into develop Nov 12, 2026
10 checks passed
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