hippofish/packages/client/src/components/MkInfo.vue

93 lines
1.5 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 22:17: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 22:17:42 +02:00
<button
v-if="closeable"
v-tooltip="i18n.ts.close"
2023-05-31 22:28:07 +02:00
class="_buttonIcon close"
:aria-label="i18n.t('close')"
2023-09-02 01:27:33 +02:00
@click.stop="close"
2023-05-29 22:17:42 +02:00
>
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";
import { i18n } from "@/i18n";
2023-05-29 20:51:02 +02:00
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);
2023-05-31 22:28:07 +02:00
display: flex;
align-items: center;
2023-06-01 20:55:13 +02:00
gap: 0.4em;
&.warn {
background: var(--infoWarnBg);
color: var(--infoWarnFg);
}
2023-05-29 15:11:42 +02:00
&.card {
2023-06-01 01:35:02 +02:00
display: block;
2023-05-29 15:11:42 +02:00
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>