({
width,
height,
x,
y,
squares,
...props
}: React.ComponentPropsWithoutRef<'svg'> & {
width: number;
height: number;
x: string | number;
y: string | number;
squares: Array<[x: number, y: number]>;
})
| 1 | import { useId } from 'react'; |
| 2 | |
| 3 | export function GridPattern({ |
| 4 | width, |
| 5 | height, |
| 6 | x, |
| 7 | y, |
| 8 | squares, |
| 9 | ...props |
| 10 | }: React.ComponentPropsWithoutRef<'svg'> & { |
| 11 | width: number; |
| 12 | height: number; |
| 13 | x: string | number; |
| 14 | y: string | number; |
| 15 | squares: Array<[x: number, y: number]>; |
| 16 | }) { |
| 17 | let patternId = useId(); |
| 18 | |
| 19 | return ( |
| 20 | <svg aria-hidden="true" {...props}> |
| 21 | <defs> |
| 22 | <pattern |
| 23 | id={patternId} |
| 24 | width={width} |
| 25 | height={height} |
| 26 | patternUnits="userSpaceOnUse" |
| 27 | x={x} |
| 28 | y={y} |
| 29 | > |
| 30 | <path d={`M.5 ${height}V.5H${width}`} fill="none" /> |
| 31 | </pattern> |
| 32 | </defs> |
| 33 | <rect |
| 34 | width="100%" |
| 35 | height="100%" |
| 36 | strokeWidth={0} |
| 37 | fill={`url(#${patternId})`} |
| 38 | /> |
| 39 | {squares && ( |
| 40 | <svg x={x} y={y} className="overflow-visible"> |
| 41 | {squares.map(([x, y]) => ( |
| 42 | <rect |
| 43 | strokeWidth="0" |
| 44 | key={`${x}-${y}`} |
| 45 | width={width + 1} |
| 46 | height={height + 1} |
| 47 | x={x * width} |
| 48 | y={y * height} |
| 49 | /> |
| 50 | ))} |
| 51 | </svg> |
| 52 | )} |
| 53 | </svg> |
| 54 | ); |
| 55 | } |
nothing calls this directly
no outgoing calls
no test coverage detected