PHP code example of mrjokermr / dynamic-modal-wrapper
1. Go to this page and download the library: Download mrjokermr/dynamic-modal-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mrjokermr / dynamic-modal-wrapper example snippets
use Mrjokermr\DynamicModalWrapper\Dtos\OpenModalDto;
use Mrjokermr\DynamicModalWrapper\Livewire\DynamicModalWrapper;
$this->dispatch(
DynamicModalWrapper::OPEN_EVENT,
new OpenModalDto(
livewireClass: CreateProductModal::class,
)
);
use Mrjokermr\DynamicModalWrapper\Dtos\OpenModalDto;
use Mrjokermr\DynamicModalWrapper\Livewire\DynamicModalWrapper;
$this->dispatch(
DynamicModalWrapper::OPEN_EVENT,
new OpenModalDto(
livewireClass: CreateProductModal::class,
params: ['id' => 12]
)
);
use Mrjokermr\DynamicModalWrapper\Dtos\OpenModalDto;
use Mrjokermr\DynamicModalWrapper\Livewire\DynamicModalWrapper;
function open()
{
$this->dispatch(
DynamicModalWrapper::OPEN_EVENT,
(new OpenModalDto(
livewireClass: CreateProductModal::class,
params: ['id' => 12],
))->setName(name: 'create-product-modal')
);
}
class CreateProductModal extends Component
{
public function mount(int $id)
{
//...
}
}
use Mrjokermr\DynamicModalWrapper\Dtos\OpenModalDto;
use Mrjokermr\DynamicModalWrapper\Livewire\DynamicModalWrapper;
$this->dispatch(
DynamicModalWrapper::OPEN_EVENT,
(new OpenModalDto(
livewireClass: CreateProductModal::class,
params: ['id' => 12]
))->setContentBackgroundColorHex(hexColor: '#292929') //hexColor: '292929' is also valid
);
use Mrjokermr\DynamicModalWrapper\Livewire\DynamicModalWrapper;
DynamicModalWrapper::OPEN_EVENT,
DynamicModalWrapper::CLOSE_EVENT,
DynamicModalWrapper::CLOSING_EVENT, //will be dispatched before closing the modal, and dispatched the optionally set ->setName(name: 'modal-name') name.
return [
'default_content_padding' => '1.25rem', //can be set to any CSS accepted value. Also nullable
'escape_to_close' => true, //when the user presses the ESC button the shown modal will be closed
'default_content_wrapper_background_color_hex' => '#ffffff', //color used for wrapping the Livewire modal content
'wrapper_background_color_hex' => '#bdbdbd33', //color used in combination with the backdrop blur.
'z-index' => 100, //used by the dynamic modal container
];