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

fix(accessibilityFixes): Accessibility Fixes #27

Merged
merged 10 commits into from
Mar 11, 2025
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
1 change: 1 addition & 0 deletions src/lib/HealNav/HealHeader.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await expect(canvas.getByTestId('heal-header')).toBeInTheDocument();
await expect(canvas.getByTestId('skip-to-main')).toBeInTheDocument();
},
};
79 changes: 46 additions & 33 deletions src/lib/HealNav/HealHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,55 @@ const generateLinkClassNames = (i: number) => {

const HealHeader: React.FC = () => {
return (
<header data-testid="heal-header">
<div className="bg-carousel-gradient h-2"></div>
<div className="container mx-auto px-1 md:px-1 lg:px-6 py-4 text-xs">
<div className="lg:flex justify-between">
<a
href={navigation.logo.href}
className="flex hover:underline justify-center mb-5 md:mb-0 lg:justify-normal"
>
<Image
src={navigation.logo.src}
alt={navigation.logo.alt}
width={navigation.logo.width}
height={navigation.logo.height}
className="w-[60px] border-r-1 pr-3"
/>
<div className="text-heal-dark_gray font-semibold text-base pl-3 mt-1">
{navigation.title}
<div>
<a
href="#main-content"
data-testid="skip-to-main"
className="absolute -left-full focus:static text-heal-blue"
>
Skip to main content
</a>
<header data-testid="heal-header">
<div className="bg-carousel-gradient h-2"></div>
<div className="container mx-auto px-1 md:px-1 lg:px-6 py-4 text-xs">
<div className="lg:flex justify-between">
<a
href={navigation.logo.href}
className="flex hover:underline justify-center mb-5 md:mb-0 lg:justify-normal"
>
<Image
src={navigation.logo.src}
alt={navigation.logo.alt}
width={navigation.logo.width}
height={navigation.logo.height}
className="w-[60px] border-r-1 pr-3"
/>
<div className="text-heal-dark_gray font-semibold text-base pl-3 mt-1">
{navigation.title}
</div>
</a>
<div className="flex flex-wrap justify-center lg:justify-normal mt-4 lg:mt-1">
{navigation.items.map((item, i) => (
<a
key={i}
href={item.href}
className={generateLinkClassNames(i)}
>
<Image
src={item.icon}
alt=""
width={16}
height={16}
className="mr-2 ml-1 mt-[-2px] h-[16px] lg:ml-4"
/>
{item.name}
</a>
))}
</div>
</a>
<div className="flex flex-wrap justify-center lg:justify-normal mt-4 lg:mt-1">
{navigation.items.map((item, i) => (
<a key={i} href={item.href} className={generateLinkClassNames(i)}>
<Image
src={item.icon}
alt=""
width={16}
height={16}
className="mr-2 ml-1 mt-[-2px] h-[16px] lg:ml-4"
/>
{item.name}
</a>
))}
</div>
</div>
</div>
</header>
</header>
</div>
);
};

Expand Down
15 changes: 15 additions & 0 deletions src/lib/HealNav/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Head from 'next/head';

interface PageTitleProps {
pageName: string;
}

const PageTitle: React.FC<PageTitleProps> = ({ pageName }) => {
return (
<Head>
<title>{`${pageName} | HEAL Data Platform`}</title>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we compensate for if pageName is not provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok for now

  • If another DEV creates a page using the PageTitle component, TypesScript will require that they pass the pageName prop with a string
  • If a page is created without the PageTitle component, the user's web browser will display the URL of the page or the name of the website as the title in the title bar or tab. In some cases, it may also show "Untitled" or a similar default message, depending on the browser being used.
  • If we need different functionality going forward, like pages with a default page title such as only "HEAL Data Platform" we can add that functionality when needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good

</Head>
);
};

export default PageTitle;
5 changes: 4 additions & 1 deletion src/lib/Home/Components/QuoteSpotlight/QuoteSpotlight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import Background from '../../Assets/Images/background.webp';
/** UI component for displaying a quote and attribution */
const QuoteSpotlight: React.FC = () => {
return (
<div data-testid="quote-spotlight" className="text-center mt-6 text-white">
<div
data-testid="quote-spotlight"
className="text-center mt-6 text-white bg-heal-background"
>
<BackgroundImage
className="m:h-[269px] md:h-[321px] lg:h-[272px] flex items-center justify-center"
src={Background.src}
Expand Down
1 change: 1 addition & 0 deletions src/lib/NewlyAvailableDatasets/CardedPageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const CardedPageContent = ({
<div className="text-md pl-10 pb-4">
<Text
data-testid="carded-page-content-title"
component="h1"
className="not-prose font-bold text-4xl text-gen3-coal font-montserrat pb-8"
>
{title}
Expand Down
10 changes: 4 additions & 6 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@ import QuickLinks from '../lib/Home/Components/QuickLinks/QuickLinks';
import PhotoDivider from '../lib/Home/Components/PhotoDivider/PhotoDivider';
import ContentSpotlight from '../lib/Home/Components/ContentSpotlight/ContentSpotlight';
import QuoteSpotlight from '../lib/Home/Components/QuoteSpotlight/QuoteSpotlight';
import HealHeader from '@/lib/HealNav/HealHeader';
import HealFooter from '@/lib/HealNav/HealFooter';
import PageTitle from '@/lib/HealNav/PageTitle';

const HealLandingPage = () => {
return (
<div className="w-full">
<HealHeader />
<>
<PageTitle pageName="Home" />
<Hero />
<CarouselBanner />
<QuickLinks />
<PhotoDivider />
<ContentSpotlight />
<QuoteSpotlight />
<HealFooter />
</div>
</>
);
};

Expand Down
27 changes: 26 additions & 1 deletion src/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import Document, { DocumentContext, DocumentInitialProps } from 'next/document';
import Document, {
DocumentContext,
DocumentInitialProps,
Html,
Head,
Main,
NextScript,
} from 'next/document';
import { ColorSchemeScript } from '@mantine/core';
import HealHeader from '@/lib/HealNav/HealHeader';
import HealFooter from '@/lib/HealNav/HealFooter';

class Gen3Document extends Document {
static async getInitialProps(
Expand All @@ -16,6 +25,22 @@ class Gen3Document extends Document {
),
};
}

render() {
return (
<Html lang="en">
<Head />
<body className="flex flex-col min-h-screen">
<HealHeader />
<main id="main-content" className="flex-grow">
<Main />
<NextScript />
</main>
<HealFooter />
</body>
</Html>
);
}
}

export default Gen3Document;
10 changes: 4 additions & 6 deletions src/pages/newly-available-datasets.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React from 'react';
import HealHeader from '@/lib/HealNav/HealHeader';
import HealFooter from '@/lib/HealNav/HealFooter';
import CardedPageContent from '@/lib/NewlyAvailableDatasets/CardedPageContent';
import newDatasetsPageConfig from '../../config/heal/newDatasets.json';
import PageTitle from '@/lib/HealNav/PageTitle';

const NewlyAvailableDatasetsPage = () => {
return (
<div className="w-full">
<HealHeader />
<>
<PageTitle pageName="Newly Available Datasets" />
<div className="flex flex-row justify-items-center">
<div className="sm:prose-base lg:prose-lg xl:prose-xl 2xl:prose-xl mx-20">
<CardedPageContent {...newDatasetsPageConfig} />
</div>
</div>
<HealFooter />
</div>
</>
);
};

Expand Down