1
0

index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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"][this.$props.headerType],
  61. };
  62. },
  63. headerImageBgUrl: function () {
  64. return headerTitleBgs[this.$props.headerType];
  65. },
  66. },
  67. };
  68. </script>
  69. <style scoped lang="less">
  70. .border-panel {
  71. position: relative;
  72. height: var(--height);
  73. width: var(--width);
  74. box-sizing: border-box;
  75. overflow: hidden;
  76. background: linear-gradient(
  77. 360deg,
  78. rgba(0, 133, 255, 0.25) 0%,
  79. rgba(0, 163, 255, 0) 100%
  80. );
  81. }
  82. .border-panel_header {
  83. height: 50px;
  84. width: var(--width);
  85. background-image: url("../assets/border-panel_header_1.svg");
  86. background-repeat: no-repeat;
  87. background-position: var(--header-ops) 0px;
  88. display: flex;
  89. justify-content: space-between;
  90. .ext-header {
  91. margin-right: 15px;
  92. margin-top: 12px;
  93. }
  94. }
  95. .border-panel::after {
  96. content: "";
  97. position: absolute;
  98. top: 0px;
  99. left: 0px;
  100. padding: 1px;
  101. box-sizing: border-box;
  102. width: var(--width);
  103. height: var(--height);
  104. background: linear-gradient(360deg, #0c5a87 0%, rgba(0, 163, 255, 0) 100%);
  105. /* 随便定义颜色 */
  106. --mask-bg: linear-gradient(red, red);
  107. --m-o: content-box, padding-box;
  108. /* mask允许使用者通过遮罩或者裁切特定区域的图片的方式来隐藏一个元素的部分或者全部可见区域 */
  109. /* 设置了用作元素蒙版层的图像,默认值为none,值为透明图片,或透明渐变 */
  110. -webkit-mask-image: var(--mask-bg), var(--mask-bg);
  111. /* 默认值为border-box,可选值与background-origin相同 */
  112. -webkit-mask-origin: var(--m-o);
  113. /* 默认值为border-box,可选值与background-clip相同 */
  114. -webkit-mask-clip: var(--m-o);
  115. /* exclude排除,只显示不重合的地方,Firefox支持4个属性 */
  116. mask-composite: exclude;
  117. /*只显示下方遮罩,重合的地方不显示*/
  118. -webkit-mask-composite: destination-out;
  119. pointer-events: none;
  120. }
  121. .border-panel_content {
  122. padding: 0px 1px 0px 1px;
  123. }
  124. </style>