feat: Add pattern slot to background
# What's changed? * Add a slot named pattern to background * Allows for icons or similar things to be passed as bg pattern
This commit is contained in:
@@ -26,7 +26,7 @@ const background = $computed(() => {
|
|||||||
const scaledGap = gap && gap * viewport.zoom
|
const scaledGap = gap && gap * viewport.zoom
|
||||||
const xOffset = scaledGap && viewport.x % scaledGap
|
const xOffset = scaledGap && viewport.x % scaledGap
|
||||||
const yOffset = scaledGap && viewport.y % scaledGap
|
const yOffset = scaledGap && viewport.y % scaledGap
|
||||||
const bgSize = size || 0.4 * viewport.zoom
|
const bgSize = size * viewport.zoom
|
||||||
|
|
||||||
return {
|
return {
|
||||||
scaledGap,
|
scaledGap,
|
||||||
@@ -66,15 +66,17 @@ export default {
|
|||||||
:height="background.scaledGap"
|
:height="background.scaledGap"
|
||||||
patternUnits="userSpaceOnUse"
|
patternUnits="userSpaceOnUse"
|
||||||
>
|
>
|
||||||
<template v-if="variant === BackgroundVariant.Lines">
|
<slot name="pattern">
|
||||||
<path :stroke="patternColor" :stroke-width="size" :d="d" />
|
<template v-if="variant === BackgroundVariant.Lines">
|
||||||
</template>
|
<path :stroke="patternColor" :stroke-width="size" :d="d" />
|
||||||
<template v-else-if="variant === BackgroundVariant.Dots">
|
</template>
|
||||||
<circle :cx="background.size" :cy="background.size" :r="background.size" :fill="patternColor" />
|
<template v-else-if="variant === BackgroundVariant.Dots">
|
||||||
</template>
|
<circle :cx="background.size" :cy="background.size" :r="background.size" :fill="patternColor" />
|
||||||
<svg v-if="bgColor" height="100" width="100">
|
</template>
|
||||||
<rect width="100%" height="100%" :fill="bgColor" />
|
<svg v-if="bgColor" height="100" width="100">
|
||||||
</svg>
|
<rect width="100%" height="100%" :fill="bgColor" />
|
||||||
|
</svg>
|
||||||
|
</slot>
|
||||||
</pattern>
|
</pattern>
|
||||||
<rect :x="x" :y="y" width="100%" height="100%" :fill="`url(#${patternId})`" />
|
<rect :x="x" :y="y" width="100%" height="100%" :fill="`url(#${patternId})`" />
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
|
|||||||
Reference in New Issue
Block a user