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

Theming, Widgets, Dashboard #553

Open
adrolli opened this issue Jun 27, 2024 · 0 comments
Open

Theming, Widgets, Dashboard #553

adrolli opened this issue Jun 27, 2024 · 0 comments
Assignees

Comments

@adrolli
Copy link
Member

adrolli commented Jun 27, 2024

Some placements on the dashboard are not as we want, occupying too much space. One possibility would be to remove the extra heading on widgets (but then it must be obvious, what information the widget contains).

Possible thing:

Yes, you can suppress the heading of a Filament widget table by customizing the widget's configuration. Filament allows you to define a custom view for your widget, where you can control the display of various components, including the heading.

Here’s a step-by-step guide on how to suppress the heading of a Filament widget table:

Step 1: Create a Custom View

Create a custom view for your widget. This view will be used to render the table without the heading.

resources/views/filament/widgets/custom-table-widget.blade.php

<div>
    {{-- Remove or customize the heading as needed --}}
    {{-- <h1>{{ $this->getHeading() }}</h1> --}}
    {{ $this->table }}
</div>

Step 2: Configure the Widget to Use the Custom View

In your widget class, override the view method to specify the custom view you created.

app/Filament/Widgets/MyExpiry.php

<?php

namespace App\Filament\Widgets;

use Filament\Tables;
use Filament\Tables\Table;
use Moox\Expiry\Models\Expiry;
use Filament\Tables\Actions\ViewAction;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Actions\DeleteBulkAction;
use Moox\Core\Base\BaseWidget;

class MyExpiry extends BaseWidget
{
    protected static ?string $view = 'filament.widgets.custom-table-widget';

    public function getTable(): Table
    {
        if (method_exists($this, 'getAdvancedTable')) {
            return $this->getAdvancedTable();
        }

        return Table::make()
            ->columns([
                // Add your table columns here
            ])
            ->actions([
                ViewAction::make(),
            ])
            ->bulkActions([
                DeleteBulkAction::make(),
            ]);
    }

    // Other methods from your class can go here
}

Explanation

  1. Custom View: The custom view resources/views/filament/widgets/custom-table-widget.blade.php is created to define how the widget should be rendered. By commenting out or removing the heading line, you can suppress the heading of the table.
  2. Widget Configuration: In the MyExpiry widget class, the $view property is set to the custom view. This tells Filament to use the custom view for rendering the widget.

Optional: Conditional Suppression

If you want to conditionally suppress the heading based on certain conditions, you can add logic to your custom view or your widget class.

For example, in your custom view:

<div>
    @if($this->shouldShowHeading())
        <h1>{{ $this->getHeading() }}</h1>
    @endif
    {{ $this->table }}
</div>

And in your widget class:

public function shouldShowHeading(): bool
{
    // Add your custom logic here
    return false; // or true based on your conditions
}

This approach gives you full control over the rendering of your widget, allowing you to customize it as needed.

@adrolli adrolli self-assigned this Jun 27, 2024
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

No branches or pull requests

1 participant