advent22/ui/src/components/bulma/Drawer.vue

63 lines
1.2 KiB
Vue
Raw Normal View History

2023-09-09 22:18:16 +00:00
<template>
2023-09-10 03:38:24 +00:00
<div class="card">
<header
class="card-header has-background-grey-lighter is-unselectable"
2023-09-12 15:10:54 +00:00
@click="toggle"
2023-09-10 03:38:24 +00:00
>
<p class="card-header-title">{{ header }}</p>
<button class="card-header-icon">
2023-09-09 23:19:46 +00:00
<span class="icon">
2023-09-09 22:18:16 +00:00
<font-awesome-icon
2023-09-09 23:19:46 +00:00
:icon="'fa-solid fa-angle-' + (is_open ? 'down' : 'right')"
2023-09-09 22:18:16 +00:00
/>
</span>
2023-09-10 03:38:24 +00:00
</button>
</header>
2023-09-12 15:10:54 +00:00
<template v-if="is_open">
<slot v-if="ready" name="default" />
<div v-else class="card-content">
<progress class="progress is-primary" max="100" />
</div>
</template>
2023-09-09 22:18:16 +00:00
</div>
</template>
<script lang="ts">
2023-09-10 00:54:29 +00:00
import { Options, Vue } from "vue-class-component";
2023-09-09 22:18:16 +00:00
2023-09-10 00:54:29 +00:00
@Options({
props: {
header: {
type: String,
required: false,
default: "",
},
2023-09-12 15:10:54 +00:00
ready: Boolean,
2023-09-10 00:54:29 +00:00
},
2023-09-12 15:10:54 +00:00
emits: ["open", "close"],
2023-09-10 00:54:29 +00:00
})
2023-09-09 22:18:16 +00:00
export default class extends Vue {
2023-09-10 00:54:29 +00:00
public header!: string;
2023-09-12 15:10:54 +00:00
public ready!: boolean;
public is_open = false;
public toggle() {
this.is_open = !this.is_open;
this.$emit(this.is_open ? "open" : "close");
}
2023-09-09 22:18:16 +00:00
}
</script>
2023-09-10 14:09:50 +00:00
<style lang="scss" scoped>
div.card {
&:not(:last-child) {
margin-bottom: 1.5rem;
}
> .card-header {
cursor: pointer;
}
2023-09-09 22:18:16 +00:00
}
</style>