Skip to content

Commit

Permalink
refactor: rename page section vars
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellmueller committed Feb 6, 2025
1 parent 0905c2e commit 18e7bf2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions frontend/src/components/layout/PageMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import '@/components/layout/PageMenu.scss';

type PageSection = {
sectionIndex: number;
link: string;
display: string;
href: string;
title: string;
};

type PageMenuProps = {
Expand All @@ -25,17 +25,17 @@ const PageMenu: React.FC<PageMenuProps> = ({
className="navbar"
>
{pageSections.map((section) => {
const { display, link, sectionIndex } = section;
const { href, sectionIndex, title } = section;
return (
<a
className={`nav-link ${activeSection === sectionIndex ? 'active' : ''}`}
data-active-section={
activeSection === sectionIndex ? 'true' : 'false'
}
key={link}
href={link}
key={href}
href={href}
>
{display}
{title}
</a>
);
})}
Expand All @@ -50,7 +50,7 @@ const PageMenu: React.FC<PageMenuProps> = ({
(section) => section.sectionIndex === Number(index),
);
if (selectedSection) {
window.location.hash = selectedSection.link;
window.location.hash = selectedSection.href;
}
};

Expand All @@ -66,10 +66,10 @@ const PageMenu: React.FC<PageMenuProps> = ({
Table of Contents
</option>
{pageSections.map((section) => {
const { display, sectionIndex } = section;
const { title, sectionIndex } = section;
return (
<option key={display} value={sectionIndex}>
{display}
<option key={title} value={sectionIndex}>
{title}
</option>
);
})}
Expand Down
24 changes: 12 additions & 12 deletions frontend/src/components/rec-resource/RecResourcePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,28 @@ const RecResourcePage = () => {
() =>
[
isClosures && {
link: '#closures',
display: 'Closures',
href: '#closures',
title: 'Closures',
},
description && {
link: '#site-description',
display: 'Site Description',
href: '#site-description',
title: 'Site Description',
},
{
link: '#maps-and-location',
display: 'Maps and Location',
href: '#maps-and-location',
title: 'Maps and Location',
},
{
link: '#camping',
display: 'Camping',
href: '#camping',
title: 'Camping',
},
isThingsToDo && {
link: '#things-to-do',
display: 'Things to Do',
href: '#things-to-do',
title: 'Things to Do',
},
{
link: '#contact',
display: 'Contact',
href: '#contact',
title: 'Contact',
},
]
.filter((section) => !!section)
Expand Down

0 comments on commit 18e7bf2

Please sign in to comment.