nazhua/src/components/dot-dot-box.vue
hi2hi 4e2ff5b84e 🚀 0.4.3
拆分点阵背景图为独立组件,支持显示控制;
config挂上reactive,支持动态响应,未来更优雅的支持配置;
执行setting的custom_code;
2024-12-06 16:34:31 +00:00

84 lines
1.6 KiB
Vue

<template>
<div
class="dot-dot-box"
:class="{
'dot-dot-box--hide': $config.nazhua?.hideDotBG === true,
}"
:style="boxStyle"
>
<slot />
</div>
</template>
<script setup>
/**
* 点格子背景盒子
*/
import { computed } from 'vue';
const props = defineProps({
borderRadius: {
type: [String, Number],
default: 12,
},
padding: {
type: [String, Number],
default: 20,
},
color: {
type: String,
default: '#eee',
},
});
const boxStyle = computed(() => {
const style = {};
if (props.borderRadius) {
if (typeof props.borderRadius === 'number') {
style['--border-radius'] = `${props.borderRadius}px`;
} else {
style['--border-radius'] = `${props.borderRadius}`;
}
}
if (props.padding) {
if (typeof props.padding === 'number') {
style.padding = `${props.padding}px`;
} else {
style.padding = props.padding;
}
}
if (props.color) {
style.color = props.color;
}
return style;
});
</script>
<style lang="scss" scoped>
.dot-dot-box {
--border-radius: 12px;
color: #eee;
border-radius: var(--border-radius);
box-shadow: 2px 4px 6px rgba(#000, 0.4);
background-image: radial-gradient(transparent 1px, rgba(#000, 0.6) 1px);
background-size: 3px 3px;
backdrop-filter: saturate(50%) blur(3px);
&--hide {
background-color: rgba(#000, 0.8);
background-image: none;
backdrop-filter: none;
}
@media screen and (max-width: 768px) {
background-color: rgba(#000, 0.8);
background-image: none;
backdrop-filter: none;
}
}
</style>