fs-tag.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view
  3. class="fs-tag"
  4. :class="[
  5. {
  6. 'fs-tag-round': round,
  7. 'fs-tag-plain': plain,
  8. 'fs-tag-mark': mark,
  9. 'fs-tag-mark-reverse': markReverse,
  10. 'fs-tag-none': closed
  11. },
  12. 'fs-tag-' + size,
  13. 'bg-' + type,
  14. ]"
  15. :style="[
  16. {color:color,backgroundColor:bgColor},
  17. customStyle
  18. ]">
  19. <slot></slot>
  20. <fs-icon
  21. class="fs-tag-close"
  22. size="13px"
  23. type="icon-close1"
  24. v-if="closable"
  25. @click="handleClosed">
  26. </fs-icon>
  27. </view>
  28. </template>
  29. <script setup>
  30. import { ref } from 'vue'
  31. const props = defineProps({
  32. plain: Boolean,
  33. round: Boolean,
  34. mark: Boolean,
  35. markReverse: Boolean,
  36. closable: Boolean,
  37. type: {
  38. type: String,
  39. default: 'primary',
  40. validator(value) {
  41. return ['primary', 'success', 'info', 'warning', 'danger', 'default'].includes(value)
  42. }
  43. },
  44. color: String,
  45. bgColor: String,
  46. size: String,
  47. customStyle: {
  48. type: Object,
  49. default() {
  50. return {}
  51. }
  52. },
  53. })
  54. const closed = ref(false)
  55. const handleClosed = () => {
  56. closed.value = true
  57. }
  58. </script>
  59. <style lang="scss" scoped>
  60. .fs-tag{
  61. display: inline-flex;
  62. height: 38rpx;
  63. line-height: 38rpx;
  64. padding: 0 10rpx;
  65. font-size: 11px;
  66. color: #fff;
  67. vertical-align: middle;
  68. border-radius: 4rpx;
  69. align-items: center;
  70. white-space: nowrap;
  71. &-plain{
  72. background-color: transparent !important;
  73. line-height: 32rpx;
  74. border: 2rpx solid currentColor;
  75. &.bg-default{
  76. color: var(--disabled);
  77. }
  78. &.bg-primary{
  79. color: var(--primary);
  80. }
  81. &.bg-success{
  82. color: var(--success);
  83. }
  84. &.bg-warning{
  85. color: var(--warning);
  86. }
  87. &.bg-info{
  88. color: var(--info);
  89. }
  90. &.bg-danger{
  91. color: var(--danger);
  92. }
  93. }
  94. &-round{
  95. border-radius: 30rpx;
  96. }
  97. &-mark{
  98. border-radius: 0 25rpx 25rpx 0;
  99. }
  100. &-mark-reverse{
  101. border-radius: 25rpx 0 0 25rpx;
  102. }
  103. &-medium{
  104. font-size: 12px;
  105. height: 48rpx;
  106. line-height: 48rpx;
  107. padding: 0 20rpx;
  108. &.plain{
  109. line-height: 48rpx;
  110. }
  111. }
  112. &-large{
  113. font-size: 13px;
  114. height: 58rpx;
  115. line-height: 58rpx;
  116. padding: 0 30rpx;
  117. &.fs-tag-plain{
  118. line-height: 58rpx;
  119. }
  120. &.fs-tag-mark-reverse{
  121. border-radius: 50rpx 0 0 50rpx;
  122. }
  123. }
  124. &-close{
  125. margin-left: 8rpx;
  126. }
  127. &-none{
  128. display: none;
  129. }
  130. }
  131. .bg-default{
  132. background-color: #cfcfcf;
  133. }
  134. </style>