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

Added skip to main content button #2607

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-xs-12 col-sm-12 col-md-9 main-content">
<div class="col-xs-12 col-sm-12 col-md-9">
<form class="primary" [formGroup]="feedbackForm" (ngSubmit)="createFeedback()">
<h2>{{ 'info.feedback.head' | translate }}</h2>
<p>{{ 'info.feedback.info' | translate }}</p>
Expand Down
6 changes: 5 additions & 1 deletion src/app/root/root.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<button (click)="skipToMainContent()" class="btn btn-primary" id="skip-to-main-content">
{{ 'root.skip-to-content' | translate }}
</button>

<div class="outer-wrapper" [class.d-none]="shouldShowFullscreenLoader" [@slideSidebarPadding]="{
value: (!(sidebarVisible | async) ? 'hidden' : (slideSidebarOver | async) ? 'shown' : 'expanded'),
params: {collapsedSidebarWidth: (collapsedSidebarWidth | async), totalSidebarWidth: (totalSidebarWidth | async)}
Expand All @@ -7,7 +11,7 @@
<ds-system-wide-alert-banner></ds-system-wide-alert-banner>
<ds-themed-header-navbar-wrapper></ds-themed-header-navbar-wrapper>
<ds-themed-breadcrumbs></ds-themed-breadcrumbs>
<main class="main-content my-cs">
<main class="my-cs" id="main-content">

<div class="container d-flex justify-content-center align-items-center h-100" *ngIf="shouldShowRouteLoader">
<ds-themed-loading [showMessage]="false"></ds-themed-loading>
Expand Down
16 changes: 16 additions & 0 deletions src/app/root/root.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#skip-to-main-content {
position: absolute;
top: -40px;
left: 0;
opacity: 0;
transition: opacity 0.3s;
z-index: calc(var(--ds-nav-z-index) + 1);
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;

&:focus {
opacity: 1;
top: 0;
}
}
8 changes: 8 additions & 0 deletions src/app/root/root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,12 @@
this.shouldShowRouteLoader = false;
}
}

skipToMainContent() {
const mainContent = document.getElementById('main-content');

Check warning on line 83 in src/app/root/root.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/root/root.component.ts#L83

Added line #L83 was not covered by tests
if (mainContent) {
mainContent.tabIndex = -1;
mainContent.focus();

Check warning on line 86 in src/app/root/root.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/root/root.component.ts#L85-L86

Added lines #L85 - L86 were not covered by tests
}
}
}
2 changes: 2 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3624,6 +3624,8 @@

"resource-policies.table.headers.title.for.collection": "Policies for Collection",

"root.skip-to-content": "Skip to main content",

"search.description": "",

"search.switch-configuration.title": "Show",
Expand Down
2 changes: 1 addition & 1 deletion src/styles/_global-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ body {
position: relative;
}

.main-content {
#main-content {
z-index: var(--ds-main-z-index);
flex: 1 1 100%;
}
Expand Down
Loading