Skip to content

Commit 196a090

Browse files
authored
Merge pull request #37 from keepsimpleio/hotfix/longevity-mob-nav
hotfix: mobile navigation of longevity
2 parents 9b23b99 + 15531ea commit 196a090

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/components/longevity/MobileNavigation/MobileNavigation.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ const MobileNavigation: FC = () => {
141141
return next ? { name: next.name, path: next.path } : null;
142142
};
143143

144+
const isHabitsItem = (item: { hasNoUrl?: boolean }) => Boolean(item.hasNoUrl);
145+
144146
const nextPathname = getNextNavItem(navItems, subNavItems);
145147

146148
return (
@@ -172,10 +174,10 @@ const MobileNavigation: FC = () => {
172174
key={item.path}
173175
className={cn(styles.li, {
174176
[styles.active]: router.pathname === item.path,
175-
[styles.habitsLi]: item.name === 'Habits',
177+
[styles.habitsLi]: isHabitsItem(item),
176178
})}
177179
onClick={() => {
178-
if (item.name === 'Habits') {
180+
if (isHabitsItem(item)) {
179181
setOpenSubNav(!openSubNav);
180182
} else {
181183
setOpenNav(!openNav);
@@ -184,7 +186,7 @@ const MobileNavigation: FC = () => {
184186
>
185187
<span
186188
className={cn(styles.txtAndIcon, {
187-
[styles.habitsTxtAndIcon]: item.name === 'Habits',
189+
[styles.habitsTxtAndIcon]: isHabitsItem(item),
188190
})}
189191
>
190192
{item.icon && <span className={styles.icon}>{item.icon}</span>}
@@ -195,12 +197,12 @@ const MobileNavigation: FC = () => {
195197
href={item.path}
196198
passHref
197199
className={styles.link}
198-
target={item.name === 'AI Assistant' ? '_blank' : '_self'}
200+
target={isInternal(item.path) ? '_self' : '_blank'}
199201
>
200202
{item.name}
201203
</Link>
202204
)}
203-
{item.name === 'Habits' && (
205+
{isHabitsItem(item) && (
204206
<NavigationIcon
205207
className={cn(styles.habitsArrow, {
206208
[styles.openHabitsArrow]: openSubNav,
@@ -211,7 +213,7 @@ const MobileNavigation: FC = () => {
211213
{item.icon && <NewPageIcon />}
212214

213215
<Divider className={styles.divider} />
214-
{item.name === 'Habits' && (
216+
{isHabitsItem(item) && (
215217
<ul
216218
className={cn(styles.subNav, {
217219
[styles.openSubNav]:

0 commit comments

Comments
 (0)