<script setup lang="ts">
  import useStatePanel from '../hooks/useStatePanel';
  import { useRuleProcessStore } from '../store';
  import IconFontSymbol from '/@/components/IconFontSymbol/Index.vue';

  const { showPanel, nodeIcon, nodeName, componentName } = useStatePanel();
  const store = useRuleProcessStore();
  const { setInfoId } = store;
  function closeFn() {
    setInfoId('');
  }
</script>

<template>
  <div class="fixed-panel" v-if="showPanel">
    <div class="fixed-head">
      <div class="left">
        <IconFontSymbol :icon="nodeIcon" fontSize="18" /><span class="fixed-head-title">{{
          nodeName
        }}</span>
      </div>
      <div class="right" @click.stop="closeFn"
        ><IconFontSymbol icon="rule-icon-guanbi" fontSize="12"
      /></div>
    </div>
    <div class="content">
      <component :is="componentName" />
    </div>
  </div>
</template>
<style lang="less" scoped>
  .fixed-panel {
    position: absolute;
    bottom: -300px;
    width: 520px;
    height: 288px;
    z-index: 100;
    border-radius: 8px;
    background-color: #fff;

    .fixed-head {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 0 10px;
      height: 30px;
      background: #cde4fc;
      border-radius: 8px 8px 0 0;

      .left {
        display: flex;
        align-items: center;
      }

      .right {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 30px;
        height: 30px;
        cursor: pointer;
      }
    }
  }

  :deep(.fixed-head-title) {
    font-weight: 400;
    font-size: 12px;
    color: #333;
    margin-left: 8px;
  }

  .content {
    background-color: #fff;
  }
</style>
