Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 2 additions & 30 deletions packages/block-library/src/accordion-heading/style.scss
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down
38 changes: 38 additions & 0 deletions packages/block-library/src/classic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading