1
0
Fork 0
freesewing/packages/react/components/Help/index.mjs

155 lines
4.1 KiB
JavaScript
Raw Normal View History

import React from 'react'
// Components
import { ModalWrapper } from '@freesewing/react/components/Modal'
2025-06-01 17:02:46 +02:00
/*
* A component to display an iframe intended for a modal window.
*
* All props are passed down to the iframe tag.
*
* @component
* @param {object} props - All component props
* @returns {JSX.Element}
*/
2025-06-01 17:04:47 +02:00
const Iframe = (props) => (
<iframe
{...props}
style={{ height: '90vh', width: '90vw' }}
className="tw:w-full tw:mx-auto tw:max-w-4xl"
/>
)
2025-06-01 17:02:46 +02:00
/*
* A component to display an iframe with FreeSewing.eu docs content intended for a modal window.
*
* @component
* @param {object} props - All component props
* @param {string} props.path - The (relative) URL path of the page to load
* @returns {JSX.Element}
*/
2025-06-01 17:04:47 +02:00
const DocsHelp = ({ path }) => (
<Iframe src={`https://freesewing.eu/${path}/?docusaurus-data-fs-embed=true`} />
)
2025-05-31 18:38:32 +02:00
/*
* A component to display inline help for a design option
*
2025-05-31 18:38:32 +02:00
* This is typically loaded as modal content as it returns an iframe.
*
* @component
* @param {object} props - All component props
2025-05-31 18:38:32 +02:00
* @param {string} props.design - The design name
* @param {string} props.o - The option ID
* @returns {JSX.Element}
*/
2025-05-31 18:38:32 +02:00
const DesignOptionHelp = ({ design, o }) =>
design && o ? (
2025-05-31 18:38:32 +02:00
<Iframe
src={`https://freesewing.eu/docs/designs/${design.toLowerCase()}/options/${o.toLowerCase()}/index.html?docusaurus-data-fs-embed=true`}
2025-06-01 17:02:46 +02:00
title="Design Options Help"
/>
) : (
<p>Invalid props provided to DesignOptionHelp.</p>
)
2025-05-31 18:38:32 +02:00
/*
* A component to display inline help for a core setting
*
* This is typically loaded as modal content as it returns an iframe.
*
* @component
* @param {object} props - All component props
* @param {string} props.name - The core setting name/id
* @returns {JSX.Element}
*/
const CoreSettingHelp = ({ name }) =>
name ? (
<Iframe
2025-06-01 17:02:46 +02:00
src={`https://freesewing.eu/docs/editor/menus/settings/${name.toLowerCase()}/index.html?docusaurus-data-fs-embed=true`}
2025-05-31 18:38:32 +02:00
title="Core Setting Help"
/>
) : (
<p>Invalid props provided to CoreSettingsHelp.</p>
)
/*
* A component to display inline help for a UI preference
*
* This is typically loaded as modal content as it returns an iframe.
*
* @component
* @param {object} props - All component props
* @param {string} props.name - The core setting name/id
* @returns {JSX.Element}
*/
const UiPreferenceHelp = ({ name }) =>
name ? (
<Iframe
2025-06-01 17:02:46 +02:00
src={`https://freesewing.eu/docs/editor/menus/preferences/${name.toLowerCase()}/index.html?docusaurus-data-fs-embed=true`}
title="UI Preferences Help"
2025-05-31 18:38:32 +02:00
/>
) : (
<p>Invalid props provided to UiPreferenceHelp.</p>
)
/*
* A component to display inline help for a measurement.
*
2025-05-31 18:38:32 +02:00
* This is typically loaded as modal content as it returns an iframe
*
* @component
* @param {object} props - All component props
* @param {string} [props.m = undefined] - The measurment name (id)
* @returns {JSX.Element}
*/
2025-05-31 18:38:32 +02:00
const MeasurementHelp = ({ m }) =>
m ? (
<iframe
src={`https://freesewing.eu/docs/measurements/${m.toLowerCase()}/index.html?docusaurus-data-fs-embed=true`}
title="Measurement Help"
style={{ height: '90vh', width: '90vw' }}
/>
) : (
2025-05-31 18:38:32 +02:00
<p>No measurement name provided in the m prop.</p>
)
2025-05-31 18:38:32 +02:00
export function modalCoreSettingHelp(name, setModal) {
setModal(
<ModalWrapper fullWidth keepOpenOnClick>
<CoreSettingHelp name={name} />
</ModalWrapper>
)
}
export function modalUiPreferenceHelp(name, setModal) {
setModal(
<ModalWrapper fullWidth keepOpenOnClick>
<UiPreferenceHelp name={name} />
</ModalWrapper>
)
}
export function modalDesignOptionHelp(design, o, setModal) {
setModal(
2025-05-31 18:38:32 +02:00
<ModalWrapper fullWidth keepOpenOnClick>
<DesignOptionHelp {...{ design, o }} />
</ModalWrapper>
)
}
export function modalMeasurementHelp(m, setModal) {
setModal(
2025-05-31 18:38:32 +02:00
<ModalWrapper fullWidth keepOpenOnClick>
<MeasurementHelp m={m} />
</ModalWrapper>
)
}
2025-06-01 17:02:46 +02:00
export function modalDocsHelp(path, setModal) {
setModal(
<ModalWrapper wide keepOpenOnClick>
<DocsHelp path={path} />
</ModalWrapper>
)
}