Skip to content
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

Exclude subsections from SideNav, a11y audit #41

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49,272 changes: 35,223 additions & 14,049 deletions assets/shared-bundle.js

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions assets/tailwind-output.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Copenhagen",
"author": "Sanctuary Computer",
"version": "4.2.15",
"version": "4.2.20",
"api_version": 4,
"default_locale": "en-us",
"settings": [
Expand Down
6 changes: 3 additions & 3 deletions src/modules/homepage/HomepageModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Layers,
} from './Icons';
import { HomepageData, ColoredCardsColor, Article } from '../../lib/types';
import ConnectBlock from './ConnectBlock';

Check warning on line 16 in src/modules/homepage/HomepageModule.tsx

View workflow job for this annotation

GitHub Actions / Lint JS files

'ConnectBlock' is defined but never used
import { HeaderBackgroundMobile } from './HeaderBackgroundMobile';

type Props = {
Expand Down Expand Up @@ -138,18 +138,18 @@
>
<ColoredCardsIconMap icon={card.icon} className="w-6 h-6" color={textColorName} />
<div className="mt-[1.875rem]">
<h4
<h3
className={cn('subheading-1', {
'text-light-orange-vibrant dark:text-dark-orange-vibrant':
textColorName === 'orange-vibrant',
'text-blue-base dark:text-blue-base': textColorName === 'blue-vibrant',
'text-green-base dark:text-green-base': textColorName === 'green-base',
'text-green-base dark:text-green-vibrant': textColorName === 'green-base',
'text-light-pink-vibrant dark:text-dark-pink-vibrant':
textColorName === 'pink-vibrant',
})}
>
{card.title}
</h4>
</h3>
<p className="body-3 text-light-neutral-2 dark:text-dark-neutral-2">
{card.description}
</p>
Expand Down
39 changes: 30 additions & 9 deletions src/modules/side-nav/SideNavModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
className={cn(
'p-padding-large pb-margin-web absolute inset-0 transition category-side-nav w-full overflow-scroll',
{
'opacity-0 pointer-events-none': !navStateIsEmpty,
'opacity-0 pointer-events-none hidden': !navStateIsEmpty,
}
)}
>
Expand All @@ -56,7 +56,12 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
<h3>
<a
href={category.url}
className="transition text-light-neutral-1 dark:text-dark-neutral-1 subheading-2 hover:text-light-accent-1 dark:hover:text-dark-accent-1"
className={cn(
'transition text-light-neutral-1 dark:text-dark-neutral-1 subheading-2 hover:text-light-accent-1 dark:hover:text-dark-accent-1',
{
'!hidden': !navStateIsEmpty,
}
)}
>
{category.name}
</a>
Expand All @@ -67,7 +72,12 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
<li key={section.id} className="mt-2">
<a
href={section.url}
className="transition text-light-neutral-2 dark:text-dark-neutral-2 body-3 hover:text-light-accent-1 dark:hover:text-dark-accent-1 block !leading-[1.4]"
className={cn(
'transition text-light-neutral-2 dark:text-dark-neutral-2 body-3 hover:text-light-accent-1 dark:hover:text-dark-accent-1 block !leading-[1.4]',
{
'!hidden': !navStateIsEmpty,
}
)}
>
{section.name}
</a>
Expand All @@ -84,13 +94,15 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
className={cn(
'p-padding-large pb-margin-web transition absolute inset-0 section-side-nav w-full overflow-scroll',
{
'opacity-0 pointer-events-none': navStateIsEmpty,
'opacity-0 pointer-events-none hidden': navStateIsEmpty,
}
)}
>
<div className="pb-3">
<button
className="group flex flex-row items-center"
className={cn('group flex flex-row items-center', {
'!hidden': navStateIsEmpty,
})}
onClick={() => setActiveNavState({})}
>
<ChevronLeft />
Expand All @@ -113,7 +125,12 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
)}
/>
<div key={`section-nav-${category.id}`}>
<a href={category.url}>
<a
href={category.url}
className={cn({
'!hidden': navStateIsEmpty,
})}
>
<h3
className={cn(
'transition subheading-2 my-3 hover:text-light-accent-1 hover:dark:text-dark-accent-1',
Expand All @@ -133,11 +150,15 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
>
{category.sections.map((section) => {
const sectionIsActive = activeNavState.section === section.id;

return (
<li key={section.id} className="mt-4 first:mt-6">
<button
className="w-full group flex flex-row space-x-0.5 items-center justify-between"
className={cn(
'w-full group flex flex-row space-x-0.5 items-center justify-between',
{
'!hidden': navStateIsEmpty,
}
)}
onClick={() => handleSectiontoggle(section.id)}
>
<span
Expand Down Expand Up @@ -165,7 +186,6 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
<div className="overflow-hidden">
{section.articles.map((article) => {
const isActiveArticle = activeNavState.article === article.id;

return (
<li key={article.id} className="mt-2 first:mt-4">
<a
Expand All @@ -177,6 +197,7 @@ export const SideNav: FC<Props> = ({ sideNavData, navState }) => {
isActiveArticle,
'text-light-neutral-2 dark:text-dark-neutral-2':
!isActiveArticle,
'!hidden': navStateIsEmpty,
}
)}
>
Expand Down
12 changes: 6 additions & 6 deletions src/modules/side-nav/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type SideNavApiResponse = {
html_url: string;
name: string;
position: number;
parent_section_id: number | null;
}[];
};

Expand All @@ -44,7 +45,7 @@ const sanitizeResponse = (response: SideNavApiResponse): SideNavData => {

const categories = response.categories.map((category) => {
const sections = response.sections
.filter((section) => section.category_id === category.id)
.filter((section) => section.category_id === category.id && !section.parent_section_id)
.map((section) => {
const articles = response.articles
.filter((article) => article.section_id === section.id)
Expand Down Expand Up @@ -79,13 +80,13 @@ const sanitizeResponse = (response: SideNavApiResponse): SideNavData => {
export const sideNav = {
get: async (): Promise<SideNavData> => {
const storedSideNavData = SideNavDataManager.get();
const expriresAt = storedSideNavData?.expriresAt;

if (expriresAt && expriresAt > Date.now() && storedSideNavData.data) {
const expiresAt = storedSideNavData?.expiresAt;
if (expiresAt && expiresAt > Date.now() && storedSideNavData.data) {
return storedSideNavData.data;
} else {
SideNavDataManager.clear();
}
SideNavDataManager.clear();

const url = `${window.location.origin}/api/v2/help_center/en-us/articles.json?include=categories,sections&per_page=100`;

Expand All @@ -96,7 +97,6 @@ export const sideNav = {
}

const responseData = await response.json();

if (responseData.page_count <= 1) {
return sanitizeResponse(responseData);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ export const sideNav = {

SideNavDataManager.set({
// Set it like this for now since the client wants to QA the side nav with different items
expriresAt: Date.now() + 5000,
expiresAt: Date.now() + 5000,
// TODO: uncomment the line below before launch
// expriresAt: Date.now() + millisecondsIn24Hours,
data: sanitizedResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LocalStorageManager<T> {
}

export const SideNavDataManager = new LocalStorageManager<{
expriresAt: number;
expiresAt: number;
data: SideNavData;
}>('SIDE_NAV_DATA');

Expand Down
20 changes: 10 additions & 10 deletions style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions templates/home_page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
title: 'Frequently Asked Questions',
description: 'Answers to our top ten questions',
color: 'pink',
url: '/hc/en-us/sections/32172915881485',
url: '/hc/en-us/articles/32601103371917-FAQs',
},
{
icon: 'lightbulb',
Expand Down Expand Up @@ -151,4 +151,4 @@
// add setTimeout to ensure the mobile nav is added after mobile menu appears on DOM first
setTimeout(() => addMobileNav(sideNavData), 100);
});
</script>
</script>
Loading