ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<script lang="ts" setup>
import type { PropType } from 'vue';
 
import { computed, useSlots } from 'vue';
 
import BasicHelp from './BasicHelp.vue';
 
const props = defineProps({
  /**
   * Help text list or string
   * @default: ''
   */
  helpMessage: {
    default: '',
    type: [String, Array] as PropType<string | string[]>,
  },
  /**
   * Whether to default the text, that is, not bold
   * @default: false
   */
  normal: { default: false, type: Boolean },
  signed: { default: false, type: Boolean },
  /**
   * Whether the color block on the left side of the title
   * @default: false
   */
  span: { default: false, type: Boolean },
});
 
const slots = useSlots();
const getClass = computed(() => [
  'jnpf-basic-title',
  { [`jnpf-basic-title-show-span`]: props.span && slots.default },
  { [`jnpf-basic-title-normal`]: props.normal },
  { [`jnpf-basic-title-signed`]: props.signed },
]);
</script>
<template>
  <span :class="getClass">
    <slot></slot>
    <BasicHelp v-if="helpMessage" :text="helpMessage" class="jnpf-basic-title-help" />
  </span>
</template>
<style lang="scss" scoped>
.jnpf-basic-title {
  position: relative;
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  color: var(--text-color-base);
  user-select: none;
 
  &-normal {
    font-size: 14px;
    font-weight: 500;
  }
 
  &-signed {
    padding-left: 10px;
 
    &::before {
      position: absolute;
      top: 0;
      left: 0;
      display: block;
      width: 4px;
      height: 100%;
      overflow: hidden;
      content: '';
      background-color: var(--primary-color);
    }
  }
 
  &-show-span {
    padding-left: 7px;
 
    &::before {
      position: absolute;
      top: 4px;
      left: 0;
      width: 3px;
      height: 16px;
      margin-right: 4px;
      content: '';
      background-color: var(--primary-color);
    }
  }
 
  :deep(&-help) {
    display: flex;
    align-items: center;
  }
}
</style>