<template>
  <div class="com-panel" :class="{ 'no-title': !hasTitle, line: showLine }">
    <div v-if="hasTitle" class="panel-header">
      <div class="panel-title">
        <i v-if="hasIcon" class="panel-icon" :class="icon"></i>
        {{ title }}
      </div>
      <div class="panel-tools">
        <slot name="tools"></slot>
      </div>
    </div>
    <div class="panel-body">
      <slot></slot>
    </div>
  </div>
</template>

<script>
// 副标题可嵌入html的panel
export default {
  name: "toolbar-panel",
  componentName: "toolbar-panel",
  props: {
    // 标题
    title: String,
    // 图标
    icon: String,
    showLine: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    hasTitle() {
      if (this.title) return true;
      return false;
    },
    hasIcon() {
      if (this.icon) return true;
      return false;
    },
  },
};
</script>

<style lang="less"></style>
