-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 850c258
Showing
23 changed files
with
1,386 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Christopher. Najman | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,50 @@ | ||
# Accessible Mobile Menu | ||
|
||
A responsive mobile menu that prioritizes accessibility features for screen readers and keyboard users. | ||
|
||
## Description | ||
|
||
The mobile menu is designed to be responsive, and is visible on screens less than 768px wide. It is initially hidden and appears upon clicking the hamburger menu button. | ||
|
||
## Accessibility Features | ||
|
||
### Screen Reader Accessibility | ||
|
||
The menu is accessible to screen readers through the use of appropriate ARIA attributes. | ||
|
||
#### ARIA Attributes Used | ||
|
||
- `aria-controls="site-navigation"`: Associates the hamburger button with the site navigation menu. | ||
- `aria-expanded="false" / aria-expanded="true"`: Dynamically updates the state of the navigation menu, indicating whether it's expanded or collapsed. | ||
|
||
### Keyboard Accessibility | ||
|
||
The menu ensures accessibility for keyboard users by allowing them to navigate to the hamburger button using the keyboard's tab functionality. Once focused on the button, users can press the 'enter' key to toggle the visibility of the menu. This behavior ensures that keyboard users can interact with the menu effectively, enabling them to open and close it without relying on mouse interactions. | ||
|
||
## Usage | ||
|
||
### HTML Structure | ||
|
||
The HTML structure comprises a div element with an ID of `primary-navigation`, containing the hamburger button and the navigation menu. | ||
|
||
### CSS | ||
|
||
The CSS defines the styles for the mobile menu and the hamburger button, including responsive design for different screen sizes. | ||
|
||
### JavaScript Functionality | ||
|
||
The JavaScript function `btnHamburger()` handles the click event on the hamburger button, toggling the visibility of the navigation menu and updating ARIA attributes accordingly. | ||
|
||
## Source | ||
|
||
- The animation on the button is based on the basic version of [Basic, Intermediate & Pro animated hamburger icons](https://youtu.be/R00QiudbD4Y?si=VDTxfeCotRcLGnGx). | ||
|
||
## Testing | ||
|
||
Tested on Windows 10 with: | ||
|
||
- Chrome | ||
- Firefox | ||
- Microsoft Edge | ||
|
||
The page has been tested in both browser and device views. |
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,281 @@ | ||
*, | ||
*::after { | ||
box-sizing: border-box; | ||
margin: 0; | ||
} | ||
|
||
html { | ||
overflow-y: scroll; | ||
font-size: 10px; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
html, | ||
html:focus-within { | ||
scroll-behavior: smooth; | ||
} | ||
} | ||
|
||
:root { | ||
--font-sans: system-ui, sans-serif; | ||
--font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, serif; | ||
--font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, "DejaVu Sans Mono", monospace; | ||
--horz-center: 0 auto; | ||
--flex: flex; | ||
--grid: grid; | ||
} | ||
|
||
ul:empty, | ||
p:empty { | ||
display: none; | ||
} | ||
|
||
body { | ||
background-color: var(--body-bg); | ||
color: var(--body-txt); | ||
font-family: var(--font-sans); | ||
margin: 0; | ||
line-height: 1.5; | ||
font-size: clamp(1.5rem, 1.35rem + 0.4vw, 1.8rem); | ||
} | ||
|
||
h1 { | ||
font-size: clamp(2.4rem, 2.2rem + 0.8889vw, 3.2rem); | ||
line-height: 1.3; | ||
@media screen and (width < 360px) { | ||
padding: 0 1rem; | ||
} | ||
} | ||
|
||
h2 { | ||
font-size: clamp(2rem, 1.9rem + 0.4444vw, 2.4rem); | ||
} | ||
|
||
h3 { | ||
font-size: clamp(1.6rem, 1.525rem + 0.3333vw, 1.9rem); | ||
margin-bottom: 1rem; | ||
} | ||
|
||
h1 { | ||
font-weight: 400; | ||
} | ||
|
||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6 { | ||
line-height: 1.1; | ||
} | ||
|
||
h2 { | ||
text-align: center; | ||
margin-bottom: 3rem; | ||
} | ||
|
||
img { | ||
max-width: 100%; | ||
height: auto; | ||
vertical-align: middle; /* replaces display: block but also removes space below */ | ||
font-style: italic; | ||
} | ||
|
||
ul[role="list"] { | ||
list-style: none; | ||
padding-left: 0; | ||
} | ||
|
||
code, | ||
pre { | ||
font-family: var(--font-mono); | ||
} | ||
|
||
:focus-visible { | ||
outline: 3px solid var(--highlight); | ||
outline-offset: 3px; | ||
} | ||
|
||
button { | ||
all: unset; | ||
color: inherit; | ||
cursor: pointer; | ||
} | ||
|
||
.page-layout { | ||
min-height: 100vh; | ||
min-height: 100dvh; | ||
display: var(--grid); | ||
grid-template-rows: auto 1fr auto; | ||
} | ||
|
||
.page-header { | ||
padding: 3.2rem 0; | ||
@media screen and (width < 360px) { | ||
padding-inline: 1rem; | ||
padding-top: 5rem; | ||
} | ||
|
||
& p { | ||
text-wrap: balance; | ||
padding-inline: 1rem; | ||
max-width: 60ch; | ||
margin: var(--horz-center); | ||
} | ||
} | ||
|
||
.main { | ||
max-width: 80rem; | ||
margin: var(--horz-center); | ||
padding: 5rem 2rem; | ||
display: var(--flex); | ||
flex-direction: column; | ||
|
||
& p { | ||
margin-bottom: 2.5rem; | ||
} | ||
} | ||
|
||
.page-footer { | ||
padding: 3.2rem 0; | ||
} | ||
|
||
.page-header, | ||
.page-footer { | ||
background-color: var(--clr-darkest); | ||
color: var(--clr-lightest); | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2rem; | ||
} | ||
|
||
.page-header a, | ||
.page-footer a { | ||
color: var(--clr-lightest); | ||
text-decoration: none; | ||
} | ||
|
||
.page-header ul, | ||
.page-footer ul { | ||
display: flex; | ||
gap: 1rem; | ||
} | ||
|
||
.page-footer { | ||
& a:hover { | ||
text-decoration: underline; | ||
} | ||
|
||
& a::after { | ||
content: " \27F6"; | ||
} | ||
|
||
& ul { | ||
flex-direction: column; | ||
} | ||
} | ||
|
||
.icon-logo { | ||
fill: var(--clr-lightest); | ||
width: 3.6rem; | ||
height: 3.6rem; | ||
margin: var(--horz-center); | ||
} | ||
|
||
.article { | ||
max-width: 100rem; | ||
margin: var(--horz-center); | ||
padding: 3rem 0 8rem; | ||
display: var(--flex); | ||
flex-direction: column; | ||
gap: 3rem; | ||
|
||
& h2 { | ||
text-align: center; | ||
margin: 1rem 0; | ||
text-transform: capitalize; | ||
} | ||
|
||
& p:first-of-type { | ||
max-width: 60ch; | ||
} | ||
|
||
& section { | ||
display: var(--flex); | ||
flex-direction: column; | ||
gap: 2.5rem; | ||
} | ||
} | ||
|
||
/** Helpers */ | ||
/* Scrollable container for tables */ | ||
[role="region"][aria-labelledby][tabindex] { | ||
overflow: auto; | ||
} | ||
|
||
/* Skip link */ | ||
.skip-link { | ||
color: var(--clr-lightest); | ||
text-decoration: none; | ||
font-weight: 600; | ||
padding: 0.5rem 1rem; | ||
|
||
&::after { | ||
content: " \2193"; | ||
} | ||
} | ||
.element-invisible { | ||
clip: rect(1px, 1px, 1px, 1px); | ||
height: 1px; | ||
overflow: hidden; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
z-index: 200; | ||
border-bottom: 5px solid transparent; | ||
&.element-focusable:active, | ||
&.element-focusable:focus { | ||
clip: auto; | ||
height: auto; | ||
overflow: visible; | ||
border-bottom-color: var(--clr-lightest); | ||
} | ||
} | ||
|
||
/* Screenreader only */ | ||
.visually-hidden { | ||
position: absolute; | ||
width: 1px; | ||
height: 1px; | ||
padding: 0; | ||
margin: -1px; | ||
overflow: clip; | ||
clip-path: inset(0); | ||
border: 0; | ||
} | ||
|
||
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */ | ||
@media (prefers-reduced-motion: reduce) { | ||
html, | ||
html:focus-within { | ||
scroll-behavior: auto; | ||
} | ||
*, | ||
*::before, | ||
*::after { | ||
animation-duration: 0.01ms !important; | ||
animation-iteration-count: 1 !important; | ||
transition-duration: 0.01ms !important; | ||
scroll-behavior: auto !important; | ||
transition-delay: 0ms !important; | ||
} | ||
} | ||
|
||
.warning { | ||
color: var(--clr-warning); | ||
font-weight: 600; | ||
} | ||
/* Always comes last **/ | ||
.hide { | ||
display: none; | ||
} |
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 @@ | ||
@import "./theme.css"; | ||
@import "./base.css"; | ||
@import "./primary-navigation.css"; | ||
/* @import "./hamburger-button.css"; */ | ||
|
||
@import "./theme-switcher.css"; |
Oops, something went wrong.