Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accessibility of sidebar toggle on mobile element index pages, darken sidebar headings #11169

Merged
merged 17 commits into from
May 11, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Changed
- Improved pagination UI accessibility. ([#11126](https://github.com/craftcms/cms/pull/11126))
- Improved element index accessibility. ([#11169](https://github.com/craftcms/cms/pull/11169))
- Live Preview now always shows a “Refresh” button, regardless of whether the preview target has auto-refresh enabled. ([#11160](https://github.com/craftcms/cms/discussions/11160))
- Entry Type condition rules now allow multiple selections. ([#11124](https://github.com/craftcms/cms/pull/11124))
- Element index filters now only show condition rules for the custom fields that are used by the field layouts in the selected source, if a native source is selected. ([#11187](https://github.com/craftcms/cms/discussions/11187))
Expand Down
11 changes: 11 additions & 0 deletions packages/craftcms-sass/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,17 @@ $radioSize: 16px;
box-shadow: var(--focus-ring);
}

@mixin visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}

@mixin readable {
font-size: 16px;
line-height: 22px;
Expand Down
7 changes: 6 additions & 1 deletion src/templates/_layouts/cp.twig
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@
{# sidebar #}
{% if sidebar %}
<div id="sidebar-toggle-container">
<button type="button" id="sidebar-toggle" class="btn menubtn"><span id="selected-sidebar-item-label"></span></button>
<button type="button" id="sidebar-toggle" class="btn menubtn" aria-controls="sidebar-container" aria-expanded="false">
{{ 'Show sidebar'|t('app') }}
</button>
</div>
<div id="sidebar-container">
<div id="sidebar" class="sidebar">
Expand All @@ -231,6 +233,9 @@

{# content-container #}
<div id="content-container">
{% if sidebar %}
<h2 id="content-heading"></h2>
{% endif %}
{% block main %}
<div id="content" class="content-pane">
{% if contentNotice or tabs %}
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css.map

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions src/web/assets/cp/src/css/_cp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,14 @@ li.breadcrumb-toggle-wrapper {
}
}

#content-heading {
margin-top: var(--xl) !important;

@media only screen and (min-width: $minHorizontalUiWidth) {
@include visually-hidden;
}
}

.content-pane {
@include pane;
border-radius: var(--large-border-radius);
Expand Down Expand Up @@ -1174,12 +1182,20 @@ li.breadcrumb-toggle-wrapper {
}

#sidebar-toggle {
&:after {
top: 0;
transform: rotate(-45deg);

body.rtl & {
transform: rotate(135deg);
}
}

body.showing-sidebar & {
background-color: darken($grey200, 10%) !important;

&:after {
transform: rotate(225deg);
top: 1px;
transform: rotate(45deg);
}
}
}
Expand Down Expand Up @@ -1302,7 +1318,7 @@ li.breadcrumb-toggle-wrapper {
padding: 0 5px;
margin: 0 -5px;
text-transform: uppercase;
color: var(--light-text-color);
color: var(--medium-text-color);
font-size: 11px;
font-weight: bold;
}
Expand Down
9 changes: 1 addition & 8 deletions src/web/assets/cp/src/css/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -951,14 +951,7 @@ td.right {

// Visually hide without hiding from screen readers
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: 0;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
@include visually-hidden;
}

.invisible {
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/src/js/BaseElementIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,7 @@ Craft.BaseElementIndex = Garnish.Base.extend(
this.setInstanceState('selectedSource', this.sourceKey);
this.sourceSelect.selectItem($source);

Craft.cp.updateSidebarMenuLabel();
gcamacho079 marked this conversation as resolved.
Show resolved Hide resolved
Craft.cp.updateContentHeading();

if (this.searching) {
// Clear the search value without causing it to update elements
Expand Down
21 changes: 14 additions & 7 deletions src/web/assets/cp/src/js/CP.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Craft.CP = Garnish.Base.extend(
$mainContent: null,
$details: null,
$sidebarContainer: null,
$sidebarToggle: null,
$sidebar: null,
$contentContainer: null,
$edition: null,
Expand Down Expand Up @@ -82,13 +83,14 @@ Craft.CP = Garnish.Base.extend(
this.$mainContent = $('#main-content');
this.$details = $('#details');
this.$sidebarContainer = $('#sidebar-container');
this.$sidebarToggle = $('#sidebar-toggle');
this.$sidebar = $('#sidebar');
this.$contentContainer = $('#content-container');
this.$collapsibleTables = $('table.collapsible');

this.isMobile = Garnish.isMobileBrowser();

this.updateSidebarMenuLabel();
this.updateContentHeading();

// Swap any instruction text with info icons
let $allInstructions = this.$details.find(
Expand Down Expand Up @@ -152,7 +154,7 @@ Craft.CP = Garnish.Base.extend(

// Toggles
this.addListener(this.$navToggle, 'click', 'toggleNav');
this.addListener($('#sidebar-toggle'), 'click', 'toggleSidebar');
this.addListener(this.$sidebarToggle, 'click', 'toggleSidebar');

// Does this page have a primary form?
if (!this.$primaryForm.length) {
Expand Down Expand Up @@ -457,11 +459,13 @@ Craft.CP = Garnish.Base.extend(
},

updateSidebarMenuLabel: function () {
var $item = this.$sidebar.find('a.sel:first');
var $label = $item.children('.label');
$('#selected-sidebar-item-label').text(
$label.length ? $label.text() : $item.text()
);
this.updateContentHeading();
},

updateContentHeading: function () {
const $item = this.$sidebar.find('a.sel:first');
const $label = $item.children('.label');
$('#content-heading').text($label.length ? $label.text() : $item.text());
Garnish.$bod.removeClass('showing-sidebar');
},

Expand Down Expand Up @@ -525,6 +529,9 @@ Craft.CP = Garnish.Base.extend(
},

toggleSidebar: function () {
const expanded = this.$sidebarToggle.attr('aria-expanded') === 'true';
const newState = expanded ? 'false' : 'true';
this.$sidebarToggle.attr('aria-expanded', newState);
Garnish.$bod.toggleClass('showing-sidebar');
},

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/dashboard/dist/css/Dashboard.css.map

Large diffs are not rendered by default.

Loading