-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: improving sd-header a11y #1668
Open
auroraVasconcelos
wants to merge
6
commits into
main
Choose a base branch
from
feat/sd-header-a11y
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bf793a2
fix: add icon only accessible names, add aria-expanded, logo descrip…
auroraVasconcelos 817a727
fix: buttons with links accessible names
auroraVasconcelos 1820267
chore: add aria expanded and aria controls to button
auroraVasconcelos e97828f
Merge branch 'main' into feat/sd-header-a11y
auroraVasconcelos 28a312f
chore: add a11y hint
auroraVasconcelos ecdb7ab
Merge branch 'feat/sd-header-a11y' of github.com:solid-design-system/…
auroraVasconcelos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ export default { | |
}, | ||
title: 'Templates/Header' | ||
}; | ||
|
||
/** **Accessibility hint:** aria-expanded and aria-controls may be use for smaller screens to make header accessible */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can remove the "smaller screens..." part and just mention that these attributes should be set for accessibility purposes. What do you think? |
||
export const SampleA = { | ||
name: 'Header Sample A-01', | ||
render: () => html` | ||
|
@@ -26,13 +26,13 @@ export const SampleA = { | |
<div class="flex justify-between items-center"> | ||
<!-- top-left-area start !--> | ||
<a class="flex flex-shrink" href="#"> | ||
<img class="h-8 md:h-12 lg:h-14" src="images/logo-unioninvestment-lg.svg" alt="Logo" /> | ||
<img class="h-8 md:h-12 lg:h-14" src="images/logo-unioninvestment-lg.svg" alt="Union Investment Homepage" /> | ||
</a> | ||
<!-- top-left-area end !--> | ||
<!-- top-right-area start !--> | ||
<div class="flex lg:hidden"> | ||
<sd-navigation-item onclick="openDrawerSampleA()"> | ||
<sd-icon name="system/menu" class="text-xl -my-[1.5px] -mx-1"></sd-icon> | ||
<sd-navigation-item id="open-menu-sample-a"> | ||
<sd-icon name="system/menu" label="Open menu" class="text-xl -my-[1.5px] -mx-1"></sd-icon> | ||
</sd-navigation-item> | ||
</div> | ||
<!-- top-right-area end !--> | ||
|
@@ -50,12 +50,12 @@ export const SampleA = { | |
<div class="-mr-4 flex items-center"> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon title="Unsere weiteren Auftritte" name="system/website" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/website" label="Website" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item onclick="alert('This could open a search bar')"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon title="Suche" name="system/magnifying-glass" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/magnifying-glass" label="Magnifying glass" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
|
@@ -97,11 +97,25 @@ export const SampleA = { | |
</sd-navigation-item> | ||
</nav> | ||
</sd-drawer> | ||
<script> | ||
function openDrawerSampleA() { | ||
<script type="module"> | ||
await Promise.all([ | ||
customElements.whenDefined('sd-navigation-item'), | ||
customElements.whenDefined('sd-drawer') | ||
]).then(() => { | ||
const drawerSampleA = document.getElementById('sample-a-drawer'); | ||
drawerSampleA.show(); | ||
} | ||
const navigationItemSampleA = document.getElementById('open-menu-sample-a'); | ||
const buttonSampleA = navigationItemSampleA.shadowRoot.querySelector('button'); | ||
|
||
buttonSampleA.setAttribute('aria-controls', 'sample-a-drawer'); | ||
//Add the necessary ARIA attributes to prevent only being added after action | ||
buttonSampleA.setAttribute('aria-expanded', 'false'); | ||
drawerSampleA.addEventListener('sd-hide', () => buttonSampleA.setAttribute('aria-expanded', 'false')); | ||
|
||
navigationItemSampleA.addEventListener('click', () => { | ||
drawerSampleA.show(); | ||
buttonSampleA.setAttribute('aria-expanded', 'true'); | ||
}); | ||
}); | ||
</script> | ||
` | ||
}; | ||
|
@@ -113,34 +127,34 @@ export const SampleA02 = { | |
<div class="flex justify-between items-center"> | ||
<!-- top-left-area start !--> | ||
<a class="flex flex-shrink" href="#"> | ||
<img class="h-8 md:h-12 lg:h-14" src="images/logo-unioninvestment-lg.svg" alt="Logo" /> | ||
<img class="h-8 md:h-12 lg:h-14" src="images/logo-unioninvestment-lg.svg" alt="Union Investment Homepage" /> | ||
</a> | ||
<!-- top-left-area end !--> | ||
<!-- top-right-area start !--> | ||
<div class="flex lg:hidden"> | ||
<sd-navigation-item onclick="openDrawerSampleA2()"> | ||
<sd-icon name="system/menu" class="text-xl -my-[1.5px] -mx-1"></sd-icon> | ||
<sd-navigation-item id="open-menu-sample-a-02"> | ||
<sd-icon name="system/menu" label="Open menu" class="text-xl -my-[1.5px] -mx-1"></sd-icon> | ||
</sd-navigation-item> | ||
</div> | ||
<div class="-mr-4 lg:flex hidden items-center"> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon name="system/filter-empty" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/filter-empty" label="Filter empty" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon name="system/globe" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/globe" label="Globe" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon name="system/website" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/website" label="Website" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item onclick="alert('This could open a search bar')"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon name="system/magnifying-glass" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/magnifying-glass" label="Magnifying glass" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
|
@@ -195,11 +209,25 @@ export const SampleA02 = { | |
</sd-navigation-item> | ||
</nav> | ||
</sd-drawer> | ||
<script> | ||
function openDrawerSampleA2() { | ||
const drawerSampleA2 = document.getElementById('sample-a02-drawer'); | ||
drawerSampleA2.show(); | ||
} | ||
<script type="module"> | ||
await Promise.all([ | ||
customElements.whenDefined('sd-navigation-item'), | ||
customElements.whenDefined('sd-drawer') | ||
]).then(() => { | ||
const drawerSampleA02 = document.getElementById('sample-a02-drawer'); | ||
const navigationItemSampleA02 = document.getElementById('open-menu-sample-a-02'); | ||
const buttonSampleA02 = navigationItemSampleA02.shadowRoot.querySelector('button'); | ||
|
||
buttonSampleA02.setAttribute('aria-controls', 'sample-a02-drawer'); | ||
//Add the necessary ARIA attributes to prevent only being added after action | ||
buttonSampleA02.setAttribute('aria-expanded', 'false'); | ||
drawerSampleA02.addEventListener('sd-hide', () => buttonSampleA02.setAttribute('aria-expanded', 'false')); | ||
|
||
navigationItemSampleA02.addEventListener('click', () => { | ||
drawerSampleA02.show(); | ||
buttonSampleA02.setAttribute('aria-expanded', 'true'); | ||
}); | ||
}); | ||
</script> | ||
` | ||
}; | ||
|
@@ -211,8 +239,12 @@ export const SampleB = { | |
<div class="flex justify-between items-center"> | ||
<!-- top-left-area start !--> | ||
<a class="flex flex-shrink" href="#"> | ||
<img class="sm:h-12 lg:h-14 hidden sm:flex" src="images/logo-unioninvestment-lg.svg" alt="Logo" /> | ||
<img class="h-8 sm:hidden" src="images/logo-unioninvestment-sm.svg" alt="Logo" /> | ||
<img | ||
class="sm:h-12 lg:h-14 hidden sm:flex" | ||
src="images/logo-unioninvestment-lg.svg" | ||
alt="Union Investment Homepage" | ||
/> | ||
<img class="h-8 sm:hidden" src="images/logo-unioninvestment-sm.svg" alt="Union Investment Homepage" /> | ||
</a> | ||
<!-- top-left-area end !--> | ||
<!-- top-right-area start !--> | ||
|
@@ -223,8 +255,8 @@ export const SampleB = { | |
</div> | ||
</div> | ||
<div class="flex lg:hidden"> | ||
<sd-navigation-item onclick="openDrawerSampleB()"> | ||
<sd-icon name="system/menu" class="text-xl -my-[1.5px] -mx-1"></sd-icon> | ||
<sd-navigation-item id="open-menu-sample-b"> | ||
<sd-icon name="system/menu" label="Open menu" class="text-xl -my-[1.5px] -mx-1"></sd-icon> | ||
</sd-navigation-item> | ||
</div> | ||
</div> | ||
|
@@ -243,12 +275,12 @@ export const SampleB = { | |
<div class="flex items-center"> | ||
<sd-navigation-item href="javascript:void(0)"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon title="Unsere weiteren Auftritte" name="system/website" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/website" label="Website" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<sd-navigation-item onclick="alert('This could open a search bar')"> | ||
<div class="w-4 h-4 flex items-center"> | ||
<sd-icon title="Suche" name="system/magnifying-glass" class="text-xl absolute -ml-1"></sd-icon> | ||
<sd-icon name="system/magnifying-glass" label="Magnifying glass" class="text-xl absolute -ml-1"></sd-icon> | ||
</div> | ||
</sd-navigation-item> | ||
<!-- bottom-right-area end !--> | ||
|
@@ -276,11 +308,25 @@ export const SampleB = { | |
</sd-navigation-item> | ||
</nav> | ||
</sd-drawer> | ||
<script> | ||
function openDrawerSampleB() { | ||
<script type="module"> | ||
await Promise.all([ | ||
customElements.whenDefined('sd-navigation-item'), | ||
customElements.whenDefined('sd-drawer') | ||
]).then(() => { | ||
const drawerSampleB = document.getElementById('sample-b-drawer'); | ||
drawerSampleB.show(); | ||
} | ||
const navigationItemSampleB = document.getElementById('open-menu-sample-b'); | ||
const buttonSampleB = navigationItemSampleB.shadowRoot.querySelector('button'); | ||
|
||
buttonSampleB.setAttribute('aria-controls', 'sample-b-drawer'); | ||
//Add the necessary ARIA attributes to prevent only being added after action | ||
buttonSampleB.setAttribute('aria-expanded', 'false'); | ||
drawerSampleB.addEventListener('sd-hide', () => buttonSampleB.setAttribute('aria-expanded', 'false')); | ||
|
||
navigationItemSampleB.addEventListener('click', () => { | ||
drawerSampleB.show(); | ||
buttonSampleB.setAttribute('aria-expanded', 'true'); | ||
}); | ||
}); | ||
</script> | ||
` | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.