-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: switched to a11y compliant HTML (#417)
* refactor: switched to a11y compliant HTML * refactor: setting the aria-current on the links instead of the list items * Revert "refactor: setting the aria-current on the links" This reverts commit c2e2081. * refactor: added aria-label to button component * refactor: added SPA variant * docs: added another quick hint * chore: remove 1.6 styling tag temporarily, until we render enterprise version of the styleguide as well
- Loading branch information
Showing
8 changed files
with
77 additions
and
22 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
12 changes: 12 additions & 0 deletions
12
source/_patterns/02-components/language-switcher/_language-switcher.md
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,12 @@ | ||
--- | ||
title: Language switcher | ||
state: inprogress | ||
--- | ||
|
||
You could either use the language switcher component with hyperlinks, which would be the recommended way, to link to another language based page, which is addressable by a different URL. | ||
|
||
The other way (especially for Single Page Applications) would be to use `<button type="button">` elements, that have some JavaScript events attached to them to handle the switch directly. Please keep in mind to announce a change of contents e.g. to screenreaders in this case. | ||
|
||
In both cases there's a slightly different HTML approach that you could inspect within the different examples below. | ||
|
||
Please keep in mind that the styling is optimized to look good included within the header section of the page and doesn't "shine" included in here. |
29 changes: 20 additions & 9 deletions
29
source/_patterns/02-components/language-switcher/language-switcher.hbs
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 |
---|---|---|
@@ -1,13 +1,24 @@ | ||
{{! TODO: evaluate on the correct role and aria-label in here }} | ||
<!-- [html-validate-disable-next prefer-native-element] --> | ||
<ul class="cmp-language-switcher" role="listbox"> | ||
<li role="option"> | ||
{{> elements-link href='#' hreflang='en' value='EN' title='English language' rel='alternate' }} | ||
{{#if spa}}<!-- [html-validate-disable-next prefer-native-element] -->{{/if }} | ||
<ul class="cmp-language-switcher"{{#if spa}} role="listbox"{{/if }}> | ||
<li{{#if spa}} role="option"{{/if }}> | ||
{{#unless spa}} | ||
{{> elements-link href='#' hreflang='en' value='EN' title='English language' rel='alternate' }} | ||
{{else}} | ||
{{> elements-button type='button' value='EN' title='English language' variant='tertiary-plain' }} | ||
{{/unless }} | ||
</li> | ||
<li role="option" aria-selected="true"> | ||
{{> elements-link href='#' hreflang='de' value='DE' title='Deutsche Sprache' rel='bookmark' }} | ||
<li{{#if spa}} role="option" aria-selected="true"{{else}} aria-current="page"{{/if }}> | ||
{{#unless spa}} | ||
{{> elements-link href='#' hreflang='de' value='DE' title='Deutsche Sprache' rel='bookmark' }} | ||
{{else}} | ||
{{> elements-button type='button' value='DE' title='Deutsche Sprache' variant='tertiary-plain' }} | ||
{{/unless }} | ||
</li> | ||
<li role="option"> | ||
{{> elements-link href='#' hreflang='fr' value='FR' title='Langue française' rel='alternate' }} | ||
<li{{#if spa}} role="option"{{/if }}> | ||
{{#unless spa}} | ||
{{> elements-link href='#' hreflang='fr' value='FR' title='Langue française' rel='alternate' }} | ||
{{else}} | ||
{{> elements-button type='button' value='FR' title='Langue française' variant='tertiary-plain' }} | ||
{{/unless }} | ||
</li> | ||
</ul> |
1 change: 0 additions & 1 deletion
1
source/_patterns/02-components/language-switcher/language-switcher.md
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
--- | ||
title: Language switcher | ||
state: inprogress | ||
tags: [style-1.6] | ||
--- | ||
|
||
[Insert description here] |
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
3 changes: 3 additions & 0 deletions
3
source/_patterns/02-components/language-switcher/language-switcher~spa.json
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 @@ | ||
{ | ||
"spa": true | ||
} |
6 changes: 6 additions & 0 deletions
6
source/_patterns/02-components/language-switcher/language-switcher~spa.md
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,6 @@ | ||
--- | ||
title: Language switcher with buttons | ||
state: inprogress | ||
--- | ||
|
||
[Insert description here] |