diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 53bedd9d24..c3deb12bfb 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -278,23 +278,7 @@ export default mixins( }; }, backgroundStyle (): object { - const scale = this.nodeViewScale; - const offsetPosition = this.$store.getters.getNodeViewOffsetPosition; - const squareSize = 20 * scale; - const dotSize = 1 * scale; - const dotPosition = 10 * scale; - const styles: object = { - 'background-size': `${squareSize}px ${squareSize}px`, - 'background-position': `left ${offsetPosition[0]}px top ${offsetPosition[1]}px`, - }; - if (squareSize > 10.5) { - const dotColor = getStyleTokenValue('--color-canvas-dot'); - return { - ...styles, - 'background-image': `radial-gradient(circle at ${dotPosition}px ${dotPosition}px, ${dotColor} ${dotSize}px, transparent 0)`, - }; - } - return styles; + return CanvasHelpers.getBackgroundStyles(this.nodeViewScale, this.$store.getters.getNodeViewOffsetPosition); }, workflowClasses () { const returnClasses = []; diff --git a/packages/editor-ui/src/views/canvasHelpers.ts b/packages/editor-ui/src/views/canvasHelpers.ts index eb319b25ef..6acb0753e2 100644 --- a/packages/editor-ui/src/views/canvasHelpers.ts +++ b/packages/editor-ui/src/views/canvasHelpers.ts @@ -325,3 +325,21 @@ export const getRelativePosition = (x: number, y: number, scale: number, offset: (y - offset[1]) / scale, ]; }; + +export const getBackgroundStyles = (scale: number, offsetPosition: XYPosition) => { + const squareSize = 20 * scale; + const dotSize = 1 * scale; + const dotPosition = 10 * scale; + const styles: object = { + 'background-size': `${squareSize}px ${squareSize}px`, + 'background-position': `left ${offsetPosition[0]}px top ${offsetPosition[1]}px`, + }; + if (squareSize > 10.5) { + const dotColor = getStyleTokenValue('--color-canvas-dot'); + return { + ...styles, + 'background-image': `radial-gradient(circle at ${dotPosition}px ${dotPosition}px, ${dotColor} ${dotSize}px, transparent 0)`, + }; + } + return styles; +};