-
-
Notifications
You must be signed in to change notification settings - Fork 377
feat: child menu support in navbar #695
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
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4f415a1
feat: implement child menu support in main navbar
imfing ae56d70
chore: update menu identifiers and add missing translations for devel…
imfing 58ade55
Merge remote-tracking branch 'origin/main' into nav-nested-menu
imfing f8484a8
chore: update hugo stats
imfing 97ffaad
Merge remote-tracking branch 'origin/main' into nav-nested-menu
imfing 35fa799
chore: update script name
imfing 3419f45
chore: update menu item names to include arrows for external links
imfing 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,61 @@ | ||
| (function () { | ||
| const dropdownToggles = document.querySelectorAll(".hextra-nav-menu-toggle"); | ||
|
|
||
| dropdownToggles.forEach((toggle) => { | ||
| toggle.addEventListener("click", (e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
|
|
||
| // Close all other dropdowns first | ||
| dropdownToggles.forEach((otherToggle) => { | ||
| if (otherToggle !== toggle) { | ||
| otherToggle.dataset.state = "closed"; | ||
| const otherMenuItems = otherToggle.nextElementSibling; | ||
| otherMenuItems.classList.add("hx:hidden"); | ||
| } | ||
| }); | ||
|
|
||
| // Toggle current dropdown | ||
| const isOpen = toggle.dataset.state === "open"; | ||
| toggle.dataset.state = isOpen ? "closed" : "open"; | ||
| const menuItemsElement = toggle.nextElementSibling; | ||
|
|
||
| if (!isOpen) { | ||
| // Position dropdown centered with toggle | ||
| menuItemsElement.style.position = "absolute"; | ||
| menuItemsElement.style.top = "100%"; | ||
| menuItemsElement.style.left = "50%"; | ||
| menuItemsElement.style.transform = "translateX(-50%)"; | ||
| menuItemsElement.style.zIndex = "1000"; | ||
|
|
||
| // Show dropdown | ||
| menuItemsElement.classList.remove("hx:hidden"); | ||
| } else { | ||
| // Hide dropdown | ||
| menuItemsElement.classList.add("hx:hidden"); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| // Dismiss dropdown when clicking outside | ||
| document.addEventListener("click", (e) => { | ||
| if (e.target.closest(".hextra-nav-menu-toggle") === null) { | ||
| dropdownToggles.forEach((toggle) => { | ||
| toggle.dataset.state = "closed"; | ||
| const menuItemsElement = toggle.nextElementSibling; | ||
| menuItemsElement.classList.add("hx:hidden"); | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| // Close dropdowns on escape key | ||
| document.addEventListener("keydown", (e) => { | ||
| if (e.key === "Escape") { | ||
| dropdownToggles.forEach((toggle) => { | ||
| toggle.dataset.state = "closed"; | ||
| const menuItemsElement = toggle.nextElementSibling; | ||
| menuItemsElement.classList.add("hx:hidden"); | ||
| }); | ||
| } | ||
| }); | ||
| })(); | ||
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
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 |
|---|---|---|
|
|
@@ -4,3 +4,5 @@ blog: "博客" | |
| about: "关于" | ||
| more: "更多" | ||
| hugoDocs: "Hugo 文档 ↗" | ||
| versions: "版本" | ||
| development: "最新开发版本" | ||
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
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.