1
0
Fork 0

[react] feat: Added docs for components/Editor

This commit is contained in:
joostdecock 2025-05-10 15:47:00 +02:00
parent 7058843534
commit f8a987e3d5
6 changed files with 27 additions and 34 deletions

View file

@ -9,7 +9,6 @@ import { EditIcon, GroupIcon, OptionsIcon, ResetIcon } from '@freesewing/react/c
import { FormControl } from '@freesewing/react/components/Input'
import { MiniTip } from '@freesewing/react/components/Mini'
/** @type {String} class to apply to buttons on open menu items */
const iconButtonClass = 'tw:daisy-btn tw:daisy-btn-xs tw:daisy-btn-ghost tw:px-0 tw:text-accent'
/**

View file

@ -19,16 +19,18 @@ import { useAccount } from '../../hooks/useAccount/index.mjs'
* FreeSewing's pattern editor
*
* Editor is the high-level FreeSewing component
* that provides the entire pattern editing environment
* that provides the entire pattern editing environment.
* This is a high-level wrapper that figures out what view to load initially,
* and handles state for the pattern, including the view
* and handles state for the pattern, including the view.
*
* @component
* @param {object} props - All React props
* @param {object} props.config - A configuration object for the editor
* @param {object} props.design - A design name to force the editor to use this design
* @param {object} props.preload - Any state to preload
* @param {function} props.setTitle - A way to set the page title (optional)
* @param {object} props.localDesigns - A way to add local designs to the editor (optional)
* @param {object} [props.config = {}] - A configuration object for the editor
* @param {object} [props.design = false] - A design name to preset the editor to use this design
* @param {object} [props.preload = {}] - Any state to preload
* @param {function} [props.setTitle = false] - A way to set the page title
* @param {object} [props.localDesigns = {}] - A way to add local designs to the editor
* @param {function} [props.measurementsHelpProvider = false] - A function that should return to a URL for measurements help
*/
export const Editor = ({
config = {},
@ -161,7 +163,7 @@ export const Editor = ({
)
}
/**
/*
* Helper method to figure out what view to load
* based on the props passed in, and destructure
* the props we need for it.

View file

@ -320,7 +320,7 @@ export function initialEditorState(preload = {}, config) {
return initial
}
/**
/*
* round a value to the correct number of decimal places to display all supplied digits after multiplication
* this is a workaround for floating point errors
* examples:
@ -746,25 +746,6 @@ export function noop() {
export function notEmpty(value) {
return String(value).length > 0
}
/**
* Helper method to merge arrays of translation namespaces
*
* Note that this method is variadic
*
* @param {[string]} namespaces - A string or array of strings of namespaces
* @return {[string]} namespaces - A merged array of all namespaces
*/
export function nsMerge(...args) {
const ns = new Set()
for (const arg of args) {
if (typeof arg === 'string') ns.add(arg)
else if (Array.isArray(arg)) {
for (const el of nsMerge(...arg)) ns.add(el)
}
}
return [...ns]
}
/*
* A translation fallback method in case none is passed in

View file

@ -28,7 +28,6 @@ import {
menuValueWasChanged,
noop,
notEmpty,
nsMerge,
objUpdate,
sample,
settingsValueIsCustom,
@ -91,7 +90,6 @@ export {
menuValueWasChanged,
noop,
notEmpty,
nsMerge,
objUpdate,
sample,
settingsValueIsCustom,

View file

@ -10,3 +10,4 @@ jsdoc -c jsdoc.json components/Control/* > ../../sites/dev/prebuild/jsdoc/react/
jsdoc -c jsdoc.json components/CuratedSet/* > ../../sites/dev/prebuild/jsdoc/react/components/curatedset.json
jsdoc -c jsdoc.json components/Docusaurus/* > ../../sites/dev/prebuild/jsdoc/react/components/docusaurus.json
jsdoc -c jsdoc.json components/Echart/* > ../../sites/dev/prebuild/jsdoc/react/components/echart.json
jsdoc -c jsdoc.json components/Editor/* > ../../sites/dev/prebuild/jsdoc/react/components/editor.json

View file

@ -2,6 +2,18 @@
title: Editor
---
:::note
This page is yet to be created
:::
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
import { ComponentDocs } from '@site/src/components/component-docs.js'
import { jsdocEditor } from '@site/prebuild/jsdoc/components.editor.mjs'
import { Editor } from '@freesewing/react/components/Editor'
<DocusaurusDoc>
The **Editor** component family provides the following components:
- [Editor](#editor)
## Editor
<ComponentDocs docs={jsdocEditor} example={Editor} />
</DocusaurusDoc>