layout-header.vue 1.79 KB
<template>
  <div class="layout-header" :class="{[`theme-${theme}`]: theme}">
    <div class="back flex">
      <slot name="back">
        <i class="iconfont icon-left"></i>
      </slot>
    </div>
    <div class="title flex">
      <slot>
        {{title}}
      </slot>
    </div>
    <div class="opts flex">
      <slot name="opts">
      </slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'LayoutHeader',
  props: {
    title: String,
    theme: String,
    fixed: Boolean,
    transparentSeek: Number
  },
  watch: {
    transparentSeek(value) {
      console.log(value)
      this.animeEl && this.animeEl.seek(this.animeEl.duration * value);
    }
  },
  mounted() {
    if (this.transparentSeek >= 0) {
      import('animejs').then(({default: anime}) => {
        this.animeEl = anime({
          targets: this.$el,
          backgroundColor: '#222',
          easing: 'easeInOutQuad',
          autoplay: false
        });
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.layout-header {
  width: 100%;
  height: 44PX;
  background-color: #444;
  color: #fff;
  overflow: hidden;
  display: flex;

  &.theme-white {
    background-color: #fff;
    color: #222;
  }

  &.theme-transparent {
    background-color: initial;
    color: #fff;
  }

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

  .iconfont {
    height: 100%;
    font-size: 20PX;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 10PX;
    padding-right: 10PX;
  }

  .back {
    width: 150px;
    padding-left: 5PX;
  }

  .title {
    flex: 1;
    justify-content: center;
    font-size: 18PX;
    letter-spacing: 0.09PX;
  }

  .opts {
    width: 150px;
    justify-content: flex-end;
    padding-right: 5PX;

    .iconfont {
      font-size: 23PX;
    }
  }
}
</style>