Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanalhattami committed Apr 23, 2024
2 parents 4625e48 + 5c3c7c2 commit 182d50d
Showing 1 changed file with 60 additions and 25 deletions.
85 changes: 60 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

---
This package is used to add context menu (right click menu) for resource pages and custom pages of [Filament Admin Panel](https://filamentphp.com/).
* It uses [Filament Actions](https://filamentphp.com/docs/3.x/actions/overview) to set menu items.
* It uses [Filament Actions](https://filamentphp.com/docs/3.x/actions/overview) to set menu actions.
* Support dark and light mode.
* Support left-to-right and right-to-left direction.
* You can set a divider between menu actions.
* Supports resource pages and custom pages.
* There are a set of useful actions:
* Three actions are available for usage:
* ```AymanAlhattami\FilamentContextMenu\RefreshAction``` to refresh the page.
* ```AymanAlhattami\FilamentContextMenu\GoBackAction``` to go back to previous page.
* ```AymanAlhattami\FilamentContextMenu\GoForward``` to go back to forward page.
* ```AymanAlhattami\FilamentContextMenu\GoForward``` to go to the forward page.

[Demo project](https://github.com/aymanalhattami/filament-context-menu-project)

Expand All @@ -32,7 +32,11 @@ composer require aymanalhattami/filament-context-menu
2. Then, define a ```getContextMenuActions``` method inside the page, the method should return an array of [Filament Actions](https://filamentphp.com/docs/3.x/actions/installation)

```php
use App\Filament\Resources\UserResource\Pages\CreateUser;use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Actions\Action;use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\UserResource\Pages\CreateUser;
use Filament\Resources\Pages\ListRecords;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use Filament\Actions\Action;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ListUsers extends ListRecords
{
Expand All @@ -54,9 +58,13 @@ class ListUsers extends ListRecords

### Divider
You can use ```AymanAlhattami\FilamentContextMenu\ContextMenuDivider``` to set divider between menu actions

```php
use App\Filament\Resources\UserResource\Pages\CreateUser;use App\Filament\Resources\UserResource\Pages\TrashedUsers;use AymanAlhattami\FilamentContextMenu\ContextMenuDivider;use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Actions\Action;use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\UserResource\Pages\CreateUser;
use App\Filament\Resources\UserResource\Pages\TrashedUsers;
use Filament\Resources\Pages\ListRecords;
use Filament\Actions\Action;
use AymanAlhattami\FilamentContextMenu\ContextMenuDivider;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ListUsers extends ListRecords
{
Expand All @@ -83,7 +91,10 @@ class ListUsers extends ListRecords
You can use ```Filament\Actions\CreateAction```, visit [filament create action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords;
use AymanAlhattami\FilamentContextMenu\ContextMenuDivider;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
use Filament\Actions\CreateAction;

class ListUsers extends ListRecords
{
Expand Down Expand Up @@ -112,7 +123,9 @@ class ListUsers extends ListRecords
You can use ```Filament\Actions\EditAction```, visit [filament edit action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/edit) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
use Filament\Actions\EditAction;

class ViewUser extends ViewRecord
{
Expand Down Expand Up @@ -141,7 +154,10 @@ class ViewUser extends ViewRecord
You can use ```Filament\Actions\ViewAction```, visit [filament view action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/view) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\EditRecord;
use Filament\Resources\Pages\EditRecord;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
use Filament\Actions\ViewAction;
use Filament\Forms\Components\TextInput;

class EditUser extends EditRecord
{
Expand Down Expand Up @@ -171,7 +187,9 @@ class EditUser extends EditRecord
You can use ```Filament\Actions\DeleteAction```, visit [filament delete action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/delete) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand All @@ -195,7 +213,9 @@ class ViewUser extends ViewRecord
You can use ```Filament\Actions\ReplicateAction```, visit [filament replicate action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/replicate) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand All @@ -219,7 +239,9 @@ class ViewUser extends ViewRecord
You can use ```Filament\Actions\ForceDeleteAction```, visit [filament force delete action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/force-delete) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand All @@ -243,7 +265,9 @@ class ViewUser extends ViewRecord
You can use ```Filament\Actions\RestoreAction```, visit [filament restore action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/restore) for more information.

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ListUsers extends ListRecords
{
Expand All @@ -267,7 +291,10 @@ class ListUsers extends ListRecords
You can use ```Filament\Actions\ImportAction```, visit [filament import action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/import) for more information.

```php
use App\Filament\Imports\UserImporter;use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
use App\Filament\Imports\UserImporter;

class ListUsers extends ListRecords
{
Expand All @@ -291,7 +318,10 @@ class ListUsers extends ListRecords
You can use ```Filament\Actions\ExportAction```, visit [filament export action](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/export) for more information.

```php
use App\Filament\Exports\UserExporter;use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Pages\ListRecords;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
use App\Filament\Exports\UserExporter;

class ListUsers extends ListRecords
{
Expand All @@ -313,9 +343,10 @@ class ListUsers extends ListRecords

### Example: action with modal
You can use filament action with modal

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand Down Expand Up @@ -351,9 +382,10 @@ class ViewUser extends ViewRecord
```

### Example: refresh, go back and go forward actions

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand All @@ -364,9 +396,9 @@ class ViewUser extends ViewRecord
public static function getContextMenuActions(): array
{
return [
\AymanAlhattami\FilamentContextMenu\Actions\RefreshAction::make(),
\AymanAlhattami\FilamentContextMenu\Actions\GoBackAction::make(),
\AymanAlhattami\FilamentContextMenu\Actions\GoForwardAction::make()
\AymanAlhattami\FilamentContextMenu\RefreshAction::make(),
\AymanAlhattami\FilamentContextMenu\GoBackAction::make(),
\AymanAlhattami\FilamentContextMenu\GoForwardAction::make()
];
}

Expand All @@ -380,7 +412,9 @@ Method 1: To globally enable or disable context menu, you need to define an env
Method 2: You can also define a static variable called ```public static bool $contextMenuEnabled``` in the page and set the value to ```true``` or ```false```;

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand All @@ -401,9 +435,10 @@ class ViewUser extends ViewRecord
```

Method 3: define static method called ```isContextMenuEnabled``` in the page

```php
use AymanAlhattami\FilamentContextMenu\Traits\InteractsWithContextMenuActions;use Filament\Resources\Pages\ViewRecord;
use Filament\Resources\Pages\ViewRecord;
use AymanAlhattami\FilamentContextMenu\ContextMenu;
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;

class ViewUser extends ViewRecord
{
Expand Down

0 comments on commit 182d50d

Please sign in to comment.