Skip to content
Draft
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
27 changes: 23 additions & 4 deletions src/app/content/components/SidebarControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,29 @@ const lockSearchControlState = (isOpen: boolean, Control: React.ComponentType<In
`);

// tslint:disable-next-line: variable-name
export const OpenTOCControl = lockTocControlState(false, TOCControl);
export const TOCControlButton = tocConnector(({open, close, isOpen, ...props}: MiddleProps) => {
// tslint:disable-next-line: variable-name
const Tag = isOpen ? OpenButton : CloseButton;

// tslint:disable-next-line: variable-name
export const CloseTOCControl = lockTocControlState(true, TOCControl);
return (
<Tag
{...props}
data-testid='toc-button'
aria-label={useIntl().formatMessage({ id: 'i18n:toolbar:toc:text' })}
aria-expanded={isOpen === true}
aria-controls='toc-sidebar'
data-analytics-label={`Click to ${isOpen ? 'close' : 'open'} the Table of Contents`}
onClick={isOpen ? close : open}
isOpen={null}
isActive={Boolean(props.showActivatedState) && isOpen === true}
>
<TocIcon />
<ButtonText>
{useIntl().formatMessage({ id: 'i18n:toolbar:toc:text' })}
</ButtonText>
</Tag>
);
});

// tslint:disable-next-line:variable-name
export const TOCCloseButton = (lockTocControlState(true, CloseTOC));
Expand All @@ -233,7 +252,7 @@ export const TOCBackButton = styled(TOCCloseButton)`
`;

// tslint:disable-next-line: variable-name
export const StyledOpenTOCControl = styled(OpenTOCControl)`
export const StyledOpenTOCControl = styled(lockTocControlState(false, TOCControl))`
display: flex;
padding: 0;
min-height: unset;
Expand Down
1 change: 1 addition & 0 deletions src/app/content/components/TableOfContents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export class TableOfContents extends Component<SidebarProps, { expandedKeys: Set
<TocHeader />
{book && (
<Styled.StyledTree
id='toc-sidebar'
aria-label='Table of Contents'
expandedKeys={this.state.expandedKeys}
onExpandedChange={this.handleExpandedChange}
Expand Down
6 changes: 2 additions & 4 deletions src/app/content/components/Toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import { NudgeElementTarget } from '../NudgeStudyTools/styles';
import {
CloseSearchControl,
CloseToCAndMobileMenuButton,
CloseTOCControl,
OpenSearchControl,
OpenTOCControl
TOCControlButton
} from '../SidebarControl';
import HighlightButton from './HighlightButton';
import PracticeQuestionsButton from './PracticeQuestionsButton';
Expand Down Expand Up @@ -67,8 +66,7 @@ const VerticalNav = () => {
>
{isMobileMenuOpen && <MobileMenu />}
<Styled.ToolbarElements>
<OpenTOCControl showActivatedState />
<CloseTOCControl showActivatedState />
<TOCControlButton showActivatedState />
{showSearchInSidebar ? (
<>
<OpenSearchControl showActivatedState data-experiment />
Expand Down
Loading