Skip to content

Commit ceb90c9

Browse files
committed
chore(background): cleanup
Signed-off-by: braks <[email protected]>
1 parent 170f79c commit ceb90c9

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/background/src/Background.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { useVueFlow } from '@vue-flow/core'
33
import { BackgroundVariant } from './types'
44
import type { BackgroundProps } from './types'
5-
import { LinePattern } from './patterns'
5+
import { DotPattern, LinePattern } from './patterns'
66
77
const {
88
id,
@@ -29,7 +29,7 @@ const { id: vueFlowId, viewport } = useVueFlow()
2929
const gapXY = computed(() => (Array.isArray(gap) ? gap : [gap, gap]))
3030
3131
const background = $computed(() => {
32-
const scaledGap = [gapXY.value[0] * viewport.value.zoom || 1, gapXY.value[1] * viewport.value.zoom || 1]
32+
const scaledGap: [number, number] = [gapXY.value[0] * viewport.value.zoom || 1, gapXY.value[1] * viewport.value.zoom || 1]
3333
3434
const scaledSize = size * viewport.value.zoom
3535
@@ -79,7 +79,7 @@ export default {
7979
>
8080
<slot name="pattern">
8181
<template v-if="variant === BackgroundVariant.Lines">
82-
<LinePattern :size="lineWidth" :color="patternColor" :dimensions="background.size" />
82+
<LinePattern :size="lineWidth" :color="patternColor" :dimensions="background.scaledGap" />
8383
</template>
8484

8585
<template v-else-if="variant === BackgroundVariant.Dots">

packages/background/src/patterns.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ interface LinePatternProps {
77
color: string
88
}
99

10-
export const LinePattern: FunctionalComponent<LinePatternProps> = ({ dimensions, size, color }) => {
11-
return () =>
12-
h('path', {
13-
'stroke': color,
14-
'stroke-width': size,
15-
'd': `M${dimensions[0] / 2} 0 V${dimensions[1]} M0 ${dimensions[1] / 2} H${dimensions[0]}`,
16-
})
10+
export const LinePattern: FunctionalComponent<LinePatternProps> = function ({ dimensions, size, color }) {
11+
return h('path', {
12+
'stroke': color,
13+
'stroke-width': size,
14+
'd': `M${dimensions[0] / 2} 0 V${dimensions[1]} M0 ${dimensions[1] / 2} H${dimensions[0]}`,
15+
})
1716
}
1817

1918
interface DotPatternProps {
2019
radius: number
2120
color: string
2221
}
2322

24-
export const DotPattern: FunctionalComponent<DotPatternProps> = ({ radius, color }) => {
25-
return () => h('circle', { cx: radius, cy: radius, r: radius, fill: color })
23+
export const DotPattern: FunctionalComponent<DotPatternProps> = function ({ radius, color }) {
24+
return h('circle', { cx: radius, cy: radius, r: radius, fill: color })
2625
}
2726

2827
export const Patterns = {

0 commit comments

Comments
 (0)