<template>
  <div class="co-progress">
    <slot name="start"></slot>
    <div class="co-progress-content">
      <div class="co-progress-runway" :style="{ height: barHeight + 'px' }"></div>
      <div class="co-progress-progress" :style="{ width: value + '%', height: barHeight + 'px' }"></div>
    </div>
    <slot name="end"></slot>
  </div>
</template>

<style>
  @component-namespace co {
    @component progress {
      position: relative;
      display: flex;
      height: 1.5rem;
      line-height: 1.5rem;

      & > * {
        display: flex;
        display: -webkit-box;
      }

      & *[slot="start"] {
        margin-right: 0.25rem;
      }

      & *[slot="end"] {
        margin-left: 0.25rem;
      }

      @descendent content {
        position: relative;
        flex: 1;
      }

      @descendent runway {
        position: absolute;
        transform: translate(0, -50%);
        top: 50%;
        left: 0;
        right: 0;
        background-color: #ebebeb;
        height: 0.15rem;
      }

      @descendent progress {
        position: absolute;
        display: block;
        background-color: #26a2ff;
        top: 50%;
        transform: translate(0, -50%);
        width: 0;
      }
    }
  }
</style>

<script type="text/ecmascript-6">
  export default {
    name: 'co-progress',

    props: {
      value: Number,
      barHeight: {
        type: Number,
        default: 3
      }
    }
  };
</script>
