diff --git a/packages/block-library/src/accordion-heading/style.scss b/packages/block-library/src/accordion-heading/style.scss index 67c5d477154a59..2da9c06f16b4e4 100644 --- a/packages/block-library/src/accordion-heading/style.scss +++ b/packages/block-library/src/accordion-heading/style.scss @@ -1,9 +1,3 @@ -.wp-block-accordion-heading { - // Some classic themes apply default margins to heading elements, - // so those styles need to be reset. - margin: 0; -} - .wp-block-accordion-heading__toggle { font-family: inherit; font-size: inherit; @@ -14,7 +8,9 @@ text-decoration: inherit; word-spacing: inherit; font-style: inherit; + background: none; border: none; + color: inherit; padding: var(--wp--preset--spacing--20, 1em) 0; cursor: pointer; overflow: hidden; @@ -23,34 +19,10 @@ text-align: inherit; width: 100%; - // Some themes may apply colors to button elements with a particularly - // high CSS specificity. Since it's impossible to predict this specificity, - // we reset the colors using `!important`. - background-color: inherit !important; - color: inherit !important; - &:not(:focus-visible) { outline: none; } - &:hover, - &:focus { - // Some themes may apply styles when a button element is hovered - // over or focused. This is not intended for accordion toggle - // buttons, so we reset it here. - text-decoration: none; - background-color: inherit !important; - box-shadow: none; - color: inherit; - border: none; - padding: var(--wp--preset--spacing--20, 1em) 0; - } - - &:focus-visible { - outline: auto; - outline-offset: 0; - } - &:hover .wp-block-accordion-heading__toggle-title { text-decoration: underline; } diff --git a/packages/block-library/src/classic.scss b/packages/block-library/src/classic.scss index ace23d9dfdae38..7b9ac61e6cbba8 100644 --- a/packages/block-library/src/classic.scss +++ b/packages/block-library/src/classic.scss @@ -20,3 +20,41 @@ background: #32373c; color: $white; } + +// These rules are needed to enforce the default styling of +// the Accordion Heading block in the classic theme. +.wp-block-accordion-heading { + // Heading elements may have default margins applied, so those + // styles need to be reset. + margin: 0; +} + +.wp-block-accordion-heading__toggle { + // Button elements can have colors applied with high CSS specificity, + // and since this specificity is impossible to predict, we use + // `!important` to reset the color. + background-color: inherit !important; + color: inherit !important; + + &:not(:focus-visible) { + outline: none; + } + + &:hover, + &:focus { + // Sometimes styles are applied when the button element is + // hovered over or focused. This isn't expected for accordion + // toggle buttons, so reset those styles here. + text-decoration: none; + background-color: inherit !important; + box-shadow: none; + color: inherit; + border: none; + padding: var(--wp--preset--spacing--20, 1em) 0; + } + + &:focus-visible { + outline-offset: 0; + outline: auto; + } +}