54 lines
1.7 KiB
Vue
54 lines
1.7 KiB
Vue
<template>
|
|
<div class="aa-card" :class="classes" :style="{ padding: paddingPx }">
|
|
<div v-if="title || $slots.extra" class="aa-card__header">
|
|
<div class="aa-card__title">
|
|
<slot name="title">{{ title }}</slot>
|
|
</div>
|
|
<div v-if="$slots.extra" class="aa-card__extra"><slot name="extra" /></div>
|
|
</div>
|
|
<div class="aa-card__body"><slot /></div>
|
|
<div v-if="$slots.actions" class="aa-card__actions"><slot name="actions" /></div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'AaCard',
|
|
props: {
|
|
title: { type: String, default: '' },
|
|
bordered: { type: Boolean, default: false },
|
|
shadowed: { type: Boolean, default: false },
|
|
padding: { type: [Number, String], default: 16 } // 16 | 24
|
|
},
|
|
computed: {
|
|
classes() {
|
|
return [
|
|
this.bordered ? 'aa-card--bordered' : '',
|
|
this.shadowed ? 'aa-card--shadowed' : ''
|
|
];
|
|
},
|
|
paddingPx() {
|
|
return typeof this.padding === 'number' ? `${this.padding}px` : this.padding;
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<!-- 样式对齐 components.css 与 card.json 契约 -->
|
|
<style>
|
|
.aa-card {
|
|
background: #fff; border-radius: 8px; box-sizing: border-box;
|
|
min-width: 280px; max-width: 360px;
|
|
}
|
|
.aa-card--bordered { border: 1px solid #E8ECF1; }
|
|
.aa-card--shadowed { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
|
|
.aa-card__header {
|
|
display: flex; align-items: center; justify-content: space-between; gap: 8px;
|
|
font-weight: 600; color: #1F2329;
|
|
}
|
|
.aa-card__title { font-size: 16px; }
|
|
.aa-card__extra { color: #2F54EB; font-size: 14px; cursor: pointer; }
|
|
.aa-card__body { color: #262626; font-size: 14px; line-height: 22px; }
|
|
.aa-card__actions { display: flex; justify-content: flex-end; gap: 8px; }
|
|
</style>
|