diff --git a/resources/views/components/sky-link.blade.php b/resources/views/components/sky-link.blade.php new file mode 100644 index 0000000..43097e6 --- /dev/null +++ b/resources/views/components/sky-link.blade.php @@ -0,0 +1,3 @@ +except('label')->except('hasLabelWrap') }}> + {{ $label }} + diff --git a/src/Classes/LinkRenderers/NavLinkRenderer.php b/src/Classes/LinkRenderers/NavLinkRenderer.php index b6aa386..aee9e84 100644 --- a/src/Classes/LinkRenderers/NavLinkRenderer.php +++ b/src/Classes/LinkRenderers/NavLinkRenderer.php @@ -37,9 +37,9 @@ public function getActiveClass(): string public function getPreparedLink(string $classes = ''): array { return [ - 'classes' => $classes . ' ' . $this->getActiveClass(), + 'class' => $classes . ' ' . $this->getActiveClass(), 'target' => $this->item['data']['target'] ?? '_self', - 'link' => $this->getLink(), + 'href' => $this->getLink(), 'label' => $this->item['label'], ]; } diff --git a/src/Classes/RenderNavItem.php b/src/Classes/RenderNavItem.php index 6bf5238..6cb10f0 100644 --- a/src/Classes/RenderNavItem.php +++ b/src/Classes/RenderNavItem.php @@ -2,6 +2,7 @@ namespace LaraZeus\Sky\Classes; +use Illuminate\Support\Facades\Blade; use LaraZeus\Sky\Classes\LinkRenderers\GenericLinkRenderer; use LaraZeus\Sky\Classes\LinkRenderers\NavLinkRenderer; use LaraZeus\Sky\SkyPlugin; @@ -13,23 +14,6 @@ class RenderNavItem */ public static string $defaultRendererClass = GenericLinkRenderer::class; - private static function anchorLink( - string $classes, - string $target, - string $link, - string $label, - ): string { - // TODO: make this component based? - // Then it's probably easier for users to further customize this? - return '' . - $label . // TODO: allow optional wrapping link text in span? - // Or maybe support this customization via components? - ''; - } - public static function render(array $item, string $class = ''): string { $itemType = $item['type']; @@ -47,6 +31,9 @@ public static function render(array $item, string $class = ''): string /** * @var NavLinkRenderer $renderer */ - return static::anchorLink(...$renderer->getPreparedLink($class)); + return Blade::render( + '', + $renderer->getPreparedLink($class) + ); } } diff --git a/src/Components/SkyLink.php b/src/Components/SkyLink.php new file mode 100644 index 0000000..5c85614 --- /dev/null +++ b/src/Components/SkyLink.php @@ -0,0 +1,22 @@ +data()); + } +} diff --git a/src/SkyServiceProvider.php b/src/SkyServiceProvider.php index 2112dd7..10b1d01 100644 --- a/src/SkyServiceProvider.php +++ b/src/SkyServiceProvider.php @@ -5,6 +5,7 @@ use Filament\Facades\Filament; use Filament\Forms\Components\Select; use LaraZeus\Core\CoreServiceProvider; +use LaraZeus\Sky\Components\SkyLink; use LaraZeus\Sky\Console\InstallCommand; use LaraZeus\Sky\Console\migrateCommand; use LaraZeus\Sky\Console\PublishCommand; @@ -31,6 +32,7 @@ public function configurePackage(Package $package): void ->hasConfigFile() ->hasCommands($this->getCommands()) ->hasViews('zeus') + ->hasViewComponent('zeus', SkyLink::class) ->hasRoute('web'); }