SectionTitle.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="section-title" :class="[`align-${align}`]" :style="{ gap: gap }">
  3. <text
  4. class="line"
  5. :style="{
  6. backgroundColor: lineColor,
  7. width: lineWidth,
  8. height: lineHeight,
  9. }"
  10. ></text>
  11. <view
  12. class="title-text"
  13. :style="{
  14. fontSize: fontSize,
  15. color: color,
  16. fontWeight: bold ? '700' : '500',
  17. }"
  18. >
  19. <slot>
  20. <trans :_t="title" v-if="title" />
  21. </slot>
  22. </view>
  23. </view>
  24. </template>
  25. <script setup>
  26. const props = defineProps({
  27. title: {
  28. type: String,
  29. default: "",
  30. },
  31. align: {
  32. type: String,
  33. default: "left",
  34. },
  35. color: {
  36. type: String,
  37. default: "var(--text)",
  38. },
  39. fontSize: {
  40. type: String,
  41. default: "28rpx",
  42. },
  43. bold: {
  44. type: Boolean,
  45. default: true,
  46. },
  47. gap: {
  48. type: String,
  49. default: "12rpx",
  50. },
  51. lineColor: {
  52. type: String,
  53. default: "var(--black)",
  54. },
  55. lineWidth: {
  56. type: String,
  57. default: "6rpx",
  58. },
  59. lineHeight: {
  60. type: String,
  61. default: "28rpx",
  62. },
  63. });
  64. </script>
  65. <style lang="less" scoped>
  66. .section-title {
  67. display: flex;
  68. align-items: center;
  69. margin: 40rpx 0 32rpx;
  70. &.align-left {
  71. justify-content: flex-start;
  72. }
  73. &.align-center {
  74. justify-content: center;
  75. }
  76. .line {
  77. display: inline-block;
  78. border-radius: 999rpx;
  79. }
  80. .title-text {
  81. display: inline-flex;
  82. align-items: center;
  83. }
  84. }
  85. </style>