6 changed files with 212 additions and 19 deletions
@ -0,0 +1,48 @@ |
|||||
|
<template> |
||||
|
<div class='BackgroundClip' :style="{ '--clip-path': clipPath, '--border-color': borderColor, '--bg-color': bgColor }"> |
||||
|
<slot /> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: 'BackgroundClip', |
||||
|
props: { |
||||
|
clipPath: { |
||||
|
type: String, |
||||
|
default: null |
||||
|
}, |
||||
|
borderColor: { |
||||
|
type: String, |
||||
|
default: null |
||||
|
}, |
||||
|
bgColor: { |
||||
|
type: String, |
||||
|
default: null |
||||
|
}, |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang='scss' scoped> |
||||
|
.BackgroundClip { |
||||
|
clip-path: var(--clip-path); |
||||
|
position: relative; |
||||
|
background: var(--border-color); |
||||
|
color: #fff; |
||||
|
|
||||
|
&::before { |
||||
|
content: ""; |
||||
|
position: absolute; |
||||
|
clip-path: var(--clip-path); |
||||
|
left: 50%; |
||||
|
top: 50%; |
||||
|
transform: translate(-50%, -50%); |
||||
|
width: calc(100% - 3px); |
||||
|
height: calc(100% - 3px); |
||||
|
background: var(--bg-color); |
||||
|
pointer-events: none; |
||||
|
z-index: -1; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,32 @@ |
|||||
|
<template> |
||||
|
<BackgroundClip class='BG-01' :clipPath="getClipPath" bgColor="linear-gradient(180deg, #152E3C 0%, #163A45 100%)" |
||||
|
borderColor="linear-gradient(180deg, rgba(40, 144, 167, 1), rgba(40, 144, 167, 0.38), rgba(40, 144, 167, 1))"> |
||||
|
<slot /> |
||||
|
</BackgroundClip> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import BackgroundClip from "./BackgroundClip.vue" |
||||
|
|
||||
|
export default { |
||||
|
name: 'BG-01', |
||||
|
components: { |
||||
|
BackgroundClip |
||||
|
}, |
||||
|
props: { |
||||
|
width: { |
||||
|
type: String, |
||||
|
default: "18px" |
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
getClipPath() { |
||||
|
return `polygon(${this.width} 0%, calc(100% - ${this.width}) 0%, 100% ${this.width}, 100% calc(100% - ${this.width}), calc(100% - ${this.width}) 100%, ${this.width} 100%, 0% calc(100% - ${this.width}), 0% ${this.width})` |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang='scss' scoped> |
||||
|
.BG-01 {} |
||||
|
</style> |
@ -0,0 +1,92 @@ |
|||||
|
<template> |
||||
|
<div class='BG-02' :style="{ '--width': width, '--lang-width': langWidth }"> |
||||
|
<BackgroundClip ref="BackgroundClipRef" class="bg" :clipPath="getClipPath" |
||||
|
bgColor="linear-gradient(180deg, #152E3C 0%, #163A45 100%)" |
||||
|
borderColor="linear-gradient(180deg, rgba(40, 144, 167, 1), rgba(40, 144, 167, 0.38), rgba(40, 144, 167, 1))"> |
||||
|
<slot /> |
||||
|
</BackgroundClip> |
||||
|
<div class="decoration"> |
||||
|
<span v-for="i in whileLength" :key="i" :style="getSize(whileLength - i + 1)" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import BackgroundClip from "./BackgroundClip.vue" |
||||
|
|
||||
|
export default { |
||||
|
name: 'BG-02', |
||||
|
components: { |
||||
|
BackgroundClip |
||||
|
}, |
||||
|
props: { |
||||
|
width: { |
||||
|
type: String, |
||||
|
default: "15px" |
||||
|
}, |
||||
|
langWidth: { |
||||
|
type: String, |
||||
|
default: "150px" |
||||
|
}, |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
whileLength: 3 |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
computed: { |
||||
|
getClipPath() { |
||||
|
return `polygon(calc(100% - ${this.langWidth} - ${this.width} * 2) 0, calc(100% - ${this.langWidth}) calc(${this.width} * 1.5), calc(100% - ${this.width} * 1.4) calc(${this.width} * 1.5), 100% calc(${this.width} * 3), 100% calc(100% - ${this.width}), calc(100% - ${this.width}) 100%, ${this.width} 100%, 0 calc(100% - ${this.width}), 0 ${this.width}, ${this.width} 0)` |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
getSize: (function () { |
||||
|
let top = 0; |
||||
|
|
||||
|
return function (i) { |
||||
|
const base = 7.2; |
||||
|
const size = i * base; |
||||
|
if (i !== this.whileLength) { |
||||
|
top += Math.ceil(((i + 1) * base - size) / 2) + 1 |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
return { width: `${size}px`, height: `${size}px`, marginTop: `${top}px`, backgroundColor: `rgba(50, 179, 187, ${i / this.whileLength})` } |
||||
|
} catch (error) { } |
||||
|
finally { |
||||
|
if (i === 1) top = 0; |
||||
|
} |
||||
|
} |
||||
|
})() |
||||
|
} |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang='scss' scoped> |
||||
|
.BG-02 { |
||||
|
position: relative; |
||||
|
|
||||
|
.bg { |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
} |
||||
|
|
||||
|
.decoration { |
||||
|
position: absolute; |
||||
|
right: 0; |
||||
|
top: calc(var(--width) / 5); |
||||
|
width: calc(var(--lang-width) + 8.1px); |
||||
|
height: calc(var(--width) * 1.5); |
||||
|
display: flex; |
||||
|
// gap: 0px; |
||||
|
// pointer-events: none; |
||||
|
// align-items: center; |
||||
|
|
||||
|
>span { |
||||
|
display: block; |
||||
|
clip-path: polygon(0 25%, 45% 25%, 100% 75%, 55% 75%); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
Loading…
Reference in new issue