Vben
2021-03-31 8a14069e71d5393cfa5b758f46a1c5c001fa172b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<template>
  <span :class="getClass">
    <slot></slot>
    <BasicHelp :class="`${prefixCls}__help`" v-if="helpMessage" :text="helpMessage" />
  </span>
</template>
<script lang="ts">
  import type { PropType } from 'vue';
 
  import { defineComponent, computed } from 'vue';
  import BasicHelp from './BasicHelp.vue';
 
  import { useDesign } from '/@/hooks/web/useDesign';
 
  import { propTypes } from '/@/utils/propTypes';
 
  export default defineComponent({
    name: 'BasicTitle',
    components: { BasicHelp },
    props: {
      helpMessage: {
        type: [String, Array] as PropType<string | string[]>,
        default: '',
      },
      span: propTypes.bool,
      normal: propTypes.bool.def(false),
    },
    setup(props, { slots }) {
      const { prefixCls } = useDesign('basic-title');
 
      const getClass = computed(() => [
        prefixCls,
        { [`${prefixCls}-show-span`]: props.span && slots.default },
        { [`${prefixCls}-normal`]: props.normal },
      ]);
      return { prefixCls, getClass };
    },
  });
</script>
<style lang="less" scoped>
  @prefix-cls: ~'@{namespace}-basic-title';
 
  .@{prefix-cls} {
    position: relative;
    display: flex;
    padding-left: 7px;
    font-size: 16px;
    font-weight: 500;
    line-height: 24px;
    color: @text-color-base;
    cursor: pointer;
    user-select: none;
 
    &-normal {
      font-size: 14px;
      font-weight: 500;
    }
 
    &-show-span::before {
      position: absolute;
      top: 4px;
      left: 0;
      width: 3px;
      height: 16px;
      margin-right: 4px;
      background: @primary-color;
      content: '';
    }
 
    &__help {
      margin-left: 10px;
    }
  }
</style>