1- import { CSSProperties , MouseEvent , TouchEvent } from ' react' ;
2- import { Rect } from ' @embedpdf/models' ;
1+ import { CSSProperties , MouseEvent , TouchEvent } from " react"
2+ import { Rect } from " @embedpdf/models"
33
44type SquigglyProps = {
5- color ?: string ;
6- opacity ?: number ;
7- segmentRects : Rect [ ] ;
8- rect ?: Rect ;
9- scale : number ;
10- onClick ?: ( e : MouseEvent < HTMLDivElement > | TouchEvent < HTMLDivElement > ) => void ;
11- style ?: CSSProperties ;
12- } ;
5+ color ?: string
6+ opacity ?: number
7+ segmentRects : Rect [ ]
8+ rect ?: Rect
9+ scale : number
10+ onClick ?: ( e : MouseEvent < HTMLDivElement > | TouchEvent < HTMLDivElement > ) => void
11+ style ?: CSSProperties
12+ }
1313
1414export function Squiggly ( {
15- color = ' #FFFF00' ,
15+ color = " #FFFF00" ,
1616 opacity = 0.5 ,
1717 segmentRects,
1818 rect,
1919 scale,
2020 onClick,
2121 style,
2222} : SquigglyProps ) {
23- const amplitude = 2 * scale ; // wave height
24- const period = 6 * scale ; // wave length
23+ const amplitude = 2 * scale // wave height
24+ const period = 6 * scale // wave length
2525
2626 const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${ period } " height="${ amplitude * 2 } " viewBox="0 0 ${ period } ${ amplitude * 2 } ">
2727 <path d="M0 ${ amplitude } Q ${ period / 4 } 0 ${ period / 2 } ${ amplitude } T ${ period } ${ amplitude } "
2828 fill="none" stroke="${ color } " stroke-width="${ amplitude } " stroke-linecap="round"/>
29- </svg>` ;
29+ </svg>`
3030
3131 // Completely escape the SVG markup
32- const svgDataUri = `url("data:image/svg+xml;utf8,${ encodeURIComponent ( svg ) } ")` ;
32+ const svgDataUri = `url("data:image/svg+xml;utf8,${ encodeURIComponent ( svg ) } ")`
3333
3434 return (
3535 < >
@@ -39,35 +39,35 @@ export function Squiggly({
3939 onPointerDown = { onClick }
4040 onTouchStart = { onClick }
4141 style = { {
42- position : ' absolute' ,
42+ position : " absolute" ,
4343 left : ( rect ? r . origin . x - rect . origin . x : r . origin . x ) * scale ,
4444 top : ( rect ? r . origin . y - rect . origin . y : r . origin . y ) * scale ,
4545 width : r . size . width * scale ,
4646 height : r . size . height * scale ,
47- background : ' transparent' ,
48- pointerEvents : onClick ? ' auto' : ' none' ,
49- cursor : onClick ? ' pointer' : ' default' ,
47+ background : " transparent" ,
48+ pointerEvents : onClick ? " auto" : " none" ,
49+ cursor : onClick ? " pointer" : " default" ,
5050 zIndex : onClick ? 1 : 0 ,
5151 ...style ,
5252 } }
5353 >
5454 { /* Visual squiggly line */ }
5555 < div
5656 style = { {
57- position : ' absolute' ,
57+ position : " absolute" ,
5858 left : 0 ,
5959 bottom : 0 ,
60- width : ' 100%' ,
60+ width : " 100%" ,
6161 height : amplitude * 2 ,
6262 backgroundImage : svgDataUri ,
63- backgroundRepeat : ' repeat-x' ,
63+ backgroundRepeat : " repeat-x" ,
6464 backgroundSize : `${ period } px ${ amplitude * 2 } px` ,
6565 opacity : opacity ,
66- pointerEvents : ' none' ,
66+ pointerEvents : " none" ,
6767 } }
6868 />
6969 </ div >
7070 ) ) }
7171 </ >
72- ) ;
72+ )
7373}
0 commit comments