Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showing icon only when it has value and ... #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tiagofrancafernandes
Copy link

  • allows programmatic hiding

On branch fix/check-state-before-load-icon
modified: resources/views/tables/icon-column.blade.php
modified: src/Tables/IconColumn.php

- allows programmatic hiding

On branch fix/check-state-before-load-icon
	modified:   resources/views/tables/icon-column.blade.php
	modified:   src/Tables/IconColumn.php
@tiagofrancafernandes
Copy link
Author

Allow

\Guava\FilamentIconPicker\Tables\IconColumn::make('icon')

    // Hide programmatically
    ->hideIcon(fn(?Model $record) => !$record?->icon)

    // Set manually an icon
    ->useIcon('feathericon-tag') // string
    ->useIcon(fn(?Model $record) => $record?->icon) // Closure
    ->useIcon(fn(?Model $record) => $record?->icon ?? 'feathericon-tag') // With alter/default value

  // Note: In the future, maybe create a default icon method if it has no value in the 'state'

@tiagofrancafernandes
Copy link
Author

In blade:

+@if (!$toHideIcon())
 <div class="filament-icon-picker-icon-column px-4 py-3">
-       <x-icon class="h-6" name="{{$getState()}}" />
+    <x-icon class="h-6" name="{{$getIcon()}}" />
 </div>
+@endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant