feat(ui): unify loading empty error states
This commit is contained in:
@@ -101,6 +101,27 @@ for (const className of requiredAdminProjectDetailClasses) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const stateComponents = [
|
||||||
|
"src/components/StateLoading.vue",
|
||||||
|
"src/components/StateEmpty.vue",
|
||||||
|
"src/components/StateError.vue"
|
||||||
|
];
|
||||||
|
|
||||||
|
const requiredStateClasses = [
|
||||||
|
"ctms-state",
|
||||||
|
"ctms-state-title",
|
||||||
|
"ctms-state-desc"
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const file of stateComponents) {
|
||||||
|
const content = readFileSync(file, "utf8");
|
||||||
|
for (const className of requiredStateClasses) {
|
||||||
|
if (!content.includes(className)) {
|
||||||
|
missing.push(`${file}:${className}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (missing.length) {
|
if (missing.length) {
|
||||||
console.error("UI contract check failed. Missing:", missing.join(", "));
|
console.error("UI contract check failed. Missing:", missing.join(", "));
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="state state-empty">
|
<section class="ctms-state state state-empty">
|
||||||
<el-icon class="state-icon"><Document /></el-icon>
|
<el-icon class="ctms-state-icon state-icon"><Document /></el-icon>
|
||||||
<div class="state-title">{{ title }}</div>
|
<h3 class="ctms-state-title state-title">{{ title }}</h3>
|
||||||
<div v-if="description" class="state-desc">{{ description }}</div>
|
<p v-if="description" class="ctms-state-desc state-desc">{{ description }}</p>
|
||||||
<div v-if="$slots.action" class="state-action">
|
<div v-if="$slots.action" class="ctms-state-action state-action">
|
||||||
<slot name="action" />
|
<slot name="action" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -26,35 +26,15 @@ withDefaults(
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.state {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 40px 12px;
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-icon {
|
.state-icon {
|
||||||
font-size: 36px;
|
|
||||||
color: var(--ctms-text-disabled);
|
color: var(--ctms-text-disabled);
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.state-title {
|
.state-title {
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--ctms-text-regular);
|
color: var(--ctms-text-regular);
|
||||||
}
|
}
|
||||||
|
|
||||||
.state-desc {
|
.state-desc {
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ctms-text-secondary);
|
color: var(--ctms-text-secondary);
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-action {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="state state-error">
|
<section class="ctms-state state state-error">
|
||||||
<el-icon class="state-icon"><CircleClose /></el-icon>
|
<el-icon class="ctms-state-icon state-icon"><CircleClose /></el-icon>
|
||||||
<div class="state-title">{{ title }}</div>
|
<h3 class="ctms-state-title state-title">{{ title }}</h3>
|
||||||
<div v-if="description" class="state-desc">{{ description }}</div>
|
<p v-if="description" class="ctms-state-desc state-desc">{{ description }}</p>
|
||||||
<div v-if="$slots.action" class="state-action">
|
<div v-if="$slots.action" class="ctms-state-action state-action">
|
||||||
<slot name="action" />
|
<slot name="action" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -26,35 +26,15 @@ withDefaults(
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.state {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 40px 12px;
|
|
||||||
color: var(--ctms-text-secondary);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-icon {
|
.state-icon {
|
||||||
font-size: 36px;
|
|
||||||
color: var(--ctms-danger);
|
color: var(--ctms-danger);
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.state-title {
|
.state-title {
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--ctms-text-main);
|
color: var(--ctms-text-main);
|
||||||
}
|
}
|
||||||
|
|
||||||
.state-desc {
|
.state-desc {
|
||||||
font-size: 12px;
|
|
||||||
color: var(--ctms-text-secondary);
|
color: var(--ctms-text-secondary);
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.state-action {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="state state-loading">
|
<section class="ctms-state ctms-state-loading state state-loading">
|
||||||
<el-skeleton :rows="rows" animated />
|
<h3 class="ctms-state-title state-title">{{ title }}</h3>
|
||||||
</div>
|
<p class="ctms-state-desc state-desc">{{ description }}</p>
|
||||||
|
<el-skeleton :rows="rows" animated class="ctms-state-skeleton" />
|
||||||
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { TEXT } from "../locales";
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
rows?: number;
|
rows?: number;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
rows: 4,
|
rows: 4,
|
||||||
|
title: TEXT.common.loading,
|
||||||
|
description: TEXT.common.messages.loadSuccess,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.state-loading {
|
|
||||||
padding: 24px;
|
|
||||||
border: 1px solid var(--ctms-border-color);
|
|
||||||
border-radius: var(--ctms-radius);
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -437,6 +437,45 @@ body {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Unified loading / empty / error states */
|
||||||
|
.ctms-state {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 28px 16px;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid var(--ctms-border-color);
|
||||||
|
border-radius: var(--ctms-radius);
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctms-state-icon {
|
||||||
|
font-size: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctms-state-title {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctms-state-desc {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 13px;
|
||||||
|
color: var(--ctms-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctms-state-action {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctms-state-loading .ctms-state-skeleton {
|
||||||
|
width: min(560px, 100%);
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tool classes */
|
/* Tool classes */
|
||||||
.text-main {
|
.text-main {
|
||||||
color: var(--ctms-text-main);
|
color: var(--ctms-text-main);
|
||||||
|
|||||||
Reference in New Issue
Block a user