<template>
  <div class="operation-area-component">
    <div class="phone-component">
      <div class="phone-body"></div>
      <div class="phone-main">
        <component
          :is="item.keyCode"
          v-for="(item, index) in diyComponents"
          :key="index"
          class="component-item"
          :config="item"
        />
      </div>
      <div v-if="footerComponent" class="phone-footer">
        <Footer />
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import Carousel from './Components/Carousel/index'
import Video from './Components/Video/index'
import Search from './Components/Search/index'
import SingleItem from './Components/SingleItem/index'
import CategoryNavigation from './Components/CategoryNavigation/index'
import Commodity from './Components/Commodity/index'
import Editor from './Components/Editor/index'
import GraphicNavigation from './Components/GraphicNavigation/index'
import ImageBox from './Components/ImageBox/index'
import GroupList from './Components/GroupList/index'
import Footer from './Components/Footer/index'
export default {
  name: 'PreviewContent',
  components: {
    Search,
    Carousel,
    Video,
    SingleItem,
    CategoryNavigation,
    Commodity,
    Editor,
    GraphicNavigation,
    ImageBox,
    GroupList,
    Footer
  },
  computed: {
    ...mapState('creationCamp', ['diyComponents', 'footerComponent'])
  }
}
</script>

<style lang="less" scoped>
.phone-component {
  display: flex;
  flex-direction: column;
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  bottom: 10px;
  width: 377px;
  height: auto;
  max-height: 667px;
  margin: auto;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  padding: 10px 0 0;
  overflow: hidden;
  float: none;

  .phone-body {
    background: url(./../../../../assets/CreationCamp/wx-top2.png) 0 0 no-repeat;
    background-size: calc(100% - 30px) auto;
    background-position: center;
    padding: 0 50px;
    font-size: 15px;
    color: #000000;
    text-align: center;
    line-height: 85px;
    height: 68px;
    cursor: default;
    overflow: hidden;
    display: block;
    white-space: nowrap;
    text-overflow: ellipsis;
    border-width: 1px 1px 0px 1px;
  }

  .phone-main {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    &::-webkit-scrollbar-track-piece {
      background-color: #fff;
    }
    &::-webkit-scrollbar {
      width: 3px;
      height: 3px;
    }

    &::-webkit-scrollbar-thumb {
      background-color: #c2c2c2;
      background-clip: padding-box;
      min-height: 28px;
      border-radius: 2px;
    }

    &::-webkit-scrollbar-thumb:hover {
      background-color: #a0a0a0;
    }
    // border: 1px solid #ddd;
    .component-item {
      padding: 15px;
    }
  }
}
</style>
