index.vue 3.1 KB

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