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

Add new Sidebar Container block to handle sticky sidebar logic #397

Merged
merged 1 commit into from
May 8, 2023

Conversation

ryelle
Copy link
Contributor

@ryelle ryelle commented May 5, 2023

This pulls out the sticky-related JS from the table of contents block, and ports over some CSS from the child themes, so that the sidebar pattern with table of contents can be reused — currently this component-pattern is used on Documentation, the new Developer site (in progress), and soon to be on the About subpages. By consolidating the code here, we can prevent duplicating the CSS across the child themes.

Additionally, this removes the use of aside for the sidebar, so it addresses some of the issue in WordPress/wporg-documentation-2022#58.

See WordPress/wporg-documentation-2022#63 for how this will be used in a child theme— we can remove the CSS and simplify the template. If this goes forward, I'll make a similar PR for Developer.

Before

<!-- wp:group {"tagName":"aside","className":"sidebar-container"} -->
<aside class="wp-block-group sidebar-container">
	<!-- wp:template-part {"slug":"search"} /-->

	<!-- wp:wporg/table-of-contents {"style":{"elements":{"link":{"color":{"text":"var:preset|color|blueberry-1"}}},"spacing":{"padding":{"top":"var:preset|spacing|20","right":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20"}}},"backgroundColor":"blueberry-4","textColor":"blueberry-1"} /-->

	<!-- wp:paragraph {"fontSize":"small","className":"is-link-to-top"} -->
	<p class="has-small-font-size is-link-to-top"><a href="#wp--skip-link--target">↑ Back to top</a></p>
	<!-- /wp:paragraph -->
</aside>
<!-- /wp:group -->

After

<!-- wp:wporg/sidebar-container -->
	<!-- wp:template-part {"slug":"search","theme":"wporg-documentation-2022"} /-->

	<!-- wp:wporg/table-of-contents {"style":{"elements":{"link":{"color":{"text":"var:preset|color|blueberry-1"}}},"spacing":{"padding":{"top":"var:preset|spacing|20","right":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20"}}},"backgroundColor":"blueberry-4","textColor":"blueberry-1"} /-->
<!-- /wp:wporg/sidebar-container -->

This pulls out the sticky-related JS from the table of contents block, and ports over some CSS from the child themes, so that the sidebar pattern with table of contents can be reused.
Copy link
Contributor

@StevenDufresne StevenDufresne left a comment

Choose a reason for hiding this comment

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

This is working as expected and the separating makes sense. 👍

I doubt this was introduced in this PR, but in safari there is an inconsistent behaviour where it doesn't properly attach: https://d.pr/i/tvomVC

I'll open a new ticket if you think it's unrelated.

@ryelle
Copy link
Contributor Author

ryelle commented May 8, 2023

I doubt this was introduced in this PR, but in safari there is an inconsistent behaviour where it doesn't properly attach: https://d.pr/i/tvomVC

It works for me in Safari, both on production and with the new sidebar container. I tried toggling the reader view and reloading a few times, and it kept working. Can you open a new issue with more steps to reproduce?

In the meantime, I'm going to merge this so I can rebase & iterate on #389.

@ryelle ryelle merged commit 794d704 into trunk May 8, 2023
@ryelle ryelle deleted the try/sidebar-container branch May 8, 2023 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants