Skip to content

Commit

Permalink
Merge pull request #6 from Cybrarist/feature/add-text-to-custom-logo
Browse files Browse the repository at this point in the history
- add text to custom logo, and make custom logo url opens in new tab 
- update doc
- update test
  • Loading branch information
Devonab authored Feb 26, 2025
2 parents ac5f5e8 + bd2a9df commit f35bc3c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,24 +237,52 @@ use Devonab\FilamentEasyFooter\EasyFooterPlugin;
![Filament Easy Footer custom logo](https://raw.githubusercontent.com/Devonab/filament-easy-footer/main/art/custom_logo.webp)


You can add **custom logo** with link to the footer by using this configuration :
### Custom logo with link
![Filament Easy Footer custom logo](https://raw.githubusercontent.com/Devonab/filament-easy-footer/main/art/custom_logo.webp)

You can add a **custom logo** with optional link and text to the footer by using this configuration:

```php
use Devonab\FilamentEasyFooter\EasyFooterPlugin;

->plugins([
EasyFooterPlugin::make()
->withLogo('https://static.cdnlogo.com/logos/l/23/laravel.svg', 'https://laravel.com')
->withLogo(
'https://static.cdnlogo.com/logos/l/23/laravel.svg', // Path to logo
'https://laravel.com' // URL for logo link (optional)
)
])
```

You're not obliged to add a link, and if you wish, you can specify the height of the logo as a parameter (default: 20px).
You can customize the logo further with optional text and height:

```php
use Devonab\FilamentEasyFooter\EasyFooterPlugin;

->plugins([
EasyFooterPlugin::make()
->withLogo(
'https://static.cdnlogo.com/logos/l/23/laravel.svg', // Path to logo
'https://laravel.com', // URL for logo link (optional)
'Powered by Laravel', // Text to display (optional)
35 // Logo height in pixels (default: 20)
)
])
```

If you don't need the link, you can pass `null` for the second parameter:

```php
use Devonab\FilamentEasyFooter\EasyFooterPlugin;

->plugins([
EasyFooterPlugin::make()
->withLogo('https://static.cdnlogo.com/logos/l/23/laravel.svg', null, 60)
->withLogo(
'https://static.cdnlogo.com/logos/l/23/laravel.svg', // Path to logo
null, // No link
null, // No text
60 // Logo height in pixels
)
])
```

Expand Down
7 changes: 5 additions & 2 deletions resources/views/easy-footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
@endif

@if($logoPath)
<span class="flex items-center">
<span class="flex items-center gap-2">
@if($logoText)
<span>{{ $logoText }}</span>
@endif
@if($logoUrl)
<a href="{{ $logoUrl }}" class="inline-flex">
<a href="{{ $logoUrl }}" class="inline-flex" target="_blank">
@endif
<img
src="{{ $logoPath }}"
Expand Down
15 changes: 14 additions & 1 deletion src/EasyFooterPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class EasyFooterPlugin implements Plugin

protected ?string $logoUrl = null;

protected ?string $logoText = null;

protected int $logoHeight = 20;

protected bool $isFooterEnabled = true;
Expand Down Expand Up @@ -121,6 +123,7 @@ protected function renderFooter(float $startTime): string
'showUrl' => $this->showUrl,
'logoPath' => $this->logoPath,
'logoUrl' => $this->logoUrl,
'logoText' => $this->logoText,
'logoHeight' => $this->logoHeight,
'borderTopEnabled' => $this->borderTopEnabled,
'loadTime' => $this->loadTimeEnabled ? $this->calculateLoadTime($startTime) : false,
Expand Down Expand Up @@ -259,13 +262,15 @@ public function withLinks(array $links): static
*
* @param string $path Path to the logo image
* @param string|null $url Optional URL for logo link
* @param string|null $text Optional text to display before the logo
* @param int $height Logo height in pixels (default: 20)
*/
public function withLogo(string $path, ?string $url = null, int $height = 20): static
public function withLogo(string $path, ?string $url = null, string $text = null, int $height = 20): static
{
$this->logoPath = $path;
$this->logoUrl = $url;
$this->logoHeight = $height;
$this->logoText = $text;

return $this;
}
Expand Down Expand Up @@ -328,6 +333,14 @@ public function getLogoUrl(): ?string
return $this->logoUrl;
}

/**
* Get the logo text
*/
public function getLogoText(): ?string
{
return $this->logoText;
}

/**
* Get the logo height
*/
Expand Down
3 changes: 2 additions & 1 deletion tests/Feature/FilamentPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@

it('can add logo with URL', function () {
$plugin = EasyFooterPlugin::make()
->withLogo('/path/to/logo.png', 'https://example.com', 25);
->withLogo('/path/to/logo.png', 'https://example.com', 'Something', 25);

expect($plugin)
->getLogoPath()->toBe('/path/to/logo.png')
->getLogoText()->toBe('Something')
->getLogoUrl()->toBe('https://example.com')
->getLogoHeight()->toBe(25);
});
Expand Down

0 comments on commit f35bc3c

Please sign in to comment.