forked from GoogleChromeLabs/baseline-demos
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add dropdown demo #1
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
Open
jamesnw
wants to merge
5
commits into
main
Choose a base branch
from
dropdown
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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,335 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<link rel="stylesheet" href="./style.css" /> | ||
<title>Bird News Daily</title> | ||
</head> | ||
<body> | ||
<header role="banner"> | ||
<h1 class="title">Bird News Daily</h1> | ||
<p class="tagline"> | ||
Building a Disclosure Navigation with Baseline features | ||
</p> | ||
</header> | ||
<nav aria-label="Bird News Daily"> | ||
<ul class="nav-list"> | ||
<li class="nav-list-item"> | ||
<a href="#home">Home</a> | ||
</li> | ||
<li class="nav-list-item"> | ||
<button data-button="popover-trigger" popovertarget="about-menu"> | ||
About | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
aria-hidden="true" | ||
focusable="false" | ||
data-icon="triangle" | ||
width="32" | ||
height="32" | ||
fill="currentColor" | ||
> | ||
<defs> | ||
<linearGradient | ||
id="triangle-gradient" | ||
x1="0%" | ||
x2="100%" | ||
y1="0%" | ||
y2="0%" | ||
gradientTransform="rotate(45)" | ||
> | ||
<stop class="gradient-start" offset="4%" /> | ||
<stop class="gradient-end" offset="100%" /> | ||
</linearGradient> | ||
</defs> | ||
<path | ||
d="M16 12L10 18V6L16 12Z" | ||
fill="url(#triangle-gradient)" | ||
></path> | ||
</svg> | ||
</button> | ||
|
||
<ul aria-label="About" popover id="about-menu" class="menu"> | ||
<li> | ||
<a href="#overview">Overview</a> | ||
</li> | ||
<li> | ||
<a href="#our-mission">Our Mission</a> | ||
</li> | ||
<li> | ||
<button | ||
popovertarget="facts-menu" | ||
data-button="popover-trigger" | ||
> | ||
Facts | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
aria-hidden="true" | ||
focusable="false" | ||
data-icon="triangle" | ||
width="32" | ||
height="32" | ||
fill="currentColor" | ||
> | ||
<defs> | ||
<linearGradient | ||
id="triangle-gradient" | ||
x1="0%" | ||
x2="100%" | ||
y1="0%" | ||
y2="0%" | ||
> | ||
<stop class="gradient-start" offset="0%" /> | ||
<stop class="gradient-end" offset="100%" /> | ||
</linearGradient> | ||
</defs> | ||
<path | ||
d="M16 12L10 18V6L16 12Z" | ||
fill="url(#triangle-gradient)" | ||
></path> | ||
</svg> | ||
</button> | ||
<ul aria-label="Facts" class="sub-menu" popover id="facts-menu"> | ||
<li> | ||
<a href="#history">History</a> | ||
</li> | ||
<li> | ||
<a href="#staff">Staff</a> | ||
</li> | ||
<li> | ||
<a href="#awards">Awards</a> | ||
</li> | ||
</ul> | ||
</li> | ||
<li> | ||
<button | ||
popovertarget="local-events-menu" | ||
data-button="popover-trigger" | ||
> | ||
Local Events | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
aria-hidden="true" | ||
focusable="false" | ||
data-icon="triangle" | ||
width="32" | ||
height="32" | ||
fill="currentColor" | ||
> | ||
<defs> | ||
<linearGradient | ||
id="triangle-gradient" | ||
x1="0%" | ||
x2="100%" | ||
y1="0%" | ||
y2="0%" | ||
> | ||
<stop class="gradient-start" offset="0%" /> | ||
<stop class="gradient-end" offset="100%" /> | ||
</linearGradient> | ||
</defs> | ||
<path | ||
d="M16 12L10 18V6L16 12Z" | ||
fill="url(#triangle-gradient)" | ||
></path> | ||
</svg> | ||
</button> | ||
<ul | ||
aria-label="Local Events" | ||
id="local-events-menu" | ||
popover | ||
class="sub-menu" | ||
> | ||
<li> | ||
<a href="#bnd-birdwalks"> BND Birdwalks </a> | ||
</li> | ||
<li> | ||
<a href="#live-talks">Live Talks</a> | ||
</li> | ||
<li> | ||
<a href="#meetups">Meetups</a> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
<li class="nav-list-item"> | ||
<button popovertarget="news-menu" data-button="popover-trigger"> | ||
News | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
aria-hidden="true" | ||
focusable="false" | ||
data-icon="triangle" | ||
width="32" | ||
height="32" | ||
fill="currentColor" | ||
> | ||
<path d="M16 12L10 18V6L16 12Z"></path> | ||
<defs> | ||
<linearGradient | ||
id="triangle-gradient" | ||
x1="0%" | ||
x2="100%" | ||
y1="0%" | ||
y2="0%" | ||
> | ||
<stop class="gradient-start" offset="0%" /> | ||
<stop class="gradient-end" offset="100%" /> | ||
</linearGradient> | ||
</defs> | ||
<path | ||
d="M16 12L10 18V6L16 12Z" | ||
fill="url(#triangle-gradient)" | ||
></path> | ||
</svg> | ||
</button> | ||
<ul aria-label="News" popover id="news-menu" class="menu"> | ||
<li> | ||
<a href="#latest-headlines">Latest Headlines</a> | ||
</li> | ||
<li> | ||
<button | ||
popovertarget="regional-menu" | ||
data-button="popover-trigger" | ||
> | ||
Regional | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
aria-hidden="true" | ||
focusable="false" | ||
data-icon="triangle" | ||
width="32" | ||
height="32" | ||
fill="currentColor" | ||
> | ||
<linearGradient | ||
id="triangle-gradient" | ||
x1="0%" | ||
x2="100%" | ||
y1="0%" | ||
y2="0%" | ||
> | ||
<stop class="gradient-start" offset="0%" /> | ||
<stop class="gradient-end" offset="100%" /> | ||
</linearGradient> | ||
<path | ||
d="M16 12L10 18V6L16 12Z" | ||
fill="url(#triangle-gradient)" | ||
></path> | ||
</svg> | ||
</button> | ||
<ul | ||
aria-label="Regional" | ||
id="regional-menu" | ||
popover | ||
class="sub-menu" | ||
> | ||
<li> | ||
<a href="#prairies">Prairies</a> | ||
</li> | ||
<li> | ||
<a href="#wetlands">Wetlands</a> | ||
</li> | ||
<li> | ||
<a href="#rural">Rural</a> | ||
</li> | ||
</ul> | ||
</li> | ||
<li> | ||
<a href="#sightings">Sightings</a> | ||
</li> | ||
<li> | ||
<a href="#recordings">Birdsong Recordings</a> | ||
</li> | ||
<li> | ||
<a href="#photo-essays">Photo Essays</a> | ||
</li> | ||
<li> | ||
<a href="#sunday-interviews">The Sunday Interview</a> | ||
</li> | ||
</ul> | ||
</li> | ||
<li class="nav-list-item"> | ||
<button | ||
popovertarget="resources-menu" | ||
data-button="popover-trigger" | ||
> | ||
Resources | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
aria-hidden="true" | ||
focusable="false" | ||
data-icon="triangle" | ||
width="32" | ||
height="32" | ||
fill="currentColor" | ||
> | ||
<defs> | ||
<linearGradient | ||
id="triangle-gradient" | ||
x1="0%" | ||
x2="100%" | ||
y1="0%" | ||
y2="0%" | ||
> | ||
<stop class="gradient-start" offset="0%" /> | ||
<stop class="gradient-end" offset="100%" /> | ||
</linearGradient> | ||
</defs> | ||
<path | ||
d="M16 12L10 18V6L16 12Z" | ||
fill="url(#triangle-gradient)" | ||
></path> | ||
</svg> | ||
</button> | ||
<ul id="resources-menu" popover aria-label="Resources" class="menu"> | ||
<li> | ||
<a href="#clubs-and-organizations">Clubs & Organizations</a> | ||
</li> | ||
<li> | ||
<a href="#identification-guides">Identification Guides</a> | ||
</li> | ||
<li> | ||
<a href="#podcast">BND Podcast</a> | ||
</li> | ||
<li> | ||
<a href="#online-courses">Online Courses</a> | ||
</li> | ||
<li role="separator"></li> | ||
<li> | ||
<a href="#research">Research</a> | ||
</li> | ||
<li> | ||
<a href="#trails">BND Trails</a> | ||
</li> | ||
<li> | ||
<a href="#kids">BDN Kids</a> | ||
</li> | ||
<li> | ||
<a href="#maps">Maps</a> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</nav> | ||
|
||
<main> | ||
<section aria-labelledby="id-page-title"> | ||
<h2 id="id-page-title">Bird News Daily</h2> | ||
</section> | ||
</main> | ||
|
||
<footer role="contentinfo"> | ||
<p>©2025 Bird News Daily</p> | ||
</footer> | ||
<script src="./script.js"></script> | ||
</body> | ||
</html> |
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,34 @@ | ||
window.addEventListener("hashchange", () => { | ||
handleRoute(window.location.hash); | ||
}); | ||
|
||
const CONTAINS_PATH_TEXT = "Contains current page link"; | ||
|
||
function handleRoute(newPage) { | ||
// Close all open popovers, would be unneeded if we actually had navigated to a new page | ||
document.querySelectorAll(":popover-open").forEach((popover) => { | ||
popover.hidePopover(); | ||
}); | ||
|
||
// Replace the content | ||
const heading = document.getElementById("id-page-title"); | ||
heading.innerText = newPage; | ||
|
||
const formerLink = document.querySelector("[aria-current]"); | ||
if (formerLink) formerLink.removeAttribute("aria-current"); | ||
|
||
const linkToRoute = document.querySelector(`[href="${newPage}"]`); | ||
linkToRoute.setAttribute("aria-current", "page"); | ||
|
||
// Remove existing title attributes | ||
document | ||
.querySelectorAll(`[title="${CONTAINS_PATH_TEXT}"]`) | ||
.forEach((element) => { | ||
element.removeAttribute("title"); | ||
}); | ||
|
||
// Add a title to ancestors | ||
document.querySelectorAll("li:has(a[aria-current])").forEach((element) => { | ||
element.setAttribute("title", CONTAINS_PATH_TEXT); | ||
}); | ||
} |
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.