Skip to content

Commit 093eb32

Browse files
committed
Adjust anchors
1 parent bcdea77 commit 093eb32

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/components/LabPage/FloatingMenu/FloatingMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const FloatingMenu = () => {
1414

1515
const isNavigatingToClickedLinkRef = useRef(false);
1616
useEffect(() => {
17-
const sectionAnchorsOnPage = Array.from(document.querySelectorAll('section[id]'));
17+
const sectionAnchorsOnPage = Array.from(document.querySelectorAll('section .anchor[id]'));
1818
const newMenuOptions = sectionAnchorsOnPage.map(section => ({
1919
label: section.getAttribute('aria-label') || section.id,
2020
id: section.id,

src/components/LabPage/Section/Section.module.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--side-padding: calc(var(--side-padding-raw));
44
background-color: rgb(238, 238, 238);
55
padding: 60px 20px;
6+
position: relative;
67

78
@media (--tablet) {
89
padding: 120px var(--side-padding);
@@ -29,4 +30,16 @@
2930
&:nth-of-type(odd) {
3031
background-color: white;
3132
}
33+
34+
.anchor {
35+
position: absolute;
36+
top: -150px;
37+
left: 0;
38+
width: 100%;
39+
height: 10px;
40+
41+
@media (--desktop) {
42+
top: -100px;
43+
}
44+
}
3245
}

src/components/LabPage/Section/Section.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ type SectionProps = {
1010

1111
const Section = ({ anchor, anchorLabel, children, className, isNarrow }: SectionProps) => {
1212
return (
13-
<section {...(anchor ? { id: anchor, 'aria-label': anchorLabel } : {})} className={`${styles.section} ${className} ${isNarrow ? styles.isNarrow : ''}`}>
13+
<section className={`${styles.section} ${className} ${isNarrow ? styles.isNarrow : ''}`}>
14+
{anchor && <div id={anchor} className={`${styles.anchor} anchor`} aria-label={anchorLabel} />}
1415
{children}
1516
</section>
1617
)

0 commit comments

Comments
 (0)