Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit 308c22e

Browse files
committed
Support for slideover from left
1 parent bb64479 commit 308c22e

File tree

7 files changed

+44
-6
lines changed

7 files changed

+44
-6
lines changed

app/resources/views/modal/base.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<div class="flex space-x-3">
88
<Link modal dusk="one" href="{{ route('modal.one') }}">Open Modal One</Link>
99
<Link slideover dusk="slideover" href="{{ route('modal.slideover') }}">Open Modal Slideover</Link>
10+
<Link slideover dusk="slideover-left" href="{{ route('modal.slideover', ['left' => 1]) }}">Open Modal Slideover Left</Link>
1011
<Link modal dusk="validation" href="{{ route('modal.validation') }}">Open Modal Validation</Link>
1112
<Link modal dusk="libraries" href="{{ route('form.components.libraries') }}">Open Form Libraries</Link>
1213
<Link modal dusk="form-select" href="{{ route('form.components.customSelectOptions') }}">Open Custom Select Options</Link>

app/resources/views/modal/slideover.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
@section('content')
44

5-
<x-splade-modal>
5+
<x-splade-modal position="{{ request()->query('left') ? 'left' : 'right' }}">
66
ModalComponentSlideover
77

88
<Link modal dusk="one-from-slideover" href="{{ route('modal.one') }}">Open Modal One</Link>

app/tests/Browser/ModalTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,29 @@ public function it_can_show_a_slideover()
8181
});
8282
}
8383

84+
/** @test */
85+
public function it_can_show_a_slideover_on_the_left_side()
86+
{
87+
$this->browse(function (Browser $browser) {
88+
$browser->visit('/modal/base')
89+
->resize(1024, 768)
90+
->waitForText('ModalComponent')
91+
->click('@slideover-left')
92+
->waitForText('ModalComponentSlideover')
93+
->pause(500)
94+
->screenshot('ModalComponentSlideover')
95+
->click('@close-slideover')
96+
->waitUntilMissingText('ModalComponentSlideover')
97+
->pause(500)
98+
->screenshot('ModalComponentSlideoverClosed');
99+
100+
$this->assertScreenshotSnapshot([
101+
'ModalComponentSlideover',
102+
'ModalComponentSlideoverClosed',
103+
]);
104+
});
105+
}
106+
84107
/** @test */
85108
public function it_can_do_nested_slideover()
86109
{

lib/Components/Modal.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export default {
4747
position: {
4848
type: String,
4949
required: false,
50-
default: "center"
50+
default: (props) => {
51+
return props.type === "modal" ? "center" : "right";
52+
},
5153
},
5254
5355
name: {

resources/views/components/slideover.blade.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
<!-- Full-screen scrollable container -->
33
<div class="fixed inset-0 z-40 overflow-y-auto">
44
<!-- Container to center the panel -->
5-
<div class="flex min-h-full items-center justify-end">
5+
<div class="flex min-h-full items-center" v-bind:class="{
6+
'justify-start': modal.position === 'left',
7+
'justify-end': modal.position === 'right'
8+
}">
69
<!-- The actual dialog panel -->
7-
<x-splade-component is="transition" child animation="slide-right" after-leave="modal.emitClose" v-bind:class="{
10+
<x-splade-component is="transition" child after-leave="modal.emitClose" v-bind:class="{
811
'transition w-full': true,
912
'blur-sm': !modal.onTopOfStack,
1013
'sm:max-w-sm': modal.maxWidth == 'sm',
@@ -17,7 +20,7 @@
1720
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl': modal.maxWidth == '5xl',
1821
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-6xl': modal.maxWidth == '6xl',
1922
'sm:max-w-md md:max-w-xl lg:max-w-3xl xl:max-w-5xl 2xl:max-w-7xl': modal.maxWidth == '7xl'
20-
}">
23+
}" animation="{{ $attributes->get('position') === 'left' ? 'slide-left' : 'slide-right' }}">
2124
<x-splade-component is="dialog" panel dusk="slideover-dialog">
2225
<div {{ $attributes->class('bg-white p-6 min-h-screen relative') }}>
2326
<div v-if="modal.closeButton" class="absolute top-0 right-0 pt-3 pr-3">
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<div class='duration-300 ease-in-out opacity-0 opacity-100 scale-100 scale-95 sm:scale-100 sm:scale-95 sm:translate-y-0 transform transition translate-x-0 translate-x-full translate-y-0 translate-y-4'>
1+
<div class='-translate-x-full duration-300 ease-in-out opacity-0 opacity-100 scale-100 scale-95 sm:scale-100 sm:scale-95 sm:translate-y-0 transform transition translate-x-0 translate-x-full translate-y-0 translate-y-4'>
22
<!-- This is an automatically generated template so that Tailwind won't purge these transition classes... -->
33
</div>

src/ServiceProvider.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,15 @@ public static function registerTransitionAnimations(TransitionRepository $transi
512512
leaveFrom: 'opacity-100 translate-y-0 sm:scale-100',
513513
leaveTo: 'opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95',
514514
)
515+
->new(
516+
name: 'slide-left',
517+
enter: 'transform transform ease-in-out duration-300',
518+
enterFrom: 'opacity-0 -translate-x-full',
519+
enterTo: 'opacity-100 translate-x-0',
520+
leave: 'transform transform ease-in-out duration-300',
521+
leaveFrom: 'opacity-100 translate-x-0',
522+
leaveTo: 'opacity-0 -translate-x-full',
523+
)
515524
->new(
516525
name: 'slide-right',
517526
enter: 'transform transform ease-in-out duration-300',

0 commit comments

Comments
 (0)