uni-badge.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <text
  3. v-if="text"
  4. :class="inverted ? 'uni-badge-' + type + ' uni-badge--' + size + ' uni-badge-inverted' : 'uni-badge-' + type + ' uni-badge--' + size"
  5. class="uni-badge"
  6. @click="onClick()"
  7. >
  8. {{ text }}
  9. </text>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'UniBadge',
  14. props: {
  15. type: {
  16. type: String,
  17. default: 'default'
  18. },
  19. inverted: {
  20. type: Boolean,
  21. default: false
  22. },
  23. text: {
  24. type: String,
  25. default: ''
  26. },
  27. size: {
  28. // small.normal
  29. type: String,
  30. default: 'normal'
  31. }
  32. },
  33. methods: {
  34. onClick() {
  35. this.$emit('click');
  36. }
  37. }
  38. };
  39. </script>
  40. <style>
  41. @charset "UTF-8";
  42. .uni-badge {
  43. font-family: 'Helvetica Neue', Helvetica, sans-serif;
  44. box-sizing: border-box;
  45. font-size: 12px;
  46. line-height: 1;
  47. display: inline-block;
  48. padding: 3px 6px;
  49. color: #333;
  50. border-radius: 100px;
  51. background-color: #e5e5e5;
  52. }
  53. .uni-badge.uni-badge-inverted {
  54. padding: 0 5px 0 0;
  55. color: #999;
  56. background-color: transparent;
  57. }
  58. .uni-badge-primary {
  59. color: #fff;
  60. background-color: #007aff;
  61. }
  62. .uni-badge-primary.uni-badge-inverted {
  63. color: #007aff;
  64. background-color: transparent;
  65. }
  66. .uni-badge-success {
  67. color: #fff;
  68. background-color: #4cd964;
  69. }
  70. .uni-badge-success.uni-badge-inverted {
  71. color: #4cd964;
  72. background-color: transparent;
  73. }
  74. .uni-badge-warning {
  75. color: #fff;
  76. background-color: #f0ad4e;
  77. }
  78. .uni-badge-warning.uni-badge-inverted {
  79. color: #f0ad4e;
  80. background-color: transparent;
  81. }
  82. .uni-badge-error {
  83. color: #fff;
  84. background-color: #dd524d;
  85. }
  86. .uni-badge-error.uni-badge-inverted {
  87. color: #dd524d;
  88. background-color: transparent;
  89. }
  90. .uni-badge--small {
  91. transform: scale(0.8);
  92. transform-origin: center center;
  93. }
  94. </style>