<script setup lang="ts">
interface Props {
  title?: string
  hasCardBackground?: boolean
  hasBodyBackground?: boolean
}
withDefaults(defineProps<Props>(), { hasBodyBackground: true })
</script>

<template>
  <div class="app-card" :class="{ 'has-background': hasCardBackground }">
    <div class="app-card-hd">
      <slot name="header">
        <h2 class="app-card-hd__title" v-if="title">{{ title }}</h2>
        <div class="app-card-hd-aside">
          <slot name="header-aside"></slot>
        </div>
      </slot>
    </div>
    <div class="app-card-bd" :class="{ 'has-background': hasBodyBackground }">
      <slot></slot>
    </div>
  </div>
</template>

<style lang="scss">
.app-card {
  &.has-background {
    background: #fff;
    box-shadow: 0 1px 6px 0 rgb(228 232 235 / 20%);
    border-radius: 6px;
    padding: 20px;
  }
}
.app-card + .app-card {
  margin-top: 20px;
}
.app-card-hd {
  display: flex;
}
.app-card-hd__title {
  flex: 1;
  margin-bottom: 20px;
  font-size: 20px;
  font-family: Source Han Sans CN;
  font-weight: bold;
  line-height: 1;
  color: #333333;
}
.app-card-bd {
  &.has-background {
    padding: 20px;
    background-color: #fff;
    border-radius: 12px;
  }
}
</style>
