Skip to content

Commit

Permalink
Merge pull request #2607 from alexandrevryghem/added-skip-to-main-con…
Browse files Browse the repository at this point in the history
…tent-button_contribute-main

Added skip to main content button
  • Loading branch information
tdonohue authored Nov 10, 2023
2 parents f336a8b + 19ed3c8 commit d029475
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
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 @@ export class RootComponent implements OnInit {
this.shouldShowRouteLoader = false;
}
}

skipToMainContent() {
const mainContent = document.getElementById('main-content');
if (mainContent) {
mainContent.tabIndex = -1;
mainContent.focus();
}
}
}
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

0 comments on commit d029475

Please sign in to comment.