md-header.vue 2.4 KB
Newer Older
璃白.'s avatar
璃白. 已提交
1
<template>
璃白.'s avatar
璃白. 已提交
2
  <div :class="['md_header', { active: isFocus }]">
璃白.'s avatar
璃白. 已提交
3 4 5
    <div class="header_tabs">
      <div
        :class="['tab_item', { active: !showPreview }]"
璃白.'s avatar
璃白. 已提交
6
        @click="setShowPreview(false)"
璃白.'s avatar
璃白. 已提交
7 8 9 10 11
      >
        编辑
      </div>
      <div
        :class="['tab_item', { active: showPreview }]"
璃白.'s avatar
璃白. 已提交
12
        @click="setShowPreview(true)"
璃白.'s avatar
璃白. 已提交
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
      >
        预览
      </div>
    </div>
    <div class="header_tools" v-if="!showPreview">
      <tool-button
        :info="item"
        v-for="(item, index) in toolButtonList"
        :key="index"
      />
    </div>
  </div>
</template>
<script>
import toolButton from "./tool-button";
璃白.'s avatar
璃白. 已提交
28
import { mapState, mapMutations } from "vuex";
璃白.'s avatar
璃白. 已提交
29 30
export default {
  components: { toolButton },
璃白.'s avatar
璃白. 已提交
31 32
  computed: {
    ...mapState(["toolButtonList", "isFocus", "showPreview"])
璃白.'s avatar
璃白. 已提交
33 34
  },
  methods: {
璃白.'s avatar
璃白. 已提交
35
    ...mapMutations(["setShowPreview"])
璃白.'s avatar
璃白. 已提交
36 37 38 39 40 41 42 43 44
  }
};
</script>
<style lang="less" scoped>
.md_header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 32px;
璃白.'s avatar
璃白. 已提交
45
  transition: border-bottom 0.3s;
璃白.'s avatar
璃白. 已提交
46
  border-bottom: 1px solid var(--md-editor-border-color);
璃白.'s avatar
璃白. 已提交
47
  &.active {
璃白.'s avatar
璃白. 已提交
48
    border-bottom: 1px solid var(--md-editor-border-color-active);
璃白.'s avatar
璃白. 已提交
49
  }
璃白.'s avatar
璃白. 已提交
50 51 52 53 54 55 56
  .header_tabs {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding-bottom: 10px;
    box-sizing: border-box;
    .tab_item {
璃白.'s avatar
璃白. 已提交
57
      color: var(--md-editor-text-color);
璃白.'s avatar
璃白. 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
      cursor: pointer;
      position: relative;
      padding: 0 6px;
      box-sizing: border-box;
      &::after {
        display: block;
        content: "";
        position: absolute;
        bottom: -12px;
        width: 0;
        height: 3px;
        left: 50%;
        transform: translateX(-50%);
        background: transparent;
        transition: all 0.3s;
      }

      &:hover {
璃白.'s avatar
璃白. 已提交
76
        color: var(--md-editor-text-color-active);
璃白.'s avatar
璃白. 已提交
77 78
        &::after {
          width: 100%;
璃白.'s avatar
璃白. 已提交
79
          background: var(--md-editor-border-color);
璃白.'s avatar
璃白. 已提交
80 81 82
        }
      }
      &.active {
璃白.'s avatar
璃白. 已提交
83
        color: var(--md-editor-text-color-active);
璃白.'s avatar
璃白. 已提交
84 85 86
        font-weight: 700;
        &::after {
          width: 100%;
璃白.'s avatar
璃白. 已提交
87
          background: var(--md-editor-border-color-active);
璃白.'s avatar
璃白. 已提交
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
        }
      }
      & + .tab_item {
        margin-left: 10px;
      }
    }
  }
  .header_tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    box-sizing: border-box;
    /deep/.tool_button {
      margin: 0 8px;
    }
  }
}
</style>