TypePicker.vue 3.5 KB
Newer Older
V
vben 已提交
1 2 3 4 5 6 7 8
<template>
  <div :class="prefixCls">
    <template v-for="item in menuTypeList || []" :key="item.title">
      <Tooltip :title="item.title" placement="bottom">
        <div
          @click="handler(item)"
          :class="[
            `${prefixCls}__item`,
V
vben 已提交
9
            `${prefixCls}__item--${item.type}`,
V
vben 已提交
10 11 12 13 14
            {
              [`${prefixCls}__item--active`]: def === item.type,
            },
          ]"
        >
V
vben 已提交
15
          <div class="mix-sidebar"></div>
V
vben 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
        </div>
      </Tooltip>
    </template>
  </div>
</template>
<script lang="ts">
  import { defineComponent, PropType } from 'vue';

  import { Tooltip } from 'ant-design-vue';
  import { useDesign } from '/@/hooks/web/useDesign';

  import { menuTypeList } from '../enum';
  export default defineComponent({
    name: 'MenuTypePicker',
    components: { Tooltip },
    props: {
      menuTypeList: {
        type: Array as PropType<typeof menuTypeList>,
34
        default: () => [],
V
vben 已提交
35 36
      },
      handler: {
V
vben 已提交
37
        type: Function,
V
Vben 已提交
38
        default: () => ({}),
V
vben 已提交
39 40 41
      },
      def: {
        type: String,
V
vben 已提交
42
        default: '',
V
vben 已提交
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
      },
    },
    setup() {
      const { prefixCls } = useDesign('setting-menu-type-picker');

      return {
        prefixCls,
      };
    },
  });
</script>
<style lang="less" scoped>
  @prefix-cls: ~'@{namespace}-setting-menu-type-picker';

  .@{prefix-cls} {
    display: flex;

    &__item {
      position: relative;
V
vben 已提交
62 63 64 65 66
      width: 56px;
      height: 48px;
      margin-right: 16px;
      overflow: hidden;
      border-radius: 4px;
V
vben 已提交
67
      background-color: #f0f2f5;
V
vben 已提交
68
      box-shadow: 0 1px 2.5px 0 rgb(0 0 0 / 18%);
V
vben 已提交
69
      cursor: pointer;
V
vben 已提交
70

V
vben 已提交
71
      &::before,
V
vben 已提交
72 73
      &::after {
        content: '';
V
vben 已提交
74
        position: absolute;
V
vben 已提交
75 76
      }

V
Vben 已提交
77 78
      &--sidebar,
      &--light {
V
vben 已提交
79
        &::before {
V
vben 已提交
80
          z-index: 1;
V
vben 已提交
81 82 83 84 85
          top: 0;
          left: 0;
          width: 33%;
          height: 100%;
          border-radius: 4px 0 0 4px;
V
vben 已提交
86
          background-color: #273352;
V
vben 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
        }

        &::after {
          top: 0;
          left: 0;
          width: 100%;
          height: 25%;
          background-color: #fff;
        }
      }

      &--mix {
        &::before {
          top: 0;
          left: 0;
          width: 33%;
          height: 100%;
          border-radius: 4px 0 0 4px;
V
vben 已提交
105
          background-color: #fff;
V
vben 已提交
106 107 108
        }

        &::after {
V
vben 已提交
109
          z-index: 1;
V
vben 已提交
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
          top: 0;
          left: 0;
          width: 100%;
          height: 25%;
          background-color: #273352;
        }
      }

      &--top-menu {
        &::after {
          top: 0;
          left: 0;
          width: 100%;
          height: 25%;
          background-color: #273352;
        }
      }

V
Vben 已提交
128 129 130 131
      &--dark {
        background-color: #273352;
      }

V
vben 已提交
132 133
      &--mix-sidebar {
        &::before {
V
vben 已提交
134
          z-index: 1;
V
vben 已提交
135 136 137 138 139
          top: 0;
          left: 0;
          width: 25%;
          height: 100%;
          border-radius: 4px 0 0 4px;
V
vben 已提交
140
          background-color: #273352;
V
vben 已提交
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
        }

        &::after {
          top: 0;
          left: 0;
          width: 100%;
          height: 25%;
          background-color: #fff;
        }

        .mix-sidebar {
          position: absolute;
          left: 25%;
          width: 15%;
          height: 100%;
          background-color: #fff;
        }
      }

V
vben 已提交
160 161
      &:hover,
      &--active {
V
vben 已提交
162 163 164 165
        padding: 12px;
        border: 2px solid @primary-color;

        &::before,
V
vben 已提交
166
        &::after {
V
vben 已提交
167
          border-radius: 0;
V
vben 已提交
168 169 170 171 172 173 174 175 176 177 178
        }
      }
    }

    img {
      width: 100%;
      height: 100%;
      cursor: pointer;
    }
  }
</style>