<template>
  <div class="product-display">
    <div class="product-display-header">
      <span
        :style="{
          color: titleColor,
          background: `linear-gradient(to bottom, ${titleColor} 0%, ${titleColor} 100%) left/3px 14px no-repeat`}"
        >{{ title }}</span
      >
      <span>{{ optionsText }}</span>
    </div>
    <div class="product-display-contents">
      <slot v-if="$slots.default"></slot>
      <div v-else
           class="product-display-default">
        暂无产品
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'md-scrolling-ribbon',
  props: {
    title: {
      type: String,
      default: '标题'
    },
    optionsText: {
      type: String,
      default: '更多操作'
    },
    titleColor: {
      type: String,
      default: '#000'
    }
  }
}
</script>

<style scoped>
.product-display {
  width: 100%;
  background: #fff;
}

.product-display-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 0 15px;
  height: 44px;
}

.product-display-header > span:nth-child(1) {
  font-size: 16px;
  padding-left: 10px;
  position: relative;
}

.product-display-header > span:nth-child(2) {
  font-size: 12px;
  color: #888;
  position: relative;
}

.product-display-header > span:nth-child(2):before {
  content: "";
  position: absolute;
  right: -30%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 10px solid;
  border-color: transparent transparent transparent #888;
  border-width: 5px 0 5px 5px;
}

.product-display-header > span:nth-child(2):after {
  content: "";
  position: absolute;
  right: -25%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 10px solid;
  border-color: transparent transparent transparent #fff;
  border-width: 5px 0 5px 5px;
}

.product-display-contents {
  overflow-x: scroll;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  padding-bottom: 10px;
}

.product-display-contents > div:not(.product-display-default) {
  width: calc((100% - 10px) / 2.5);
}

.product-display-contents
  > div:not(.product-display-default)
  + div:not(.product-display-default) {
  margin-left: 5px;
}

.product-display-default {
  height: 120px;
  line-height: 120px;
  text-align: center;
  font-size: 12px;
  color: #888;
}
</style>
