The table of contents in Vector 2022 can appear in 4 different places:
| In the sidebar | Beside the page title | In the sticky header | Pinned to the edge of the screen |
The code for these positions currently resides in tableOfContents.less and tableOfContentsCollapsed.less.
We should draw clearer distinctions between these 4 different ToC states by separating out the code responsible for them. The logic can be split into 5 different files:
- tableOfContentsBase.less - containing the styles for the actual ToC list items, as well as any hide/show behaviour shared across the different placements.
- tableOfContentsSidebar.less - styles for the ToC in the sidebar.
- tableOfContentsHeader.less - styles for the ToC near the page title.
- tableOfContentsStickyHeader.less - styles for the ToC when it's in the sticky header.
- tableOfContentsPinned.less - styles for the ToC when it's pinned to the edge of the screen, at lower resolutions.
For the most part, the logic determining these placements is based on breakpoints and whether the ToC has been "hidden".
IF viewport greater than 1000px:
hidden false: in sidebar
hidden true: in header AND in sticky header
IF viewport less than 1000px:
hidden false: in header
hidden true: in header
scrolled below title: pinned to edge.
This refactor should structure the code in a way that clarifies this logic.
Pixel tests should also be added to account for the different placements and expanded/collapsed states.



