From 73b6cdcc88eb7b181f649bc227ada6eafceda547 Mon Sep 17 00:00:00 2001 From: Dan Pock Date: Mon, 18 Mar 2024 17:29:45 -0400 Subject: [PATCH] refactor add controls for classes --- resources/views/components/sky-link.blade.php | 2 +- src/Classes/LinkRenderers/NavLinkRenderer.php | 5 ++--- src/Configuration.php | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/resources/views/components/sky-link.blade.php b/resources/views/components/sky-link.blade.php index 43097e6..a80e206 100644 --- a/resources/views/components/sky-link.blade.php +++ b/resources/views/components/sky-link.blade.php @@ -1,3 +1,3 @@ -except('label')->except('hasLabelWrap') }}> +except(['label', 'hasLabelWrap']) }}> {{ $label }} diff --git a/src/Classes/LinkRenderers/NavLinkRenderer.php b/src/Classes/LinkRenderers/NavLinkRenderer.php index aee9e84..5d27ef4 100644 --- a/src/Classes/LinkRenderers/NavLinkRenderer.php +++ b/src/Classes/LinkRenderers/NavLinkRenderer.php @@ -13,10 +13,9 @@ public function __construct( ) { } - // TODO: something to control these classes for end-user? public static string $activeClasses = 'border-b border-b-secondary-500 text-secondary-500'; - public static string $defaultActiveClass = 'border-transparent'; + public static string $nonActiveClasses = 'border-transparent'; abstract public function getModel(): ?Model; @@ -28,7 +27,7 @@ public function getActiveClass(): string { return $this->isActiveRoute() ? self::$activeClasses : - self::$defaultActiveClass; + self::$nonActiveClasses; } /** diff --git a/src/Configuration.php b/src/Configuration.php index 39f545c..b35ad54 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -311,4 +311,26 @@ public function getNavRenderers(): array $this->navRenderers ); } + + /** + * Set the default active CSS class(es) on a nav link. + * @param string $activeClasses + * @return $this + */ + public function setActiveClasses(string $activeClasses): static + { + NavLinkRenderer::$activeClasses = $activeClasses; + return $this; + } + + /** + * Set the default non-active CSS class(es) on a nav link. + * @param string $nonActiveClass + * @return $this + */ + public function setNonActiveClasses(string $nonActiveClass): static + { + NavLinkRenderer::$nonActiveClasses = $nonActiveClass; + return $this; + } }