From 3ecb4d9a2870aa9597aaddf74b38864a2a68836a Mon Sep 17 00:00:00 2001 From: xikcode Date: Sun, 19 May 2024 16:08:24 +0200 Subject: [PATCH 1/3] Update 02-stats-overview.md Improve Stats Overview Widgets documentation for clarity and completeness --- packages/widgets/docs/02-stats-overview.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/widgets/docs/02-stats-overview.md b/packages/widgets/docs/02-stats-overview.md index 577a01f9d0c..9926713b455 100644 --- a/packages/widgets/docs/02-stats-overview.md +++ b/packages/widgets/docs/02-stats-overview.md @@ -58,6 +58,22 @@ protected function getStats(): array } ``` +The `descriptionIcon()` method also accepts a second parameter to specify the icon position. This parameter is part of `Filament\Support\Enums\IconPosition` and can be set to `Before` or `After`: + +```php +use Filament\Support\Enums\IconPosition; + +protected function getStats(): array +{ + return [ + Stat::make('Unique views', '192.1k') + ->description('32k increase') + ->descriptionIcon('heroicon-m-arrow-trending-up', IconPosition::Before), + // ... + ]; +} +``` + ## Changing the color of the stat You may also give stats a `color()` (`danger`, `gray`, `info`, `primary`, `success` or `warning`): From 06e11ca41c071c463f87acd5b292960bc3720c69 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Mon, 20 May 2024 12:55:32 +0100 Subject: [PATCH 2/3] Update 02-stats-overview.md --- packages/widgets/docs/02-stats-overview.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/widgets/docs/02-stats-overview.md b/packages/widgets/docs/02-stats-overview.md index 9926713b455..79c5fb5f7f9 100644 --- a/packages/widgets/docs/02-stats-overview.md +++ b/packages/widgets/docs/02-stats-overview.md @@ -42,6 +42,8 @@ Now, check out your widget in the dashboard. You may add a `description()` to provide additional information, along with a `descriptionIcon()`: ```php +use Filament\Widgets\StatsOverviewWidget\Stat; + protected function getStats(): array { return [ @@ -58,20 +60,15 @@ protected function getStats(): array } ``` -The `descriptionIcon()` method also accepts a second parameter to specify the icon position. This parameter is part of `Filament\Support\Enums\IconPosition` and can be set to `Before` or `After`: +The `descriptionIcon()` method also accepts a second parameter to put the icon before the description instead of after it: ```php use Filament\Support\Enums\IconPosition; +use Filament\Widgets\StatsOverviewWidget\Stat; -protected function getStats(): array -{ - return [ - Stat::make('Unique views', '192.1k') - ->description('32k increase') - ->descriptionIcon('heroicon-m-arrow-trending-up', IconPosition::Before), - // ... - ]; -} +Stat::make('Unique views', '192.1k') + ->description('32k increase') + ->descriptionIcon('heroicon-m-arrow-trending-up', IconPosition::Before) ``` ## Changing the color of the stat From 9a583fd04dc19d916d301d32147a4b31e8eb95be Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Mon, 20 May 2024 12:56:01 +0100 Subject: [PATCH 3/3] Update 02-stats-overview.md --- packages/widgets/docs/02-stats-overview.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/widgets/docs/02-stats-overview.md b/packages/widgets/docs/02-stats-overview.md index 79c5fb5f7f9..80dd56420ee 100644 --- a/packages/widgets/docs/02-stats-overview.md +++ b/packages/widgets/docs/02-stats-overview.md @@ -76,6 +76,8 @@ Stat::make('Unique views', '192.1k') You may also give stats a `color()` (`danger`, `gray`, `info`, `primary`, `success` or `warning`): ```php +use Filament\Widgets\StatsOverviewWidget\Stat; + protected function getStats(): array { return [ @@ -100,6 +102,8 @@ protected function getStats(): array You may also pass extra HTML attributes to stats using `extraAttributes()`: ```php +use Filament\Widgets\StatsOverviewWidget\Stat; + protected function getStats(): array { return [ @@ -121,6 +125,8 @@ In this example, we are deliberately escaping the `$` in `$dispatch()` since thi You may also add or chain a `chart()` to each stat to provide historical data. The `chart()` method accepts an array of data points to plot: ```php +use Filament\Widgets\StatsOverviewWidget\Stat; + protected function getStats(): array { return [