BasicTitle.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <span :class="getClass">
  3. <slot></slot>
  4. <BasicHelp :class="`${prefixCls}-help`" v-if="helpMessage" :text="helpMessage" />
  5. </span>
  6. </template>
  7. <script lang="ts" setup>
  8. import type { PropType } from 'vue';
  9. import { useSlots, computed } from 'vue';
  10. import BasicHelp from './BasicHelp.vue';
  11. import { useDesign } from '/@/hooks/web/useDesign';
  12. const props = defineProps({
  13. /**
  14. * Help text list or string
  15. * @default: ''
  16. */
  17. helpMessage: {
  18. type: [String, Array] as PropType<string | string[]>,
  19. default: '',
  20. },
  21. /**
  22. * Whether the color block on the left side of the title
  23. * @default: false
  24. */
  25. span: { type: Boolean },
  26. /**
  27. * Whether to default the text, that is, not bold
  28. * @default: false
  29. */
  30. normal: { type: Boolean },
  31. });
  32. const { prefixCls } = useDesign('basic-title');
  33. const slots = useSlots();
  34. const getClass = computed(() => [prefixCls, { [`${prefixCls}-show-span`]: props.span && slots.default }, { [`${prefixCls}-normal`]: props.normal }]);
  35. </script>
  36. <style lang="less" scoped>
  37. @prefix-cls: ~'@{namespace}-basic-title';
  38. .@{prefix-cls} {
  39. position: relative;
  40. display: flex;
  41. padding-left: 7px;
  42. font-size: 16px;
  43. font-weight: 500;
  44. line-height: 24px;
  45. color: @text-color-base;
  46. cursor: pointer;
  47. user-select: none;
  48. &-normal {
  49. font-size: 14px;
  50. font-weight: 500;
  51. }
  52. &-show-span::before {
  53. position: absolute;
  54. top: 4px;
  55. left: 0;
  56. width: 3px;
  57. height: 16px;
  58. margin-right: 4px;
  59. background-color: @primary-color;
  60. content: '';
  61. }
  62. &-help {
  63. margin-left: 10px;
  64. }
  65. }
  66. </style>