update: background properties
This commit is contained in:
@@ -22,9 +22,7 @@ const defaultColors: Record<BackgroundVariant, string> = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
// when there are multiple flows on a page we need to make sure that every background gets its own pattern.
|
|
||||||
|
|
||||||
const bgClasses = ['vue-flow__background']
|
|
||||||
const background = computed(() => {
|
const background = computed(() => {
|
||||||
const scaledGap = props.gap && props.gap * store.transform[2]
|
const scaledGap = props.gap && props.gap * store.transform[2]
|
||||||
const xOffset = scaledGap && store.transform[0] % scaledGap
|
const xOffset = scaledGap && store.transform[0] % scaledGap
|
||||||
@@ -39,13 +37,12 @@ const background = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const isLines = props.variant === BackgroundVariant.Lines
|
// when there are multiple flows on a page we need to make sure that every background gets its own pattern.
|
||||||
const bgColor = props.color ? props.color : defaultColors[props.variant || BackgroundVariant.Dots]
|
|
||||||
const patternId = `pattern-${Math.floor(Math.random() * 100000)}`
|
const patternId = `pattern-${Math.floor(Math.random() * 100000)}`
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<svg
|
<svg
|
||||||
:class="bgClasses"
|
class="vue-flow__background"
|
||||||
:style="{
|
:style="{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
@@ -59,9 +56,9 @@ const patternId = `pattern-${Math.floor(Math.random() * 100000)}`
|
|||||||
:height="background.scaledGap"
|
:height="background.scaledGap"
|
||||||
patternUnits="userSpaceOnUse"
|
patternUnits="userSpaceOnUse"
|
||||||
>
|
>
|
||||||
<template v-if="isLines">
|
<template v-if="props.variant === BackgroundVariant.Lines">
|
||||||
<path
|
<path
|
||||||
:stroke="bgColor"
|
:stroke="props.color ? props.color : defaultColors[props.variant || BackgroundVariant.Dots]"
|
||||||
:stroke-width="props.size"
|
:stroke-width="props.size"
|
||||||
:d="`M${background.scaledGap / 2} 0 V${background.scaledGap} M0 ${background.scaledGap / 2} H${background.scaledGap}`"
|
:d="`M${background.scaledGap / 2} 0 V${background.scaledGap} M0 ${background.scaledGap / 2} H${background.scaledGap}`"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ const props = withDefaults(defineProps<MiniMapNodeProps>(), {
|
|||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
|
|
||||||
const styles = (attrs.style ?? {}) as CSSProperties
|
const styles = (attrs.style ?? {}) as CSSProperties
|
||||||
const fill = computed(() => (props.color || styles.background || styles.backgroundColor) as string)
|
const fill = computed(() => props.color || styles.background || styles.backgroundColor)
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<rect
|
<rect
|
||||||
|
|||||||
Reference in New Issue
Block a user