astrbot_plugin_imagestudio/frontend/standalone-web/src/components/StateCard.vue

99 行
1.6 KiB
Vue

<script setup lang="ts">
type StateTone = "good" | "bad" | "warn" | "idle"
const props = withDefaults(
defineProps<{
tone: StateTone
title: string
detail: string
actionLabel?: string
busy?: boolean
}>(),
{
actionLabel: "",
busy: false,
},
)
const emit = defineEmits<{
action: []
}>()
function handleAction() {
if (props.busy) return
emit("action")
}
</script>
<template>
<section
:class="['state-card', tone]"
:role="tone === 'bad' ? 'alert' : 'status'"
aria-live="polite"
:aria-busy="busy"
>
<strong>{{ title }}</strong>
<span>{{ detail }}</span>
<button
v-if="actionLabel"
type="button"
:aria-label="actionLabel"
:disabled="busy"
@click="handleAction"
>
{{ actionLabel }}
</button>
</section>
</template>
<style scoped>
.state-card {
display: grid;
gap: 8px;
margin-top: 14px;
border: 1px solid var(--border);
border-radius: 8px;
padding: 14px;
background: var(--panel-muted);
box-shadow: none;
}
.state-card.good {
border-color: var(--accent-strong);
}
.state-card.bad {
border-color: var(--danger-strong);
}
.state-card.warn {
border-color: var(--warn-strong);
}
.state-card.idle {
border-color: var(--border);
}
.state-card span {
color: var(--text-soft);
line-height: 1.5;
}
.state-card button {
justify-self: start;
min-height: 34px;
border: 1px solid var(--border);
border-radius: 8px;
padding: 0 12px;
color: var(--text);
background: var(--panel);
font: inherit;
cursor: pointer;
}
.state-card button:disabled {
cursor: not-allowed;
opacity: 0.56;
}
</style>