import React, { useState } from 'react' import { withinPartBounds, defaultComponents as patternComponents, } from '@freesewing/react/components/Pattern' import { H5, H6 } from '@freesewing/react/components/Heading' import { KeyVal } from '@freesewing/react/components/KeyVal' import { round } from '@freesewing/utils' export const PointXray = ({ stackName, pointName, part, point, settings, components, strings, drillProps = {}, }) => { // Don't include parts outside the part bounding box if (!withinPartBounds(point, part)) return null const { info = {} } = drillProps /* * We use the Point component from Pattern here * If we would extract Point from the components passed down, * we'd create a recursion loop as the Point we call below * would be this very PointXray component. */ const { Point } = patternComponents return ( <> info?.set ? info.set() : null } > {pointName} {round(point.x)},{round(point.y)} ) } const PointXrayInfo = ({ point, pointName, stackName }) => { const [rounded, setRounded] = useState(true) const rounder = rounded ? round : (val) => val return (
Point {pointName} of {stackName}
Coordinates
{Object.keys(point.attributes.list).length > 0 ? ( <>
Attributes
{Object.entries(point.attributes.list).map(([k, val]) => ( ))}
) : null}
) }