File size: 1,009 Bytes
f56a29b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39


import type { AlignmentLineProps } from '@/lib/types/edit';

export interface AlignmentLineComponentProps extends AlignmentLineProps {
  canvasScale: number;
}

/**
 * Alignment line component
 * Displays visual alignment guides during element dragging
 */
export function AlignmentLine({ type, axis, length, canvasScale }: AlignmentLineComponentProps) {
  // Alignment line position
  const left = axis.x * canvasScale;
  const top = axis.y * canvasScale;

  // Alignment line length
  const sizeStyle =
    type === 'vertical'
      ? { height: `${length * canvasScale}px` }
      : { width: `${length * canvasScale}px` };

  return (
    <div
      className="alignment-line absolute z-42"
      style={{
        left: `${left}px`,
        top: `${top}px`,
      }}
    >
      <div
        className={`line ${type === 'vertical' ? 'border-l border-dashed border-primary -translate-x-0.5' : 'border-t border-dashed border-primary -translate-y-0.5'}`}
        style={sizeStyle}
      />
    </div>
  );
}