From 6dd8c6241be330bd3b32b7af6756f60473fc88c7 Mon Sep 17 00:00:00 2001 From: Divyansh Singh Date: Thu, 6 Oct 2022 00:13:00 +0530 Subject: [PATCH] feat: add hidden skip-to-content button (#47577) * feat: add skip-to-content button * fix: remove content start ids from everywhere and add to default layout * chore: format landing-top.tsx * use single quotes in skip-to-content component * include breadcrumbs in navigation * linting fail fix * use anchor tag instead of new component * update challenge title snap * fix(test): reliably move focus onto the editor Co-authored-by: Oliver Eyton-Williams --- client/src/components/Header/header.css | 12 +++++ client/src/components/Header/index.tsx | 3 ++ client/src/components/Intro/index.tsx | 2 +- client/src/components/layouts/default.tsx | 19 +++++++- .../Challenges/classic/action-row.tsx | 11 +---- .../Challenges/classic/desktop-layout.tsx | 6 --- .../templates/Challenges/classic/editor.css | 3 +- .../src/templates/Challenges/classic/show.tsx | 9 ---- .../templates/Challenges/codeally/show.tsx | 2 - .../challenge-title.test.tsx.snap | 35 -------------- .../Challenges/components/challenge-title.css | 1 - .../components/challenge-title.test.tsx | 2 - .../Challenges/components/challenge-title.tsx | 8 ---- .../Challenges/projects/backend/Show.tsx | 2 - .../Challenges/projects/frontend/Show.tsx | 2 - .../src/templates/Challenges/video/Show.tsx | 2 - client/utils/gatsby/layout-selector.tsx | 13 ++++- .../default/learn/challenges/output.js | 47 ++++++++----------- 18 files changed, 67 insertions(+), 112 deletions(-) diff --git a/client/src/components/Header/header.css b/client/src/components/Header/header.css index 29ed47851b4..34010ecf6de 100644 --- a/client/src/components/Header/header.css +++ b/client/src/components/Header/header.css @@ -4,3 +4,15 @@ header { width: 100%; z-index: 200; } +.skip-to-content-button { + position: absolute; + top: var(--header-height); + border-radius: 15px; + font-weight: 600; + padding-block: 1em; + padding-inline: 1.5em; + left: -1000px; +} +.skip-to-content-button:focus { + left: 0px; +} diff --git a/client/src/components/Header/index.tsx b/client/src/components/Header/index.tsx index 6b9bed4da48..01644bbf54a 100644 --- a/client/src/components/Header/index.tsx +++ b/client/src/components/Header/index.tsx @@ -91,6 +91,9 @@ export class Header extends React.Component<
+ + Skip To Content + -

+

{name ? `${t('learn.welcome-1', { name: name })}` : `${t('learn.welcome-2')}`} diff --git a/client/src/components/layouts/default.tsx b/client/src/components/layouts/default.tsx index c6588e8d60f..557738f4ad7 100644 --- a/client/src/components/layouts/default.tsx +++ b/client/src/components/layouts/default.tsx @@ -26,6 +26,7 @@ import { userFetchStateSelector } from '../../redux/selectors'; import { UserFetchState, User } from '../../redux/prop-types'; +import BreadCrumb from '../../templates/Challenges/components/bread-crumb'; import Flash from '../Flash'; import { flashMessageSelector, removeFlashMessage } from '../Flash/redux'; @@ -84,6 +85,9 @@ interface DefaultLayoutProps extends StateProps, DispatchProps { children: ReactNode; pathname: string; showFooter?: boolean; + isChallenge?: boolean; + block?: string; + superBlock?: string; t: TFunction; useTheme?: boolean; } @@ -133,6 +137,9 @@ class DefaultLayout extends Component { isSignedIn, removeFlashMessage, showFooter = true, + isChallenge = false, + block, + superBlock, t, theme = 'default', user, @@ -211,7 +218,17 @@ class DefaultLayout extends Component { removeFlashMessage={removeFlashMessage} /> ) : null} - {fetchState.complete && children} + {isChallenge && ( +
+ +
+ )} +
+ {fetchState.complete && children} +
{showFooter &&