Skip to content

Commit 0dea4d8

Browse files
committed
Tab navigation improvement for the docs sidebar.
1 parent 41035fb commit 0dea4d8

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

theme/docs.less

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
@docsCardBorderColor: #e9eef2;
3131
@docsCardHoverBorderColor: #1dacf4;
32+
@docsCardFocusBorderColor: #0078D4; // --pxt-focus-border not available in iframed documentation
3233

3334
#docs .footer,
3435
#docs .topbar,
@@ -219,6 +220,7 @@
219220
#sidedocs-back-button {
220221
margin-top: 1.25rem;
221222
margin-left: 1.25rem;
223+
margin-right: 5rem; // Safety margin for the "open in new tab" button
222224
cursor: pointer;
223225
user-select: none;
224226
color: var(--pxt-page-foreground);
@@ -227,6 +229,11 @@
227229
&:hover {
228230
text-decoration: none;
229231
}
232+
233+
&:focus-visible {
234+
outline: 3px solid @docsCardFocusBorderColor;
235+
outline-offset: 3px;
236+
}
230237
}
231238

232239
#sidedocs-back-button.disabled {
@@ -483,6 +490,10 @@
483490

484491
.sideDocs #sidedocsbar a {
485492
color: @docsLinkColor;
493+
&:focus-visible {
494+
outline: 3px solid var(--pxt-focus-border);
495+
outline-offset: 3px;
496+
}
486497
}
487498

488499
.replaceDocsAvatar() when not (@docsAvatarImage = none) {

webapp/src/container.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,14 @@ export interface SideDocsState {
608608
interface BuiltInHelpDetails {
609609
component: () => JSX.Element;
610610
popOutHref: string;
611+
singleTabStop: boolean; // if the whole doc is only one tab stop, the "open in new tab" button placement becomes unintuitive.
611612
}
612613

613614
const builtIns: Record<pxt.editor.BuiltInHelp, BuiltInHelpDetails> = {
614615
"keyboardControls": {
615616
component: KeyboardControlsHelp,
616-
popOutHref: "https://makecode.com/accessibility"
617+
popOutHref: "https://makecode.com/accessibility",
618+
singleTabStop: true
617619
}
618620
}
619621

@@ -778,20 +780,27 @@ export class SideDocs extends data.Component<SideDocsProps, SideDocsState> {
778780
tabIndex: 0,
779781
};
780782

783+
const openInSidebar = !lockedEditor && <div className="ui app hide" id="sidedocsbar">
784+
<a className="ui icon link" aria-label={lf("Open documentation in new tab")} {...openInNewTabLinkProps}>
785+
<sui.Icon icon="external" />
786+
</a>
787+
</div>;
788+
789+
const content = <div id="sidedocsframe-wrapper">
790+
{this.renderContent(url, builtIn, lockedEditor)}
791+
</div>;
792+
793+
const flipNewTabLinkOrder = builtIn?.singleTabStop;
794+
795+
const contentParts = flipNewTabLinkOrder ? [content, openInSidebar] : [openInSidebar, content];
796+
781797
/* eslint-disable @microsoft/sdl/react-iframe-missing-sandbox */
782798
return <div>
783799
<button id="sidedocstoggle" role="button" aria-label={sideDocsCollapsed ? lf("Expand the side documentation") : lf("Collapse the side documentation")} className="ui icon button large" onClick={this.toggleVisibility}>
784800
<sui.Icon icon={`icon inverted chevron ${showLeftChevron ? 'left' : 'right'}`} />
785801
</button>
786802
<div id="sidedocs" onKeyDown={this.handleKeyDown}>
787-
{!lockedEditor && <div className="ui app hide" id="sidedocsbar">
788-
<a className="ui icon link" aria-label={lf("Open documentation in new tab")} {...openInNewTabLinkProps}>
789-
<sui.Icon icon="external" />
790-
</a>
791-
</div>}
792-
<div id="sidedocsframe-wrapper">
793-
{this.renderContent(url, builtIn, lockedEditor)}
794-
</div>
803+
{contentParts}
795804
</div>
796805
</div>
797806
/* eslint-enable @microsoft/sdl/react-iframe-missing-sandbox */

0 commit comments

Comments
 (0)