advent22/ui/src/components/BulmaBreadcrumbs.vue

48 lines
966 B
Vue
Raw Normal View History

2023-01-31 22:31:27 +00:00
<template>
<nav class="breadcrumb has-succeeds-separator">
<ul>
<li
v-for="(step, index) in steps"
:key="`step-${index}`"
2023-02-02 12:50:12 +00:00
:class="modelValue === index ? 'is-active' : ''"
2023-01-31 22:31:27 +00:00
@click="change_step(index)"
>
<a>
<span class="icon is-small">
<font-awesome-icon :icon="step.icon" />
</span>
<span>{{ step.label }}</span>
</a>
</li>
</ul>
</nav>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";
2023-02-01 09:45:01 +00:00
export interface Step {
2023-01-31 22:31:27 +00:00
label: string;
icon: string;
2023-02-01 09:45:01 +00:00
}
2023-01-31 22:31:27 +00:00
@Options({
props: {
steps: Array,
2023-02-02 12:50:12 +00:00
modelValue: Number,
2023-01-31 22:31:27 +00:00
},
2023-02-02 12:50:12 +00:00
emits: ["update:modelValue"],
2023-01-31 22:31:27 +00:00
})
export default class extends Vue {
private steps!: Step[];
2023-02-02 12:50:12 +00:00
private modelValue!: number;
2023-01-31 22:31:27 +00:00
private change_step(next_step: number) {
2023-02-02 12:50:12 +00:00
if (next_step === this.modelValue) {
2023-01-31 22:31:27 +00:00
return;
}
2023-02-02 12:50:12 +00:00
this.$emit("update:modelValue", next_step);
2023-01-31 22:31:27 +00:00
}
}
</script>