<template>
  <div class="ModalInfo">
    <div class="list">
      <div v-for="item in option.dataset" :key="item.key">
        <div class="item">
          <div class="title">
            <Dot :dotSize="option.titleStyle.dotSize" :dotColor="option.titleStyle.dotColor" />
            <span class="dot">{{ item.title }}</span>
          </div>
          <div class="content"> {{ item.content }} </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { computed, PropType, toRefs, watch, reactive, ref } from 'vue';
  import { CreateComponentType } from '@/packages/index.d';
  import { icon } from '@/plugins';
  import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore';
  import { useChartDataFetch } from '@/hooks';
  import Dot from './svg/dot.vue';

  const props = defineProps({
    chartConfig: {
      type: Object as PropType<CreateComponentType>,
      required: true,
    },
  });

  const { w, h } = toRefs(props.chartConfig.attr);

  const option = reactive({
    dataset: props.chartConfig.option.dataset,
    dataStyle: props.chartConfig.option.dataStyle,
    titleStyle: props.chartConfig.option.titleStyle,
    contentStyle: props.chartConfig.option.contentStyle,
  });

  watch(
    () => w.value,
    () => {
      option.contentStyle.width = w.value - option.dataStyle.marginLeft - option.titleStyle.width;
    },
    {
      immediate: true,
      deep: true,
    },
  );
  watch(
    () => option.titleStyle.width,
    () => {
      option.contentStyle.width = w.value - option.dataStyle.marginLeft - option.titleStyle.width;
    },
    {
      immediate: true,
      deep: true,
    },
  );
</script>

<style lang="scss" scoped>
  .ModalInfo {
    overflow-y: auto;
    background: v-bind('`${option.dataStyle.backgroud}`');
    width: v-bind('`${w}px`');
    height: v-bind('`${h}px`');
  }
  .ModalInfo::-webkit-scrollbar {
    display: none;
  }
  .ModalInfo {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .list {
    display: inline-block;
    flex-wrap: wrap;
    width: 100%;
    margin-top: v-bind('`${option.dataStyle.marginTop}px`');
    margin-left: v-bind('`${option.dataStyle.marginLeft}px`');
  }
  .item {
    display: inline-flex;
    margin-top: v-bind('`${option.dataStyle.listMarginTop}px`');
    margin-left: v-bind('`${option.dataStyle.listMarginLeft}px`');
  }
  .title {
    display: inline-flex;
    width: v-bind('`${option.titleStyle.width}px`');
    height: v-bind('`${option.titleStyle.height}px`');
    color: v-bind('`${option.titleStyle.fontcolor}`');
    font-size: v-bind('`${option.titleStyle.fontsize}px`');
    text-align: v-bind('`${option.titleStyle.align}`');
  }
  .dot {
    margin-left: v-bind('`${option.titleStyle.dotMarginRight}px`');
  }
  .content {
    width: v-bind('`${option.contentStyle.width}px`');
    // height: v-bind('`${option.contentStyle.height}px`');
    height: 100%;
    color: v-bind('`${option.contentStyle.fontcolor}`');
    font-size: v-bind('`${option.contentStyle.fontsize}px`');
    text-align: v-bind('`${option.contentStyle.align}`');
  }
</style>
