An open API service indexing awesome lists of open source software.

https://github.com/simtabi/laramodal


https://github.com/simtabi/laramodal

Last synced: 4 months ago
JSON representation

Awesome Lists containing this project

README

          

# Livewire Modal

Turn any Laravel Livewire Component into Modal.

## ๐Ÿท Features
- Modal triggered by javascript i.e. opens instantly without waiting for livewire network round trip to finish ( no laggy feeling )
- Skeleton loading indicator
- Support alert message ( info, warning, success, danger )
- Trigger from Alpine Component / Vanilla JS / Livewire Class Component

## ๐Ÿงพ Requirements

- Bootstrap 5
- Laravel >= 7
- Livewire >= 2.0
- Alpine JS

## ๐Ÿ“ฅ Installation

```shell
composer require simtabi/laramodal
```

#### Include the base modal component
```html

...
@laramodalStylesInit

...
@laramodalScriptsInit

```

#### Publish assets
```shell
php artisan vendor:publish --force --tag=laramodal:assets
```

#### Publish config
```shell
php artisan vendor:publish --force --tag=laramodal:config
```
> config support bootstrap theme: bs5

### ๐Ÿ“Œ Updating
> **Important:** when updating the package make sure to re-publish the assets with `--force` flag
```shell
php artisan vendor:publish --force --tag=laramodal:assets
```

## โš—๏ธ Usage
### Create Livewire Component
No consideration required, create livewire component as usual. Use livewire's `mount` to handle passed parameters

### โœจ Open Modal

###### โœ”๏ธ From Alpine Component
```html


open


```

###### โœ”๏ธ Via Vanilla JS

```html

open

```

###### โœ”๏ธ Via Trigger Blade Component

```html

{{__('Title')}}

```

###### โœ”๏ธ From Livewire Class

```php
$this->dispatchBrowserEvent('open-x-modal', ['title' => 'My Modal', 'modal' => 'product.order', 'args' => ['id' => 1, 'rate' => 20]]);
```

> ๐Ÿ’ก Modal size supports `sm` `lg` `xl` *// completely optional*

#### โœŒ๐Ÿผ Two reasons to use this component

๐ŸŸข a pretty line progress loading indicator which appears in the top when livewire loading state changes

๐ŸŸข alert notification message which can be triggered by:
```php
$this->info('Hi !, i am an alert'); // support `info` `warning` `success` `danger`
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## ๐Ÿ‘‹๐Ÿผ Say Hi!
Leave a โญ if you find this package useful ๐Ÿ‘๐Ÿผ,
don't forget to let me know in [Twitter](https://twitter.com/simtabi)