Repository navigation
Refactor mobile menu to use Popover API #4121
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
Merged
+93
−69
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8ff14cb
Refactor mobile menu to use Popover API
delucis ce9b01a
Update browser versions link in CONTRIBUTING.md
delucis 1408ee6
Fix browserslist range
delucis 0586e9f
Add changesets
delucis d36e058
Use `beforetoggle` event
delucis a343bb1
Further refactor so that body locking is not dependent on JS either
delucis 39a8b15
Merge branch 'main' into chris/sidebar-refactor
louisescher 77300e8
Fix browser list
delucis 7358276
Remove polyfill recommendation
delucis eaf60a1
Inherit text color in `popover`
delucis a4535bd
Update Edge version in contributing guide browser list
delucis 050b7ca
Refactor menu pane to be a custom element
delucis cbf64ca
Close the menu when the viewport resizes instead of only managing the…
delucis 837b654
Mention overrides in changeset
delucis a1986b7
Use `toggle` event
delucis 5c73fb3
Move menu toggle script to PageFrame
delucis 62964d3
Add class name to menu button to help migration
delucis 5ae97d6
Fix E2E test to make it a bit more robust
delucis 1e62e46
Fix aria-expanded example in changeset
delucis 7e23a75
Update changeset to mention `data-mobile-menu-expanded` change
delucis 2529960
Merge branch 'main' into chris/sidebar-refactor
delucis c3a8f08
Merge branch 'main' into chris/sidebar-refactor
delucis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Simplifies markup for Starlight’s mobile menu toggle | ||
|
|
||
| **⚠️ Potentially breaking change:** If you use a theme plugin, custom styles, or component overrides targeting the `MobileMenuToggle` button or `PageFrame` components, you may need to adjust these for the new markup. The button is no longer wrapped in a `<starlight-menu-button>` custom element and no longer uses the `aria-expanded` attribute. Instead, you can use the `.sl-menu-button` class name to target the button and the `:popover-open` pseudo-class to style the menu open state specifically. | ||
|
|
||
| In the following example, custom styles for the menu button are updated for the new approach: | ||
|
|
||
| ```diff | ||
| - starlight-menu-button button { | ||
| + .sl-menu-button { | ||
| color: var(--sl-color-text); | ||
| } | ||
|
|
||
| - starlight-menu-button[aria-expanded='true'] button { | ||
| + .sl-menu-button:has(~ :popover-open) { | ||
| color: var(--sl-color-text-accent-high); | ||
| } | ||
| ``` | ||
|
|
||
| See [`MobileMenuToggle.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/MobileMenuToggle.astro) and [`PageFrame.astro`](https://github.com/withastro/starlight/blob/main/packages/starlight/components/PageFrame.astro) on GitHub for the full source code of the updated components. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| '@astrojs/starlight': minor | ||
| --- | ||
|
|
||
| Refactors Starlight’s mobile menu toggle to work when JavaScript fails or is disabled | ||
|
|
||
| ⚠️ **BREAKING CHANGE:** This release drops official support for Chromium-based browsers prior to version 116 (released August 2023), Safari-based browsers prior to version 17.0 (released September 2023), and Firefox prior to version 125 (released April 2024). You can find a list of currently supported browsers and their versions using this [browserslist query](https://browsersl.ist/#q=%3E+0.5%25%2C+not+dead%2C+Chrome+%3E%3D+116%2C+Edge+%3E%3D+116%2C+Firefox+%3E%3D+125%2C+Safari+%3E%3D+17.0%2C+iOS+%3E%3D+17.0%2C+not+op_mini+all). | ||
|
|
||
| This change also removes the `data-mobile-menu-expanded` attribute, which was previously added to `<body>` while the mobile menu is open. If you have custom code that was depending on this attribute, you will need to update it to use a new selector to check if the mobile menu is open. | ||
|
|
||
| In the following example, a custom background colour for the site header while the menu is open is updated for the new approach: | ||
|
|
||
| ```diff | ||
| - [data-mobile-menu-expanded] header { | ||
| + body:has(sl-sidebar-pane:popover-open) header { | ||
| background-color: var(--sl-color-bg); | ||
| } | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.