aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2021-12-18 00:12:19 -0500
committerThedro Neely <thedroneely@gmail.com>2021-12-18 00:12:19 -0500
commit13b69343b9f8cf4be673256010e784ebd846aa95 (patch)
tree6d67f82bdf6572614d9fd6669f770d05cff25377 /app
parent7a61c746f0ee5d999c88414bf206a30781b87e31 (diff)
downloadthedroneely.com-13b69343b9f8cf4be673256010e784ebd846aa95.tar.gz
thedroneely.com-13b69343b9f8cf4be673256010e784ebd846aa95.tar.bz2
thedroneely.com-13b69343b9f8cf4be673256010e784ebd846aa95.zip
app/model/Navigation: Simplify active route logic
Diffstat (limited to 'app')
-rw-r--r--app/model/Navigation.php7
-rw-r--r--app/views/components/navigator.link.dropdown.php7
-rw-r--r--app/views/components/navigator.link.php6
3 files changed, 3 insertions, 17 deletions
diff --git a/app/model/Navigation.php b/app/model/Navigation.php
index d32546b..055c3ce 100644
--- a/app/model/Navigation.php
+++ b/app/model/Navigation.php
@@ -7,13 +7,8 @@ class Navigation
return (bool) (strpos($_SERVER['REQUEST_URI'], $route) !== false);
}
- public function isActiveHome()
- {
- return (bool) (strlen(strtok($_SERVER['REQUEST_URI'], '?')) === 1);
- }
-
public function isActive($route)
{
- return (bool) ($_SERVER['REQUEST_URI'] === $route || $this->requestContains($route));
+ return (bool) (ltrim(Request::uri(), "/") === ltrim($route, "/") || $this->requestContains(ltrim($route, "/")));
}
}
diff --git a/app/views/components/navigator.link.dropdown.php b/app/views/components/navigator.link.dropdown.php
index be937f8..0657bc6 100644
--- a/app/views/components/navigator.link.dropdown.php
+++ b/app/views/components/navigator.link.dropdown.php
@@ -1,10 +1,5 @@
<a href="<?php echo $route ?? null; ?>"
- class="
- <?php
- echo $check = ($label === 'Home')
- ? ($navigation->isActiveHome() ? ' navbar__active' : '')
- : ($navigation->isActive($route ?? null) ? ' navbar__active' : '');
- ?> navbar-item"
+ class="<?php if ($navigation->isActive($route ?? null)) { echo ' navbar__active'; } ?> navbar-item"
title="<?php echo $label ?? null; ?>"
>
<?php echo $label ?? null; ?>
diff --git a/app/views/components/navigator.link.php b/app/views/components/navigator.link.php
index a129acf..3b57d62 100644
--- a/app/views/components/navigator.link.php
+++ b/app/views/components/navigator.link.php
@@ -1,12 +1,8 @@
<a href="<?php echo $route ?? null; ?>" class="navbar-item navbar__icon has-text-centered
<?php
-
$hiddenLabels = [ 'Profile' ];
if (in_array($label, $hiddenLabels)) { echo ' navbar__icon__hidden'; }
-
- echo $check = ($label === 'Home')
- ? ($navigation->isActiveHome() ? ' navbar__active' : '')
- : ($navigation->isActive($route ?? null) ? ' navbar__active' : '');
+ if ($navigation->isActive($route ?? null)) { echo ' navbar__active'; }
?>
">
<div class="has-text-centered">