diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json index d872b38e89c..9b4d3801515 100644 --- a/client/i18n/locales/english/translations.json +++ b/client/i18n/locales/english/translations.json @@ -488,6 +488,12 @@ "breadcrumb-nav": "breadcrumb", "submit": "Use Ctrl + Enter to submit.", "running-tests": "Running tests", + "hide-preview": "Hide the preview", + "move-preview-to-new-window": "Move the preview to a new window and focus it", + "move-preview-to-main-window": "Move the preview to this window and close the external preview window", + "close-external-preview-window": "Close the external preview window", + "show-preview": "Show the preview in this window", + "open-preview-in-new-window": "Open the preview in a new window and focus it", "step": "Step", "steps": "Steps", "steps-for": "Steps for {{blockTitle}}" diff --git a/client/src/templates/Challenges/classic/action-row.tsx b/client/src/templates/Challenges/classic/action-row.tsx index 3fedc739580..68a40bd2867 100644 --- a/client/src/templates/Challenges/classic/action-row.tsx +++ b/client/src/templates/Challenges/classic/action-row.tsx @@ -1,4 +1,6 @@ import React from 'react'; +import { faExternalLinkAlt } from '@fortawesome/free-solid-svg-icons'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { useTranslation } from 'react-i18next'; import BreadCrumb from '../components/bread-crumb'; @@ -11,7 +13,8 @@ interface ActionRowProps { showConsole: boolean; showNotes: boolean; showInstructions: boolean; - showPreview: boolean; + showPreviewPane: boolean; + showPreviewPortal: boolean; superBlock: string; togglePane: (pane: string) => void; } @@ -20,7 +23,8 @@ const ActionRow = ({ hasNotes, togglePane, showNotes, - showPreview, + showPreviewPane, + showPreviewPortal, showConsole, showInstructions, isProjectBasedChallenge, @@ -28,6 +32,29 @@ const ActionRow = ({ block }: ActionRowProps): JSX.Element => { const { t } = useTranslation(); + + // sets screen reader text for the two preview buttons + function getPreviewBtnsSrText() { + // no preview open + const previewBtnsSrText = { + pane: t('aria.show-preview'), + portal: t('aria.open-preview-in-new-window') + }; + + // preview open in main window + if (showPreviewPane && !showPreviewPortal) { + previewBtnsSrText.pane = t('aria.hide-preview'); + previewBtnsSrText.portal = t('aria.move-preview-to-new-window'); + + // preview open in external window + } else if (showPreviewPortal && !showPreviewPane) { + previewBtnsSrText.pane = t('aria.move-preview-to-main-window'); + previewBtnsSrText.portal = t('aria.close-external-preview-window'); + } + + return previewBtnsSrText; + } + return (