Skip to content

Commit

Permalink
refactor add controls for classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck committed Mar 18, 2024
1 parent 809143d commit 73b6cdc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion resources/views/components/sky-link.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<a {{ $attributes->except('label')->except('hasLabelWrap') }}>
<a {{ $attributes->except(['label', 'hasLabelWrap']) }}>
{{ $label }}
</a>
5 changes: 2 additions & 3 deletions src/Classes/LinkRenderers/NavLinkRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -28,7 +27,7 @@ public function getActiveClass(): string
{
return $this->isActiveRoute() ?
self::$activeClasses :
self::$defaultActiveClass;
self::$nonActiveClasses;
}

/**
Expand Down
22 changes: 22 additions & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 73b6cdc

Please sign in to comment.