<template>
  <div
    class="ui-panel"
    :class="[{'is-border': border}, 'ui-panel--' + size]"
  >
    <div class="ui-panel__head">
      <strong class="ui-panel__title" v-if="title">{{title}}</strong>
      <div class="ui-panel__addon" v-if="$slots.tools || $slots.link">
        <div
          v-if="$slots.tools"
          class="ui-panel__tools"
        >
          <slot name="tools"></slot>
        </div>
        <div
          v-if="$slots.link"
          class="ui-panel__link"
        >
          <slot name="link"></slot>
        </div>
      </div>
    </div>
    <div class="ui-panel__body">
      <slot></slot>
    </div>
  </div>
</template>
<script>
export default {
  name: 'UiPanel',
  props: {
    title: {
      type: String
    },
    border: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: 'medium',
      validator(value) {
        return ['medium', 'small'].includes(value)
      }
    }
  }
}
</script>
<style lang="less">
.ui-panel{
  &.is-border {
    padding: 16px 24px 24px;
    box-shadow: 0px 0px 5px 1px rgba(204, 204, 204, 0.5);
    border-radius: 4px;
  }
}
.ui-panel__head {
  height: 32px;
  line-height: 32px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
}
.ui-panel__addon {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.ui-panel__link{
  margin-right: -10px;
}
.ui-panel--medium {
  .ui-panel__title{
    font-size: 18px;
  }
}
.ui-panel--small {
  .ui-panel__title{
    font-size: 14px;
  }
}
</style>
