Skip to content

Commit

Permalink
add widget sort
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsramos committed Jun 24, 2024
1 parent d9ca79e commit 2b9ee9e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Version on Packagist](https://img.shields.io/packagist/v/rmsramos/system-info.svg?style=flat-square)](https://packagist.org/packages/rmsramos/system-info)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/rmsramos/system-info/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/rmsramos/system-info/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain)
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/rmsramos/system-info/fix-php-code-styling-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/rmsramos/system-info/actions?query=workflow%3A"fix+php+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/rmsramos/system-info.svg?style=flat-square)](https://packagist.org/packages/rmsramos/system-info/stats)

![Screenshot of Application Feature](https://raw.githubusercontent.com/rmsramos/system-info/main/arts/cover.png)
Expand Down Expand Up @@ -32,7 +32,8 @@ class AdminPanelProvider extends PanelProvider
{
return $panel
->plugins([
SystemInfoPlugin::make(),
SystemInfoPlugin::make()
->setSort(2),
]);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/Filament/Widgets/SystemInfoWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
namespace Rmsramos\SystemInfo\Filament\Widgets;

use Filament\Widgets\Widget;
use Rmsramos\SystemInfo\SystemInfoPlugin;

class SystemInfoWidget extends Widget
{
//protected static ?int $sort = -2;
public static function getSort(): int
{

return SystemInfoPlugin::get()->getSort() ?? -1;
}

protected static bool $isLazy = false;

Expand Down
19 changes: 19 additions & 0 deletions src/SystemInfoPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

namespace Rmsramos\SystemInfo;

use Closure;
use Filament\Contracts\Plugin;
use Filament\Panel;
use Filament\Support\Concerns\EvaluatesClosures;
use Rmsramos\SystemInfo\Filament\Widgets\SystemInfoWidget;

class SystemInfoPlugin implements Plugin
{
use EvaluatesClosures;

public Closure | null | int $sort = null;

public function getId(): string
{
return 'system-info';
Expand Down Expand Up @@ -38,4 +44,17 @@ public static function get(): static

return $plugin;
}

public function setSort(Closure | int | null $value = null): static
{
$this->sort = $value;

return $this;
}

public function getSort(): ?int
{
return $this->evaluate($this->sort);
}

}

0 comments on commit 2b9ee9e

Please sign in to comment.