2024-10-06 11:49:14 +02:00
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A React component to wrap SVG linedrawings for FreeSewing designs
|
|
|
|
*
|
|
|
|
* @param design {string} - The (lowercase) name of a FreeSewing design
|
|
|
|
* @param className {string} - CSS classes to set on the svg tag
|
|
|
|
*
|
|
|
|
* @return LineDrawing as JSX
|
|
|
|
*/
|
|
|
|
export const LineDrawingWrapper = ({
|
2025-04-18 08:07:13 +00:00
|
|
|
className = 'tw:w-full', // CSS classes to apply
|
2024-10-06 11:49:14 +02:00
|
|
|
viewBox = '0 0 100 100', // SVG viewBox
|
|
|
|
stroke = 1, // Stroke to use
|
|
|
|
children = [], // The actual linedrawing
|
2024-10-06 12:03:08 +02:00
|
|
|
style = { maxHeight: 'inherit' },
|
2024-10-06 11:49:14 +02:00
|
|
|
}) => (
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
fill="none"
|
|
|
|
viewBox={viewBox}
|
|
|
|
strokeWidth={stroke}
|
|
|
|
stroke="currentColor"
|
|
|
|
strokeLinecap="round"
|
|
|
|
strokeLinejoin="round"
|
|
|
|
className={className + ' linedrawing'}
|
2024-10-06 12:03:08 +02:00
|
|
|
style={style}
|
2024-10-06 11:49:14 +02:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</svg>
|
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
2024-10-12 16:41:28 +02:00
|
|
|
* Regular stroke-width helper to ensure consistency across linedrawings
|
|
|
|
*/
|
|
|
|
export const regular = (stroke = 1) => ({ strokeWidth: stroke })
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Thin stroke-width helper to ensure consistency across linedrawings
|
2024-10-06 11:49:14 +02:00
|
|
|
*/
|
2025-04-01 16:15:20 +02:00
|
|
|
export const thin = (stroke = 1) => ({ strokeWidth: stroke / 1.3 })
|
2024-10-06 11:49:14 +02:00
|
|
|
|
|
|
|
/*
|
2024-10-12 16:41:28 +02:00
|
|
|
* Very thin stroke-width helper to ensure consistency across linedrawings
|
2024-10-06 11:49:14 +02:00
|
|
|
*/
|
2025-04-01 16:15:20 +02:00
|
|
|
export const veryThin = (stroke = 1) => ({ strokeWidth: stroke / 2 })
|
2024-10-06 11:49:14 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dashed stroke-dasharray helper to ensure consistency across linedrawings
|
|
|
|
*/
|
|
|
|
export const dashed = (stroke = 1) => ({ strokeDasharray: `${stroke * 1.2},${stroke * 0.8}` })
|