Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 Entry Emulator - sidebar table of contents #2869

Merged
merged 17 commits into from
Nov 6, 2023
Merged

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Oct 28, 2023

Adds support for sidebars in Gdocs articles. Luckily, because the sdg-toc was already an extension of the original site TableOfContents, required changes were minimal 🙌

Marwa had given the component a refresh on figma, but when I began working on this I realized it wouldn't really work. It has to be an overlay because we have textual and graphic content that goes full width.

Thus, an overlay it is (and one that isn't exactly integrated with our grid system either 🙈.)

image

There's an issue where scrolling doesn't always correctly update the highlighted heading in the sidebar. I'll check with Matthieu if he has any ideas, but first wanted to validate this overall solution with the team before working on it further.

Also need to test on more browsers.

@@ -23,6 +23,118 @@
color: $vermillion !important;
}
}

.toc-wrapper {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of this duplicates the existing site sidebar CSS because much of that CSS is stuck inside media queries (because for old-style entries, the sidebar is always open on xxlg, which we can't do here because it would obscure full-width content beneath it)

@ikesau ikesau requested review from mlbrgl and removed request for danyx23 October 30, 2023 16:46
Copy link
Member

@mlbrgl mlbrgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(WIP)

@@ -168,6 +168,7 @@ const migrate = async (): Promise<void> => {
// Provide an empty array to prevent the sticky nav from rendering at all
// Because if it isn't defined, it tries to automatically populate itself
"sticky-nav": isEntry ? [] : undefined,
"sidebar-toc": true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be only true for entries?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% 🙃

Copy link
Member

@mlbrgl mlbrgl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool that we can piggyback on the SDG table of contents, nicely done!

There's an issue where scrolling doesn't always correctly update the highlighted heading in the sidebar.

Let me know what you meant here and I can take a look.

const supertitleString = supertitle
? spansToSimpleString(supertitle)
: ""
if (titleString && (level === primary || level === secondary)) {
toc.push({
title: titleString,
supertitle: supertitleString,
text: titleString,
slug: urlSlug(`${supertitleString} ${titleString}`),
Copy link
Member

@mlbrgl mlbrgl Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I came across two headings with the same title/slug in time-use ("Additional information"), which made them both light up at the same time in the ToC. We had a provision in WP code to handle this special case but it hasn't been ported over yet. It is not the most critical bug but it can be quite visible so I'm a bit on the fence as to whether to make the fix par of this PR.

Here is an example doc: https://docs.google.com/document/d/1uYZEcCP2shwa5U1EYaGb6cRvLFEz0MrUJv9m8UASbqs/edit

Screenshot 2023-10-31 at 18 44 52

}
contentHeadings.forEach((contentHeading) => {
observer.observe(contentHeading)
})

return () => observer.disconnect()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure hover states (toggle, title vs close) are on your radar, just making a note here for good measure.

@ikesau ikesau force-pushed the linear-topic-page-toc branch from 1b41a96 to 3baee54 Compare November 1, 2023 19:54
@ikesau ikesau merged commit c439f3f into master Nov 6, 2023
13 checks passed
@ikesau ikesau deleted the linear-topic-page-toc branch November 6, 2023 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants