import React from 'react' import sanitize from 'html-react-parser' const style = { fill: 'none', stroke: 'currentColor' } const StackDefs = ({ stacks }) => Object.keys(stacks).map((stackName) => { const part = stacks[stackName].parts[0] let anchor = { x: 0, y: 0 } if (typeof part.points.gridAnchor !== 'undefined') anchor = part.points.gridAnchor else if (typeof part.points.anchor !== 'undefined') anchor = part.points.anchor if (isNaN(anchor.x)) anchor.x = 0 if (isNaN(anchor.y)) anchor.y = 0 return ( ) }) const MetricPaperlessDefs = ({ stacks }) => ( <> ) const ImperialPaperlessDefs = ({ stacks }) => ( <> ) const PaperlessDefs = ({ units = 'metric', stacks }) => units === 'imperial' ? ( ) : ( ) /** * A component to render the defs section of an SVG element inside a FreeSewing pattern * * @component * @param {object} props - All component props * @param {Svg} props.svg - The FreeSewing Svg object for the pattern * @param {object} props.settings - The settings for the pattern * @param {object} props.stacks - The pattern stacks * @returns {JSX.Element} */ export const Defs = ({ svg, stacks, settings = {} }) => svg ? ( {svg.defs.list ? sanitize(Object.values(svg.defs.list).join('')) : null} {settings[0]?.paperless ? : null} ) : null