-
Notifications
You must be signed in to change notification settings - Fork 515
Expand file tree
/
Copy pathMachine.vue
More file actions
71 lines (64 loc) · 1.61 KB
/
Machine.vue
File metadata and controls
71 lines (64 loc) · 1.61 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
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<template>
<div v-if="isActive">
<div class="mb-6 text-center text-gray-600">
<span>
{{
$t("i18n.components.machine._global.machine", {
current_step: context.currentStep,
total_steps: context.totalSteps,
})
}}
</span>
<div class="mt-2 h-2 w-full overflow-hidden rounded-full bg-layer-1">
<div
class="h-full rounded-full bg-cta-orange transition-all duration-300"
:style="{
width: `${(context.currentStep / context.totalSteps) * 100}%`,
}"
/>
</div>
</div>
<Loading
v-if="loading && !currentScreen"
:loading="(loading && currentScreen)!!"
/>
<component :is="currentScreen" v-else-if="currentScreen" />
</div>
</template>
<script setup lang="ts">
const props = defineProps<{
machineType: MachineType;
options?: UseFlowScreensOptions;
}>();
const emit = defineEmits(["close", "submit"]);
const { isActive, currentScreen, context, loading, start, close, next, prev } =
useFlowScreens(props.machineType, props.options);
// Provide both the actions and the reactive context.
provide("flow", {
// Actions
start,
close: (discard?: boolean) => {
close(discard);
emit("close");
},
next,
prev,
// Reactive state
context,
});
defineExpose({ start, close });
</script>
<style scoped>
/* Add some styling for the progress bar. */
.progress-bar-container {
margin-bottom: 1.5rem;
text-align: center;
color: #555;
}
progress {
width: 100%;
height: 8px;
margin-top: 0.5rem;
}
</style>