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

Use main, footer, nav and their ARIA equivalent for better a11y #365

Merged
merged 1 commit into from
Jun 10, 2021
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
5 changes: 3 additions & 2 deletions src/layouts/core/components/CoreLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ const CoreLayout: React.FunctionComponent<Props> = (props): JSX.Element => {
},
})}
>
<div
<main
role={'main'}
className={layoutName}
css={css`
${layoutBaseCSS || ''}
Expand Down Expand Up @@ -217,7 +218,7 @@ const CoreLayout: React.FunctionComponent<Props> = (props): JSX.Element => {
<Footer />
)
}
</div>
</main>
</Amplitude>
);
};
Expand Down
5 changes: 3 additions & 2 deletions src/layouts/demo/components/DemoFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ const DemoFooter: React.FunctionComponent<Props> = (props) => {
const currentYear = (new Date()).getFullYear();

return (
<div
<footer
id="footer"
role="contentinfo"
className={'footer'}
style={style}
css={css`
Expand Down Expand Up @@ -173,7 +174,7 @@ const DemoFooter: React.FunctionComponent<Props> = (props) => {
/>
</div>
</section>
</div>
</footer>
);
};

Expand Down
101 changes: 53 additions & 48 deletions src/layouts/demo/components/DemoLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,61 +80,66 @@ const DemoLayout: React.FunctionComponent<Props> = (props): JSX.Element => {
},
})}
>
<DemoHead {...headProps} />
<LogOnMount eventType="page-displayed" />

{/* Loaded from components/Head - See https://github.com/mikemaccana/outdated-browser-rework */}
{/*<div*/}
{/* id="outdated"*/}
{/* style={{ display: 'none' }}*/}
{/*></div>*/}
<main
role={'main'}
className={'demo-layout'}
>
<DemoHead {...headProps} />
<LogOnMount eventType="page-displayed" />

{
// XXX You may want to enable preview mode during non-production stages only
process.env.NEXT_PUBLIC_APP_STAGE !== 'production' && (
<PreviewModeBanner />
)
}
{/* Loaded from components/Head - See https://github.com/mikemaccana/outdated-browser-rework */}
{/*<div*/}
{/* id="outdated"*/}
{/* style={{ display: 'none' }}*/}
{/*></div>*/}

{
(!isInIframe || isIframeWithFullPagePreview) && (
<DemoNav />
)
}
{
// XXX You may want to enable preview mode during non-production stages only
process.env.NEXT_PUBLIC_APP_STAGE !== 'production' && (
<PreviewModeBanner />
)
}

<div
className={classnames('page-wrapper', isInIframe ? 'is-in-iframe' : 'not-in-iframe')}
>
{
// If an error happened, we display it instead of displaying the page
// We display a custom error instead of the native Next.js error by providing children (removing children will display the native Next.js error)
error ? (
<ErrorPage
statusCode={500}
isReadyToRender={true}
err={error}
>
<DefaultErrorLayout
error={error}
/>
</ErrorPage>
) : (
<DemoPageContainer
isSidebarOpen={isSidebarOpen}
setIsSidebarOpen={setIsSidebarOpen}
Sidebar={Sidebar}
>
{children}
</DemoPageContainer>
(!isInIframe || isIframeWithFullPagePreview) && (
<DemoNav />
)
}
</div>

{
(!isInIframe || isIframeWithFullPagePreview) && (
<DemoFooter />
)
}
<div
className={classnames('page-wrapper', isInIframe ? 'is-in-iframe' : 'not-in-iframe')}
>
{
// If an error happened, we display it instead of displaying the page
// We display a custom error instead of the native Next.js error by providing children (removing children will display the native Next.js error)
error ? (
<ErrorPage
statusCode={500}
isReadyToRender={true}
err={error}
>
<DefaultErrorLayout
error={error}
/>
</ErrorPage>
) : (
<DemoPageContainer
isSidebarOpen={isSidebarOpen}
setIsSidebarOpen={setIsSidebarOpen}
Sidebar={Sidebar}
>
{children}
</DemoPageContainer>
)
}
</div>

{
(!isInIframe || isIframeWithFullPagePreview) && (
<DemoFooter />
)
}
</main>
</Amplitude>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/layouts/demo/components/DemoNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const DemoNav: React.FunctionComponent<Props> = () => {
{({ logEvent }: { logEvent: LogEvent }): JSX.Element => (
<Navbar
id={'nav'}
role="navigation"
color="#F5F5F5"
light
css={css`
Expand Down
8 changes: 6 additions & 2 deletions src/layouts/quickPreview/components/QuickPreviewBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ const QuickPreviewBanner: React.FunctionComponent<Props> = (props): JSX.Element
const shouldDisplayI18nButton = availableLanguages?.length > 1;

return (
<div className={'quick-preview-banner'}>
<main
// Role is "main" because only this banner is displayed on the page when this component is used (through Stacker)
role="main"
className={'quick-preview-banner'}
>
<div
css={css`
display: inline-flex;
Expand Down Expand Up @@ -149,7 +153,7 @@ const QuickPreviewBanner: React.FunctionComponent<Props> = (props): JSX.Element
}
</div>
</div>
</div>
</main>
);
};

Expand Down
5 changes: 3 additions & 2 deletions src/modules/core/previewMode/components/PreviewModeBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const PreviewModeBanner: React.FunctionComponent<Props> = (props): JSX.Element =
}

return (
<div
<header
role="banner"
css={css`
display: inline-flex;
justify-content: space-between;
Expand Down Expand Up @@ -167,7 +168,7 @@ const PreviewModeBanner: React.FunctionComponent<Props> = (props): JSX.Element =
</Fragment>
)
}
</div>
</header>
);
};

Expand Down