-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from camino-school/landing_page
Landing page
- Loading branch information
Showing
14 changed files
with
938 additions
and
66 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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 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 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,38 @@ | ||
const handleIntersect = (navLinks) => (entries, observer) => { | ||
entries.forEach((entry) => { | ||
if (entry.isIntersecting) { | ||
for (const navLink of navLinks) { | ||
if (navLink.getAttribute('href') === `#${entry.target.id}`) { | ||
navLink.setAttribute('aria-current', 'true') | ||
} else { | ||
navLink.setAttribute('aria-current', 'false') | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
|
||
const navScrollspyHook = { | ||
mounted() { | ||
// this hook is expected to be used in a <nav> component. | ||
// it will use all of it's children links href as the intersection observer targets | ||
const navEl = this.el | ||
const navLinks = document.querySelectorAll(`${navEl.id} a`) | ||
|
||
const options = { | ||
root: null, | ||
rootMargin: "0px", | ||
threshold: 0.5, | ||
}; | ||
|
||
const observer = new IntersectionObserver(handleIntersect(navLinks), options); | ||
|
||
for (const navLink of navLinks) { | ||
const elementId = navLink.getAttribute('href').replace('#', '') | ||
const target = document.getElementById(elementId) | ||
observer.observe(target) | ||
} | ||
}, | ||
}; | ||
|
||
export default navScrollspyHook; |
This file contains 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 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 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 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.