[react] feat: Added docs for components/Editor
This commit is contained in:
parent
7058843534
commit
f8a987e3d5
6 changed files with 27 additions and 34 deletions
|
@ -9,7 +9,6 @@ import { EditIcon, GroupIcon, OptionsIcon, ResetIcon } from '@freesewing/react/c
|
||||||
import { FormControl } from '@freesewing/react/components/Input'
|
import { FormControl } from '@freesewing/react/components/Input'
|
||||||
import { MiniTip } from '@freesewing/react/components/Mini'
|
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'
|
const iconButtonClass = 'tw:daisy-btn tw:daisy-btn-xs tw:daisy-btn-ghost tw:px-0 tw:text-accent'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,16 +19,18 @@ import { useAccount } from '../../hooks/useAccount/index.mjs'
|
||||||
* FreeSewing's pattern editor
|
* FreeSewing's pattern editor
|
||||||
*
|
*
|
||||||
* Editor is the high-level FreeSewing component
|
* 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,
|
* 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 - All React props
|
||||||
* @param {object} props.config - A configuration object for the editor
|
* @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.design = false] - A design name to preset the editor to use this design
|
||||||
* @param {object} props.preload - Any state to preload
|
* @param {object} [props.preload = {}] - Any state to preload
|
||||||
* @param {function} props.setTitle - A way to set the page title (optional)
|
* @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 (optional)
|
* @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 = ({
|
export const Editor = ({
|
||||||
config = {},
|
config = {},
|
||||||
|
@ -161,7 +163,7 @@ export const Editor = ({
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Helper method to figure out what view to load
|
* Helper method to figure out what view to load
|
||||||
* based on the props passed in, and destructure
|
* based on the props passed in, and destructure
|
||||||
* the props we need for it.
|
* the props we need for it.
|
||||||
|
|
|
@ -320,7 +320,7 @@ export function initialEditorState(preload = {}, config) {
|
||||||
return initial
|
return initial
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* round a value to the correct number of decimal places to display all supplied digits after multiplication
|
* 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
|
* this is a workaround for floating point errors
|
||||||
* examples:
|
* examples:
|
||||||
|
@ -746,25 +746,6 @@ export function noop() {
|
||||||
export function notEmpty(value) {
|
export function notEmpty(value) {
|
||||||
return String(value).length > 0
|
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
|
* A translation fallback method in case none is passed in
|
||||||
|
|
|
@ -28,7 +28,6 @@ import {
|
||||||
menuValueWasChanged,
|
menuValueWasChanged,
|
||||||
noop,
|
noop,
|
||||||
notEmpty,
|
notEmpty,
|
||||||
nsMerge,
|
|
||||||
objUpdate,
|
objUpdate,
|
||||||
sample,
|
sample,
|
||||||
settingsValueIsCustom,
|
settingsValueIsCustom,
|
||||||
|
@ -91,7 +90,6 @@ export {
|
||||||
menuValueWasChanged,
|
menuValueWasChanged,
|
||||||
noop,
|
noop,
|
||||||
notEmpty,
|
notEmpty,
|
||||||
nsMerge,
|
|
||||||
objUpdate,
|
objUpdate,
|
||||||
sample,
|
sample,
|
||||||
settingsValueIsCustom,
|
settingsValueIsCustom,
|
||||||
|
|
|
@ -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/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/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/Echart/* > ../../sites/dev/prebuild/jsdoc/react/components/echart.json
|
||||||
|
jsdoc -c jsdoc.json components/Editor/* > ../../sites/dev/prebuild/jsdoc/react/components/editor.json
|
||||||
|
|
|
@ -2,6 +2,18 @@
|
||||||
title: Editor
|
title: Editor
|
||||||
---
|
---
|
||||||
|
|
||||||
:::note
|
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
|
||||||
This page is yet to be created
|
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>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue