rudeshark.net/packages/client/src/components/MkInfo.vue

79 lines
1.3 KiB
Vue
Raw Normal View History

<template>
2023-05-29 20:51:02 +02:00
<div v-if="visible" class="info" :class="{ warn, card }">
2023-04-08 02:01:42 +02:00
<i v-if="warn" class="ph-warning ph-bold ph-lg"></i>
2023-05-29 15:11:42 +02:00
<i v-else class="ph-bold ph-lg" :class="icon ? `ph-${icon}` : 'ph-info'"></i>
2023-04-08 02:01:42 +02:00
<slot></slot>
2023-05-29 20:55:00 +02:00
<button v-if="closeable" class="_button close" @click.stop="close">
2023-05-29 20:51:02 +02:00
<i class="ph-x ph-bold ph-lg"></i>
</button>
2023-04-08 02:01:42 +02:00
</div>
</template>
2022-09-06 11:09:17 +02:00
<script lang="ts" setup>
2023-05-29 20:51:02 +02:00
import { ref } from "vue";
const visible = ref(true);
2022-12-07 05:12:44 +01:00
defineProps<{
2023-05-29 15:11:42 +02:00
icon?: string;
2022-09-06 11:09:17 +02:00
warn?: boolean;
2023-05-29 15:11:42 +02:00
card?: boolean;
2023-05-29 20:55:00 +02:00
closeable?: boolean;
2022-09-06 11:09:17 +02:00
}>();
2023-05-29 20:51:02 +02:00
const emit = defineEmits<{
(ev: "close"): void;
}>();
function close() {
visible.value = false;
emit("close");
}
</script>
<style lang="scss" scoped>
2023-05-29 15:11:42 +02:00
.info {
padding: 16px;
font-size: 90%;
background: var(--infoBg);
color: var(--infoFg);
border-radius: var(--radius);
&.warn {
background: var(--infoWarnBg);
color: var(--infoWarnFg);
}
2023-05-29 15:11:42 +02:00
&.card {
background: var(--panel);
color: var(--fg);
padding: 48px;
font-size: 1em;
text-align: center;
> i {
display: block;
font-size: 4em;
margin: 0;
}
> :deep(*) {
margin-inline: auto;
}
> :deep(:not(:last-child)) {
margin-bottom: 20px;
}
> :deep(p) {
max-width: 30em;
}
}
> i {
margin-right: 4px;
}
2023-05-29 20:51:02 +02:00
> .close {
margin-left: auto;
float: right;
}
}
</style>