From 7d32ec80d35be151f4c7061901dc43c0f04b0e63 Mon Sep 17 00:00:00 2001 From: Jan Drewniak Date: Mon, 7 Feb 2022 14:20:17 -0500 Subject: [PATCH] Collapse ToC by default & expand sections when clicking section headings Collapses sub-sections in the new table of contents by default (except for non-js and reduced-motion users) and expands the sections when the top-level section link has been clicked. Refactors the `activateSection` TableOfContents methods into separate `activateSection` and `deactivateSection` functions. Adds `expandSection` and `collapseSection` methods. Adds triangle icon as a visual expand/collapsed indicator next to all ToC section headings and are hidden via CSS based on whether or not the section contains subsections. Adds test for tableOfContents. Bug: T299361 Change-Id: I36b3ae7f9f633877683bc17a9444c970d7fa7293 --- includes/templates/TableOfContents.mustache | 2 +- .../templates/TableOfContents__line.mustache | 2 +- .../TableOfContents__topSection.mustache | 13 ++ resources/skins.vector.es6/main.js | 8 +- resources/skins.vector.es6/tableOfContents.js | 206 ++++++++++++++---- .../components/TableOfContents.less | 82 +++++-- skin.json | 3 +- tests/jest/tableOfContents.test.js | 100 +++++++++ 8 files changed, 349 insertions(+), 67 deletions(-) create mode 100644 includes/templates/TableOfContents__topSection.mustache create mode 100644 tests/jest/tableOfContents.test.js diff --git a/includes/templates/TableOfContents.mustache b/includes/templates/TableOfContents.mustache index 0a6b6f708..99a17d8d6 100644 --- a/includes/templates/TableOfContents.mustache +++ b/includes/templates/TableOfContents.mustache @@ -4,7 +4,7 @@ diff --git a/includes/templates/TableOfContents__line.mustache b/includes/templates/TableOfContents__line.mustache index 32b180952..7f7b11feb 100644 --- a/includes/templates/TableOfContents__line.mustache +++ b/includes/templates/TableOfContents__line.mustache @@ -3,7 +3,7 @@ -