-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client: skip to main content (a11y) (#681)
- Loading branch information
Showing
11 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './skip-to-main-content.component'; | ||
export * from './skip-to-main-content.constants'; | ||
export * from './skip-to-main-content.directive'; |
4 changes: 4 additions & 0 deletions
4
client/src/app/layout/skip-to-main-content/skip-to-main-content.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<a (click)="focusMainContent()" (keydown.enter)="focusMainContent()" tabindex="0" class="app-skip-to-main-content"> | ||
<ng-container i18n="@@Component.SkipToMainContent.Title">Accéder au contenu principal</ng-container> | ||
<mat-icon class="app-skip-to-main-content__icon">step_over</mat-icon> | ||
</a> |
27 changes: 27 additions & 0 deletions
27
client/src/app/layout/skip-to-main-content/skip-to-main-content.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.app-skip-to-main-content { | ||
position: fixed; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
z-index: 9999; | ||
padding: 1rem; | ||
border-radius: 0.5rem; | ||
background-color: var(--sys-secondary); | ||
color: var(--sys-on-secondary); | ||
text-decoration: none; | ||
font-size: 1.125rem; | ||
cursor: pointer; | ||
|
||
top: -9999px; | ||
opacity: 0; | ||
transition: ease 300ms opacity; | ||
|
||
&:focus-visible { | ||
top: 4rem; | ||
opacity: 1; | ||
} | ||
|
||
&__icon { | ||
margin-left: 0.5rem; | ||
vertical-align: bottom; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
client/src/app/layout/skip-to-main-content/skip-to-main-content.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { DOCUMENT } from '@angular/common'; | ||
import { Component, inject, ViewEncapsulation } from '@angular/core'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { SKIP_TO_MAIN_CONTENT_ID } from './skip-to-main-content.constants'; | ||
|
||
@Component({ | ||
selector: 'app-skip-to-main-content', | ||
standalone: true, | ||
imports: [MatIconModule], | ||
templateUrl: './skip-to-main-content.component.html', | ||
styleUrls: ['./skip-to-main-content.component.scss'], | ||
encapsulation: ViewEncapsulation.None, | ||
}) | ||
export class SkipToMainContentComponent { | ||
#document = inject(DOCUMENT); | ||
|
||
focusMainContent() { | ||
this.#document.getElementById(SKIP_TO_MAIN_CONTENT_ID)!.focus({ preventScroll: true }); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
client/src/app/layout/skip-to-main-content/skip-to-main-content.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const SKIP_TO_MAIN_CONTENT_ID = 'skip-to-main-content-target'; |
13 changes: 13 additions & 0 deletions
13
client/src/app/layout/skip-to-main-content/skip-to-main-content.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Directive } from '@angular/core'; | ||
import { SKIP_TO_MAIN_CONTENT_ID } from './skip-to-main-content.constants'; | ||
|
||
@Directive({ | ||
selector: '[appSkipToMainContent]', | ||
host: { | ||
id: SKIP_TO_MAIN_CONTENT_ID, | ||
tabindex: '0', | ||
'[style.outline]': '"none"', | ||
}, | ||
standalone: true, | ||
}) | ||
export class SkipToMainContentDirective {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters