1
0

index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <div
  3. @click="(e) => $emit('click', e)"
  4. class="border-panel"
  5. :style="borderPanelStyle"
  6. >
  7. <div
  8. class="border-panel_header"
  9. :style="{
  10. backgroundImage: `url(${headerImageBgUrl})`,
  11. }"
  12. >
  13. <linear-text
  14. :text="title"
  15. startColor="#95CCFF"
  16. endColor="#fff"
  17. :extClass="{
  18. top: '11px',
  19. left: '35px',
  20. textShadow: '0 1px 1px #0057FF',
  21. }"
  22. />
  23. <div class="ext-header"><slot name="ext-header"></slot></div>
  24. </div>
  25. <div class="border-panel_content">
  26. <slot></slot>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { headerTitleBgs } from "./data";
  32. import LinearText from "../LinearText";
  33. /**
  34. * 边框面板
  35. */
  36. export default {
  37. name: "BorderPanel",
  38. components: {
  39. LinearText,
  40. },
  41. props: {
  42. title: {
  43. type: String,
  44. default: "标题",
  45. },
  46. width: {
  47. type: String,
  48. default: "443px",
  49. },
  50. height: {
  51. type: String,
  52. default: "200px",
  53. },
  54. headerType: {
  55. type: Number,
  56. default: 0,
  57. },
  58. },
  59. computed: {
  60. borderPanelStyle: function () {
  61. return {
  62. "--height": this.$props.height,
  63. "--width": this.$props.width,
  64. "--header-ops": ["-4px", "0px", "0px"][this.$props.headerType],
  65. };
  66. },
  67. headerImageBgUrl: function () {
  68. console.log(this.headerType);
  69. return headerTitleBgs[this.$props.headerType];
  70. },
  71. },
  72. };
  73. </script>
  74. <style scoped lang="less">
  75. .border-panel {
  76. position: relative;
  77. height: var(--height);
  78. width: var(--width);
  79. box-sizing: border-box;
  80. overflow: hidden;
  81. background: linear-gradient(
  82. 360deg,
  83. rgba(0, 133, 255, 0.25) 0%,
  84. rgba(0, 163, 255, 0) 100%
  85. );
  86. }
  87. .border-panel_header {
  88. height: 50px;
  89. width: var(--width);
  90. background-image: url("../assets/border-panel_header_1.svg");
  91. background-repeat: no-repeat;
  92. background-position: var(--header-ops) 0px;
  93. display: flex;
  94. justify-content: space-between;
  95. .ext-header {
  96. margin-right: 15px;
  97. margin-top: 12px;
  98. }
  99. }
  100. .border-panel::after {
  101. content: "";
  102. position: absolute;
  103. top: 0px;
  104. left: 0px;
  105. padding: 1px;
  106. box-sizing: border-box;
  107. width: var(--width);
  108. height: var(--height);
  109. background: linear-gradient(360deg, #0c5a87 0%, rgba(0, 163, 255, 0) 100%);
  110. /* 随便定义颜色 */
  111. --mask-bg: linear-gradient(red, red);
  112. --m-o: content-box, padding-box;
  113. /* mask允许使用者通过遮罩或者裁切特定区域的图片的方式来隐藏一个元素的部分或者全部可见区域 */
  114. /* 设置了用作元素蒙版层的图像,默认值为none,值为透明图片,或透明渐变 */
  115. -webkit-mask-image: var(--mask-bg), var(--mask-bg);
  116. /* 默认值为border-box,可选值与background-origin相同 */
  117. -webkit-mask-origin: var(--m-o);
  118. /* 默认值为border-box,可选值与background-clip相同 */
  119. -webkit-mask-clip: var(--m-o);
  120. /* exclude排除,只显示不重合的地方,Firefox支持4个属性 */
  121. mask-composite: exclude;
  122. /*只显示下方遮罩,重合的地方不显示*/
  123. -webkit-mask-composite: destination-out;
  124. pointer-events: none;
  125. }
  126. .border-panel_content {
  127. padding: 0px 1px 0px 1px;
  128. }
  129. </style>