Skip to content

Commit c64130c

Browse files
committed
Add global slideover
1 parent 2394052 commit c64130c

File tree

6 files changed

+78
-0
lines changed

6 files changed

+78
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script>
2+
export default {
3+
props: {
4+
title: String,
5+
position: String,
6+
contents: String,
7+
},
8+
9+
render() {
10+
return this.$scopedSlots.default(this)
11+
},
12+
13+
methods: {
14+
open() {
15+
this.$root.globalSlideover.content = this.slideoverContents
16+
this.$root.globalSlideover.title = this.title
17+
this.$root.globalSlideover.position = this.position
18+
},
19+
},
20+
21+
computed: {
22+
slideoverContents() {
23+
if (this.contents) {
24+
return this.contents
25+
}
26+
27+
return this.$el.querySelector('.global-slideover-wrapper').innerHTML;
28+
}
29+
},
30+
}
31+
</script>

resources/js/package.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ function init() {
9494
// implement payment providers.
9595
doNotGoToTheNextStep: false,
9696
},
97+
globalSlideover: {
98+
title: '',
99+
position: 'left',
100+
content: '',
101+
},
97102
},
98103
methods: {
99104
search(value) {

resources/js/vue-components.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Vue.component('graphql-mutation', graphqlMutation)
1818

1919
import notifications from './components/Notifications/Notifications.vue'
2020
Vue.component('notifications', notifications)
21+
import globalSlideover from './components/GlobalSlideover.vue'
22+
Vue.component('global-slideover', globalSlideover)
2123

2224
import images from './components/Product/Images.vue'
2325
Vue.component('images', images)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{--
2+
This is a wrapper for the global slideover. Use this as much as possible to reduce the amount of html elements in the DOM.
3+
4+
Standard usage may look like this:
5+
<x-rapidez::slideover.global :title="__('My slideover')">
6+
<x-slot:label class="rounded p-3 border">
7+
Click me
8+
</x-slot:label>
9+
10+
<div class="font-semibold">
11+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
12+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
13+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
14+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
15+
</div>
16+
</x-rapidez::slideover.global>
17+
--}}
18+
19+
@props(['title', 'position' => 'left'])
20+
@slots(['label', 'contents'])
21+
22+
<global-slideover title="{{ $title }}" position="{{ $position }}" contents="{{ $slot->toHtml() }}" v-slot="slideover">
23+
<label {{ $label->attributes->class('global-slideover-label cursor-pointer') }} for="slideover-global" v-on:click="slideover.open">
24+
{{ $label }}
25+
</label>
26+
</global-slideover>

resources/views/layouts/app.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
</main>
3535
@includeWhen(!request()->is('checkout'), 'rapidez::layouts.partials.footer')
3636
@includeWhen(request()->is('checkout'), 'rapidez::layouts.checkout.footer')
37+
38+
@include('rapidez::layouts.partials.global-slideover')
3739
@stack('page_end')
3840
</div>
3941

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<template v-if="globalSlideover.content ?? false" v-cloak>
2+
<x-rapidez::slideover
3+
id="slideover-global"
4+
v-bind:class="{ '-right-full peer-checked:right-0 !left-auto': (globalSlideover.position ?? 'left') === 'right' }"
5+
>
6+
<x-slot:title>
7+
<div v-html="globalSlideover.title ?? ''"></div>
8+
</x-slot:title>
9+
10+
<div v-html="globalSlideover.content ?? ''"></div>
11+
</x-rapidez::slideover>
12+
</template>

0 commit comments

Comments
 (0)