mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-20 10:02:23 -06:00
This follows up from #1259 and closes #1261. Basically, this PR accomplishes the two items discussed in the issue: 1. for all anchors that are *actually* buttons (i.e., have `href="#"`), I've replaced them with a semantic `<button>` - under the hood, I've made a `.btn-reset` class pulling out the reset from #1259, so there's no visual change 2. for anchors that are ["toggle buttons"](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#toggle_buttons) (the mobile menu nav, sidebar children/grandchildren toggles), I've added an `aria-pressed` property that is updated as the button is clicked I've also slightly modified some of the `aria-label`s to make them more consistent. Observe that we *shouldn't* update these as the button is clicked; screen readers use the `aria-pressed` property to add an annotation to each button. To test this, - the sidebar children and grandchildren can be done on the deploy preview: - open an arbitrary page; observe that the sidebar children/grandchildren dropdown ticks now have a proper `aria-label` and `aria-pressed`, as well as otherwise work as intended - toggle one of the buttons; observe the `aria-pressed` role changing as this is done - open a grandchild page; observe that the `aria-pressed` has a correct default wrt whether or not the page is active - the mobile menu can be done on the deploy preview; on a smaller viewport, observe the correct `aria-pressed` - two features require local changes to test: - the `site.search.button` needs to be enabled in the `_config.yml`. To test this, locally clone the repo, change the flag, and observe that the button still works as intended + has no visual regressions. - the collections feature is a bit more complicated. To test this, locally clone the repo, add an arbitrary collection and changes to `_config.yml`, and observe the same behaviour for the sidebar children/grandchildren above
124 lines
2.4 KiB
SCSS
124 lines
2.4 KiB
SCSS
// Buttons and things that look like buttons
|
|
// stylelint-disable color-named
|
|
|
|
.btn {
|
|
display: inline-block;
|
|
box-sizing: border-box;
|
|
padding: 0.3em 1em;
|
|
margin: 0;
|
|
font-family: inherit;
|
|
font-size: inherit;
|
|
font-weight: 500;
|
|
line-height: 1.5;
|
|
color: $link-color;
|
|
text-decoration: none;
|
|
vertical-align: baseline;
|
|
cursor: pointer;
|
|
background-color: $base-button-color;
|
|
border-width: 0;
|
|
border-radius: $border-radius;
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.08);
|
|
appearance: none;
|
|
|
|
&:focus {
|
|
text-decoration: none;
|
|
outline: none;
|
|
box-shadow: 0 0 0 3px rgba(blue, 0.25);
|
|
}
|
|
|
|
&:focus:hover,
|
|
&.selected:focus {
|
|
box-shadow: 0 0 0 3px rgba(blue, 0.25);
|
|
}
|
|
|
|
&:hover,
|
|
&.zeroclipboard-is-hover {
|
|
color: darken($link-color, 2%);
|
|
}
|
|
|
|
&:hover,
|
|
&:active,
|
|
&.zeroclipboard-is-hover,
|
|
&.zeroclipboard-is-active {
|
|
text-decoration: none;
|
|
background-color: darken($base-button-color, 1%);
|
|
}
|
|
|
|
&:active,
|
|
&.selected,
|
|
&.zeroclipboard-is-active {
|
|
background-color: darken($base-button-color, 3%);
|
|
background-image: none;
|
|
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
&.selected:hover {
|
|
background-color: darken(#dcdcdc, 5%);
|
|
}
|
|
|
|
&:disabled,
|
|
&.disabled {
|
|
&,
|
|
&:hover {
|
|
color: rgba(102, 102, 102, 0.5);
|
|
cursor: default;
|
|
background-color: rgba(229, 229, 229, 0.5);
|
|
background-image: none;
|
|
box-shadow: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
.btn-outline {
|
|
color: $link-color;
|
|
background: transparent;
|
|
box-shadow: inset 0 0 0 2px $grey-lt-300;
|
|
|
|
&:hover,
|
|
&:active,
|
|
&.zeroclipboard-is-hover,
|
|
&.zeroclipboard-is-active {
|
|
color: darken($link-color, 4%);
|
|
text-decoration: none;
|
|
background-color: transparent;
|
|
box-shadow: inset 0 0 0 3px $grey-lt-300;
|
|
}
|
|
|
|
&:focus {
|
|
text-decoration: none;
|
|
outline: none;
|
|
box-shadow: inset 0 0 0 2px $grey-dk-100, 0 0 0 3px rgba(blue, 0.25);
|
|
}
|
|
|
|
&:focus:hover,
|
|
&.selected:focus {
|
|
box-shadow: inset 0 0 0 2px $grey-dk-100;
|
|
}
|
|
}
|
|
|
|
.btn-primary {
|
|
@include btn-color($white, $btn-primary-color);
|
|
}
|
|
|
|
.btn-purple {
|
|
@include btn-color($white, $purple-100);
|
|
}
|
|
|
|
.btn-blue {
|
|
@include btn-color($white, $blue-000);
|
|
}
|
|
|
|
.btn-green {
|
|
@include btn-color($white, $green-100);
|
|
}
|
|
|
|
.btn-reset {
|
|
background: none;
|
|
border: none;
|
|
margin: 0;
|
|
text-align: inherit;
|
|
font: inherit;
|
|
border-radius: 0;
|
|
appearance: none;
|
|
}
|