feat(dev): Added react docs for Pattern + refactor
This adds support for not only documenating components, but also constants and functions that may be exported next to components.
This commit is contained in:
parent
d0baf7cece
commit
22a89f12d3
50 changed files with 1816 additions and 669 deletions
|
@ -16,8 +16,11 @@ import { Circle as DefaultCircle } from './circle.mjs'
|
|||
import { getId, getProps, withinPartBounds, translateStrings } from './utils.mjs'
|
||||
import { Link as WebLink } from '@freesewing/react/components/Link'
|
||||
|
||||
/*
|
||||
* Allow people to override these components
|
||||
/**
|
||||
* Default pattern components that you can override
|
||||
*
|
||||
* @public
|
||||
* @constant
|
||||
*/
|
||||
const defaultComponents = {
|
||||
Svg: DefaultSvg,
|
||||
|
@ -34,9 +37,17 @@ const defaultComponents = {
|
|||
Circle: DefaultCircle,
|
||||
}
|
||||
|
||||
/*
|
||||
* The pattern component
|
||||
* FIXME: document props
|
||||
/**
|
||||
* A component to render a FreeSewing pattern based on its renderProps
|
||||
*
|
||||
* @component
|
||||
* @param {object} props - All component props
|
||||
* @param {JSX.Element} props.children - The component children, if they are set, we will not render any stacks
|
||||
* @param {string} [props.className = 'freesewing pattern'] - SVG classes to set on the SVG element
|
||||
* @param {object} [props.components = {}] - Any custom components to use in the pattern
|
||||
* @param {object} [props.string = {}] - Strings to use for translation
|
||||
* @param {object} props.renderProps - The pattern's renderProps as generated by FreeSewing core
|
||||
* @returns {JSX.Element}
|
||||
*/
|
||||
const Pattern = forwardRef((props, ref) => {
|
||||
if (!props.renderProps) return null
|
||||
|
@ -102,3 +113,17 @@ export {
|
|||
// The Pattern component itself
|
||||
Pattern,
|
||||
}
|
||||
|
||||
// Also export default components
|
||||
export const Svg = DefaultSvg
|
||||
export const Defs = DefaultDefs
|
||||
export const Group = DefaultGroup
|
||||
export const Stack = DefaultStack
|
||||
export const Part = DefaultPart
|
||||
export const Point = DefaultPoint
|
||||
export const Path = DefaultPath
|
||||
export const Snippet = DefaultSnippet
|
||||
export const Grid = DefaultGrid
|
||||
export const Text = DefaultText
|
||||
export const TextOnPath = DefaultTextOnPath
|
||||
export const Circle = DefaultCircle
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue