Skip to content

Commit f35bc3c

Browse files
authored
Merge pull request #6 from Cybrarist/feature/add-text-to-custom-logo
- add text to custom logo, and make custom logo url opens in new tab - update doc - update test
2 parents ac5f5e8 + bd2a9df commit f35bc3c

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,24 +237,52 @@ use Devonab\FilamentEasyFooter\EasyFooterPlugin;
237237
![Filament Easy Footer custom logo](https://raw.githubusercontent.com/Devonab/filament-easy-footer/main/art/custom_logo.webp)
238238

239239

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

242245
```php
243246
use Devonab\FilamentEasyFooter\EasyFooterPlugin;
244247

245248
->plugins([
246249
EasyFooterPlugin::make()
247-
->withLogo('https://static.cdnlogo.com/logos/l/23/laravel.svg', 'https://laravel.com')
250+
->withLogo(
251+
'https://static.cdnlogo.com/logos/l/23/laravel.svg', // Path to logo
252+
'https://laravel.com' // URL for logo link (optional)
253+
)
248254
])
249255
```
250256

251-
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).
257+
You can customize the logo further with optional text and height:
258+
259+
```php
260+
use Devonab\FilamentEasyFooter\EasyFooterPlugin;
261+
262+
->plugins([
263+
EasyFooterPlugin::make()
264+
->withLogo(
265+
'https://static.cdnlogo.com/logos/l/23/laravel.svg', // Path to logo
266+
'https://laravel.com', // URL for logo link (optional)
267+
'Powered by Laravel', // Text to display (optional)
268+
35 // Logo height in pixels (default: 20)
269+
)
270+
])
271+
```
272+
273+
If you don't need the link, you can pass `null` for the second parameter:
274+
252275
```php
253276
use Devonab\FilamentEasyFooter\EasyFooterPlugin;
254277

255278
->plugins([
256279
EasyFooterPlugin::make()
257-
->withLogo('https://static.cdnlogo.com/logos/l/23/laravel.svg', null, 60)
280+
->withLogo(
281+
'https://static.cdnlogo.com/logos/l/23/laravel.svg', // Path to logo
282+
null, // No link
283+
null, // No text
284+
60 // Logo height in pixels
285+
)
258286
])
259287
```
260288

resources/views/easy-footer.blade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@
5555
@endif
5656

5757
@if($logoPath)
58-
<span class="flex items-center">
58+
<span class="flex items-center gap-2">
59+
@if($logoText)
60+
<span>{{ $logoText }}</span>
61+
@endif
5962
@if($logoUrl)
60-
<a href="{{ $logoUrl }}" class="inline-flex">
63+
<a href="{{ $logoUrl }}" class="inline-flex" target="_blank">
6164
@endif
6265
<img
6366
src="{{ $logoPath }}"

src/EasyFooterPlugin.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class EasyFooterPlugin implements Plugin
3939

4040
protected ?string $logoUrl = null;
4141

42+
protected ?string $logoText = null;
43+
4244
protected int $logoHeight = 20;
4345

4446
protected bool $isFooterEnabled = true;
@@ -121,6 +123,7 @@ protected function renderFooter(float $startTime): string
121123
'showUrl' => $this->showUrl,
122124
'logoPath' => $this->logoPath,
123125
'logoUrl' => $this->logoUrl,
126+
'logoText' => $this->logoText,
124127
'logoHeight' => $this->logoHeight,
125128
'borderTopEnabled' => $this->borderTopEnabled,
126129
'loadTime' => $this->loadTimeEnabled ? $this->calculateLoadTime($startTime) : false,
@@ -259,13 +262,15 @@ public function withLinks(array $links): static
259262
*
260263
* @param string $path Path to the logo image
261264
* @param string|null $url Optional URL for logo link
265+
* @param string|null $text Optional text to display before the logo
262266
* @param int $height Logo height in pixels (default: 20)
263267
*/
264-
public function withLogo(string $path, ?string $url = null, int $height = 20): static
268+
public function withLogo(string $path, ?string $url = null, string $text = null, int $height = 20): static
265269
{
266270
$this->logoPath = $path;
267271
$this->logoUrl = $url;
268272
$this->logoHeight = $height;
273+
$this->logoText = $text;
269274

270275
return $this;
271276
}
@@ -328,6 +333,14 @@ public function getLogoUrl(): ?string
328333
return $this->logoUrl;
329334
}
330335

336+
/**
337+
* Get the logo text
338+
*/
339+
public function getLogoText(): ?string
340+
{
341+
return $this->logoText;
342+
}
343+
331344
/**
332345
* Get the logo height
333346
*/

tests/Feature/FilamentPluginTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@
133133

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

138138
expect($plugin)
139139
->getLogoPath()->toBe('/path/to/logo.png')
140+
->getLogoText()->toBe('Something')
140141
->getLogoUrl()->toBe('https://example.com')
141142
->getLogoHeight()->toBe(25);
142143
});

0 commit comments

Comments
 (0)