You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
1.8 KiB

  1. <template>
  2. <span v-if="label" class="highlight bottom" :style="{ borderColor: color }">
  3. <span class="highlight__content">{{ content }}</span><span class="highlight__label" :data-label="label" :style="{backgroundColor: color}" @click="open" />
  4. </span>
  5. <span v-else>{{ content }}</span>
  6. </template>
  7. <script>
  8. import { idealColor } from '~/plugins/utils.js'
  9. export default {
  10. props: {
  11. content: {
  12. type: String,
  13. default: '',
  14. required: true
  15. },
  16. label: {
  17. type: String,
  18. default: ''
  19. },
  20. color: {
  21. type: String,
  22. default: '#64FFDA'
  23. }
  24. },
  25. computed: {
  26. textColor() {
  27. return idealColor(this.color)
  28. }
  29. },
  30. methods: {
  31. open() {
  32. alert('hello')
  33. }
  34. }
  35. }
  36. </script>
  37. <style scoped>
  38. .highlight.blue {
  39. background: #edf4fa !important;
  40. }
  41. .highlight.bottom {
  42. display: block;
  43. white-space: normal;
  44. }
  45. .highlight:first-child {
  46. margin-left: 0;
  47. }
  48. .highlight {
  49. border: 2px solid;
  50. color: #232323;
  51. margin: 4px 6px 4px 3px;
  52. vertical-align: middle;
  53. box-shadow: 2px 4px 20px rgba(0,0,0,.1);
  54. position: relative;
  55. cursor: default;
  56. min-width: 26px;
  57. line-height: 22px;
  58. display: flex;
  59. }
  60. .highlight__content {
  61. display: flex;
  62. flex-wrap: wrap;
  63. align-items: center;
  64. padding: 2px 2px 0px 6px;
  65. }
  66. .highlight.bottom .highlight__content:after {
  67. content: " ";
  68. padding-right: 3px;
  69. }
  70. .highlight__label {
  71. line-height: 14px;
  72. padding-top: 1px;
  73. align-items: center;
  74. justify-content: center;
  75. display: flex;
  76. padding: 0 8px;
  77. text-align: center;
  78. -webkit-user-select: none;
  79. -moz-user-select: none;
  80. -ms-user-select: none;
  81. user-select: none;
  82. color: white;
  83. }
  84. .highlight__label::after {
  85. content: attr(data-label);
  86. }
  87. </style>