@wishbone-media/spark 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +227 -201
- package/package.json +1 -1
- package/src/components/SparkBrandSelector.vue +3 -3
- package/src/components/SparkOverlay.vue +24 -17
- package/src/composables/index.js +1 -0
- package/src/composables/sparkOverlayService.js +31 -0
- package/src/composables/useSparkOverlay.js +7 -4
- package/src/stores/brand-filter.js +1 -1
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</div>
|
|
14
14
|
</div>
|
|
15
15
|
<div
|
|
16
|
-
v-for="brand in
|
|
16
|
+
v-for="brand in sparkBrandFilterStore.allBrands"
|
|
17
17
|
:key="brand.name"
|
|
18
18
|
:class="brand.current ? 'bg-gray-50' : 'hover:bg-gray-50'"
|
|
19
19
|
class="flex px-[22px] py-[15px] cursor-pointer"
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
</template>
|
|
48
48
|
|
|
49
49
|
<script setup>
|
|
50
|
-
import {
|
|
50
|
+
import { useSparkBrandFilterStore } from '@/stores/brand-filter'
|
|
51
51
|
import { Icons } from '@/plugins/fontawesome'
|
|
52
52
|
|
|
53
53
|
const emit = defineEmits(['close', 'select'])
|
|
54
54
|
|
|
55
|
-
const
|
|
55
|
+
const sparkBrandFilterStore = useSparkBrandFilterStore()
|
|
56
56
|
|
|
57
57
|
const selectBrand = (brand) => {
|
|
58
58
|
emit('select', brand)
|
|
@@ -1,42 +1,48 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<TransitionRoot :show="overlayInstance.state.isVisible" as="template">
|
|
3
|
-
<Dialog
|
|
3
|
+
<Dialog
|
|
4
|
+
:initialFocus="panelRef"
|
|
5
|
+
class="relative z-200"
|
|
6
|
+
@close="overlayInstance.close"
|
|
7
|
+
>
|
|
4
8
|
<TransitionChild
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
as="template"
|
|
10
|
+
enter="transition-opacity ease-linear duration-150"
|
|
11
|
+
enter-from="opacity-0"
|
|
12
|
+
enter-to="opacity-100"
|
|
13
|
+
leave="transition-opacity ease-linear duration-150"
|
|
14
|
+
leave-from="opacity-100"
|
|
15
|
+
leave-to="opacity-0"
|
|
12
16
|
>
|
|
13
17
|
<div class="fixed inset-0 bg-gray-600/30" />
|
|
14
18
|
</TransitionChild>
|
|
15
19
|
|
|
16
20
|
<div class="fixed inset-0 flex">
|
|
17
21
|
<TransitionChild
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
as="template"
|
|
23
|
+
enter="transition ease-in-out duration-150 transform"
|
|
24
|
+
:enter-from="
|
|
21
25
|
position === 'left' ? '-translate-x-full opacity-0' : 'translate-x-full opacity-0'
|
|
22
26
|
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
enter-to="translate-x-0 opacity-100"
|
|
28
|
+
leave="transition ease-in-out duration-150 transform"
|
|
29
|
+
leave-from="translate-x-0 opacity-100"
|
|
30
|
+
:leave-to="
|
|
27
31
|
position === 'left' ? '-translate-x-full opacity-0' : 'translate-x-full opacity-0'
|
|
28
32
|
"
|
|
29
33
|
>
|
|
30
34
|
<DialogPanel
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
ref="panelRef"
|
|
36
|
+
:class="[
|
|
33
37
|
'flex w-[400px] py-2.5',
|
|
34
38
|
position === 'left' ? 'relative left-[10px]' : 'absolute right-[10px] h-full',
|
|
35
39
|
]"
|
|
36
40
|
>
|
|
41
|
+
<!-- Bind props and event handlers dynamically -->
|
|
37
42
|
<component
|
|
38
43
|
:is="overlayInstance.state.content"
|
|
39
44
|
v-bind="{ ...$attrs, ...overlayInstance.state.props }"
|
|
45
|
+
v-on="overlayInstance.state.eventHandlers"
|
|
40
46
|
/>
|
|
41
47
|
</DialogPanel>
|
|
42
48
|
</TransitionChild>
|
|
@@ -57,6 +63,7 @@ defineProps({
|
|
|
57
63
|
required: true,
|
|
58
64
|
validator: (value) => ['left', 'right'].includes(value),
|
|
59
65
|
},
|
|
66
|
+
|
|
60
67
|
overlayInstance: {
|
|
61
68
|
type: Object,
|
|
62
69
|
required: true,
|
package/src/composables/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useSparkOverlay } from '@/composables/useSparkOverlay'
|
|
2
|
+
|
|
3
|
+
class SparkOverlayService {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.left = useSparkOverlay()
|
|
6
|
+
this.right = useSparkOverlay()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
showLeft = (component, props = {}, eventHandlers = {}) => {
|
|
10
|
+
this.left.show(component, props, eventHandlers)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
showRight = (component, props = {}, eventHandlers = {}) => {
|
|
14
|
+
this.right.show(component, props, eventHandlers)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
closeLeft = () => {
|
|
18
|
+
this.left.close()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
closeRight = () => {
|
|
22
|
+
this.right.close()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
closeAll = () => {
|
|
26
|
+
this.left.close()
|
|
27
|
+
this.right.close()
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const sparkOverlayService = new SparkOverlayService()
|
|
@@ -5,6 +5,7 @@ export function useSparkOverlay() {
|
|
|
5
5
|
isVisible: false,
|
|
6
6
|
content: null,
|
|
7
7
|
props: {},
|
|
8
|
+
eventHandlers: {},
|
|
8
9
|
})
|
|
9
10
|
|
|
10
11
|
const toggle = () => {
|
|
@@ -13,19 +14,21 @@ export function useSparkOverlay() {
|
|
|
13
14
|
|
|
14
15
|
const close = () => {
|
|
15
16
|
state.isVisible = false
|
|
17
|
+
state.eventHandlers = {}
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
const open = () => {
|
|
19
21
|
state.isVisible = true
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
const setContent = (content, props = {}) => {
|
|
24
|
+
const setContent = (content, props = {}, eventHandlers = {}) => {
|
|
23
25
|
state.content = markRaw(content)
|
|
24
26
|
state.props = props
|
|
27
|
+
state.eventHandlers = eventHandlers
|
|
25
28
|
}
|
|
26
29
|
|
|
27
|
-
const show = (content, props = {}) => {
|
|
28
|
-
if (content) setContent(content, props)
|
|
30
|
+
const show = (content, props = {}, eventHandlers = {}) => {
|
|
31
|
+
if (content) setContent(content, props, eventHandlers)
|
|
29
32
|
open()
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -37,4 +40,4 @@ export function useSparkOverlay() {
|
|
|
37
40
|
setContent,
|
|
38
41
|
show,
|
|
39
42
|
}
|
|
40
|
-
}
|
|
43
|
+
}
|
|
@@ -5,7 +5,7 @@ import mrPestControllerLogo from '@/assets/images/mr-pest-controller.png'
|
|
|
5
5
|
import mrGutterCleaningLogo from '@/assets/images/mr-gutter-cleaning.png'
|
|
6
6
|
import mrAntennaLogo from '@/assets/images/mr-antenna.png'
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const useSparkBrandFilterStore = defineStore('brandFilter', () => {
|
|
9
9
|
const state = reactive({
|
|
10
10
|
brands: [
|
|
11
11
|
{
|