User Story
As a reader, I want to be able to see a shorter version of the ToC so that I can scan it more quickly
Design Spec
collapsed state | expanded state |
- When a section is collapsed, all of its subsections are hidden.
- When a section is expanded, all of its subsections are visible.
- Collapsing/expanding behaviour only applies to top-level sections.
UI Behaviour
When clicking on a ToC section link:
- It should "activate" (scroll to corresponding section and bolden the text)
- The corresponding ToC section should expand
Default states
- Collapsed by default: Sections should expand when clicking the top-level section headings.
- Expanded by default (potentially in the future):-sections should remain expanded when scrolling and clicking. No collapsing should occur.
Prototype
https://di-toc-phase2.web.app/Silver
A11Y & I18N considerations
- The arrow should point left for RTL languages when collapsed (◀) and be aligned with the beginning of the text.
- This feature (expanding and collapsing) should be disabled for users with the prefers-reduced-motion flag enabled in their browser. With this flag enabled, the ToC should essentially fall back to the no-js version.
no-js version
Given that expanding and collapsing on scroll requires Javascript, this feature should be limited to browsers with JS enabled. If javascript is disabled, the table of contents should just be expanded by default and the arrows should not appear.
Acceptance Criteria
- Sections will have the ability to collapse and uncollapse the subsections within them
- Collapsing and uncollapsing will be achieved by selecting the section name
- Sections will be collapsed by default when total section count is >= 20
- [] A unit test should be added to Vector modelling the behaviour
QA Results - Beta
AC | Status | Details |
---|---|---|
1 | ❌ | T299361#7745195 |
2 | ✅ | T299361#7745195 |
3 | ❓ | T299361#7745195 |