wire-elements/modal

Plans to support volt?

Closed this issue · 2 comments

Is there a way to make this package support using volt livewire components?

Required interface [WireElements\Pro\Contracts\BehavesAsModal]


use WireElements\Pro\Components\Modal\Modal;
use function Livewire\Volt\{state};

new class extends Modal {
    public $count = 0;

    public function increment()
    {
        $this->count++;
    }
}

?>

<div>
    hello i should open in modal
</div>

You can use this approach.

<x-secondary-button x-data="" x-on:click.prevent="$dispatch('open-modal', 'create-new')">{{ __('Create New') }}</x-secondary-button>

<x-modal name="create-new" :show="$errors->isNotEmpty()"> <livewire:create /> </x-modal>

This is your volt create component.


use function Livewire\Volt\{state};

//

?>

<div>
    <form wire:submit="save" class="p-6">

        <h2 class="text-lg font-medium text-gray-900">
            {{ __('Create new') }}
        </h2>
        <input />

        <div class="mt-6 flex justify-end">
            <x-secondary-button x-on:click="$dispatch('close')">
                {{ __('Cancel') }}
            </x-secondary-button>

            <x-primary-button class="ms-3">
                {{ __('Submit') }}
            </x-primary-button>
        </div>
    </form>
</div>

Is there a way to make this package support using volt livewire components?

Required interface [WireElements\Pro\Contracts\BehavesAsModal]


use WireElements\Pro\Components\Modal\Modal;
use function Livewire\Volt\{state};

new class extends Modal {
    public $count = 0;

    public function increment()
    {
        $this->count++;
    }
}

?>

<div>
    hello i should open in modal
</div>

Not at this time unless there is a lot of demand. But I'm happy to accept a PR 😄