-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPluginConfigShell.vue
More file actions
103 lines (84 loc) · 2.91 KB
/
PluginConfigShell.vue
File metadata and controls
103 lines (84 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<script setup lang="ts">
import { mdiArrowLeft, mdiArrowRight, mdiClose } from '@mdi/js'
import { getPluginById, PLUGINS } from '@/data/plugins'
// Stores
import { useBuilderStore } from '@/stores/builder'
// Utilities
import { toRef } from 'vue'
import { useRouter } from 'vue-router'
const { pluginId } = defineProps<{
pluginId: string
}>()
const emit = defineEmits<{
save: []
}>()
const store = useBuilderStore()
const router = useRouter()
const meta = toRef(() => getPluginById(pluginId))
const sequence = toRef(() => PLUGINS.filter(p => store.isPluginSelected(p.id)))
const position = toRef(() => sequence.value.findIndex(p => p.id === pluginId))
const isFirst = toRef(() => position.value === 0)
const isLast = toRef(() => position.value === sequence.value.length - 1)
function goToPrev () {
if (isFirst.value) {
router.push('/builder')
return
}
router.push(`/builder/${sequence.value[position.value - 1].slug}`)
}
function goToNext () {
if (isLast.value) {
router.push('/builder/components')
return
}
router.push(`/builder/${sequence.value[position.value + 1].slug}`)
}
function onSkip () {
goToNext()
}
function onSave () {
emit('save')
goToNext()
}
</script>
<template>
<div v-if="meta" class="max-w-4xl mx-auto px-6 py-12">
<p class="text-xs text-on-surface-variant uppercase tracking-wide mb-1">
Configuring {{ meta.title }} ({{ position + 1 }} of {{ sequence.length }})
</p>
<h2 class="text-2xl font-bold mb-2">{{ meta.title }}</h2>
<slot name="description">
<p class="text-on-surface-variant mb-8">
{{ meta.title }} configuration
</p>
</slot>
<div class="mb-8">
<slot />
</div>
<div class="flex items-center justify-between border-t pt-6">
<button
class="text-sm text-on-surface-variant hover:text-on-surface inline-flex items-center gap-1"
@click="goToPrev"
>
<svg class="w-4 h-4" viewBox="0 0 24 24"><path :d="mdiArrowLeft" fill="currentColor" /></svg>
{{ isFirst ? 'Back to plugin selection' : 'Prev' }}
</button>
<div class="flex items-center gap-3">
<button
class="text-sm text-on-surface-variant hover:text-on-surface inline-flex items-center gap-1"
@click="onSkip"
>
<svg class="w-4 h-4" viewBox="0 0 24 24"><path :d="mdiClose" fill="currentColor" /></svg>
Skip (use defaults)
</button>
<button
class="px-6 py-2.5 bg-primary text-on-primary rounded-lg font-semibold text-sm hover:opacity-90 transition-opacity inline-flex items-center gap-2"
@click="onSave"
>
{{ isLast ? 'Save & Continue to Components' : 'Save & Next' }}
<svg class="w-4 h-4" viewBox="0 0 24 24"><path :d="mdiArrowRight" fill="currentColor" /></svg>
</button>
</div>
</div>
</div>
</template>