diff --git a/sites/lab/hooks/useApp.mjs b/sites/lab/hooks/useApp.mjs index 5f964454e95..486e57f8280 100644 --- a/sites/lab/hooks/useApp.mjs +++ b/sites/lab/hooks/useApp.mjs @@ -53,7 +53,7 @@ for (const type in designsByType) { } } -function useApp(full = true) { +export const useApp = () => { // Load translation method const locale = useRouter().locale const { t } = useTranslation(['app']) @@ -108,5 +108,3 @@ function useApp(full = true) { standalone: false, } } - -export default useApp diff --git a/sites/shared/components/workbench/exporting/export-worker.mjs b/sites/shared/components/workbench/exporting/export-worker.js similarity index 100% rename from sites/shared/components/workbench/exporting/export-worker.mjs rename to sites/shared/components/workbench/exporting/export-worker.js diff --git a/sites/shared/components/workbench/exporting/pdf-maker.mjs b/sites/shared/components/workbench/exporting/pdf-maker.mjs index 0cad1567bbc..36dd06b3b91 100644 --- a/sites/shared/components/workbench/exporting/pdf-maker.mjs +++ b/sites/shared/components/workbench/exporting/pdf-maker.mjs @@ -1,6 +1,6 @@ import PDFDocument from 'pdfkit/js/pdfkit.standalone' import SVGtoPDF from 'svg-to-pdfkit' -import { logoPath } from 'shared/logos/freesewing.mjs' +import { logoPath } from 'shared/components/logos/freesewing.mjs' /** an svg of the logo to put on the cover page */ const logoSvg = ` diff --git a/sites/shared/components/workbench/inputs/design-option-pct-deg.mjs b/sites/shared/components/workbench/inputs/design-option-pct-deg.mjs index dc0bd3164f9..3f28165c995 100644 --- a/sites/shared/components/workbench/inputs/design-option-pct-deg.mjs +++ b/sites/shared/components/workbench/inputs/design-option-pct-deg.mjs @@ -1,6 +1,6 @@ import { useState } from 'react' import { ClearIcon, EditIcon } from 'shared/components/icons.mjs' -import { formatMm, round } from 'shared/utils' +import { formatMm, round } from 'shared/utils.mjs' import { useTranslation } from 'next-i18next' const EditOption = (props) => ( diff --git a/sites/shared/components/workbench/logs.mjs b/sites/shared/components/workbench/logs.mjs index 83579e04da5..47fbaf43821 100644 --- a/sites/shared/components/workbench/logs.mjs +++ b/sites/shared/components/workbench/logs.mjs @@ -1,6 +1,6 @@ import Markdown from 'react-markdown' -import { formatMm } from 'shared/utils' -import { Tab, Tabs } from '../mdx/tabs.js' +import { formatMm } from 'shared/utils.mjs' +import { Tab, Tabs } from '../mdx/tabs.mjs' export const Error = ({ err }) => { // Include the error name and message info if it isn't already at the top diff --git a/sites/shared/components/workbench/measurements/index.js b/sites/shared/components/workbench/measurements/index.mjs similarity index 89% rename from sites/shared/components/workbench/measurements/index.js rename to sites/shared/components/workbench/measurements/index.mjs index 76877281fd5..2ff7260c079 100644 --- a/sites/shared/components/workbench/measurements/index.js +++ b/sites/shared/components/workbench/measurements/index.mjs @@ -1,14 +1,14 @@ import React, { useMemo, useEffect, useState } from 'react' -import MeasurementInput from '../inputs/measurement.js' +import { MeasurementInput } from '../inputs/measurement.mjs' import { adult, doll, giant } from '@freesewing/models' import { - CisFemalIcon as WomenswearIcon, + CisFemaleIcon as WomenswearIcon, CisMaleIcon as MenswearIcon, } from 'shared/components/icons.mjs' import { useTranslation } from 'next-i18next' -import Setting from '../menu/core-settings/setting' -import { settings } from '../menu/core-settings/index' -import { Tab, Tabs } from 'shared/components/mdx/tabs.js' +import { Setting } from '../menu/core-settings/setting.mjs' +import { settings } from '../menu/core-settings/index.mjs' +import { Tab, Tabs } from 'shared/components/mdx/tabs.mjs' const groups = { adult, doll, giant } @@ -17,7 +17,7 @@ const icons = { cisMale: , } -const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) => { +export const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) => { const { t } = useTranslation(['app', 'cfp']) // Method to handle measurement updates @@ -111,5 +111,3 @@ const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) => ) } - -export default WorkbenchMeasurements diff --git a/sites/shared/components/workbench/measurements/non-human.js b/sites/shared/components/workbench/measurements/non-human.mjs similarity index 59% rename from sites/shared/components/workbench/measurements/non-human.js rename to sites/shared/components/workbench/measurements/non-human.mjs index 7d44effa177..139353b70d2 100644 --- a/sites/shared/components/workbench/measurements/non-human.js +++ b/sites/shared/components/workbench/measurements/non-human.mjs @@ -8,43 +8,34 @@ const nonHuman = { womenswear: { dolls: dolls.cisFemale, giants: giants.cisMale, - } + }, } -const round = val => Math.round(val*10)/10 -for (let i=0.1;i<0.7;i+=0.1) { - const name = `${Math.round(i*10)}/10` +const round = (val) => Math.round(val * 10) / 10 +for (let i = 0.1; i < 0.7; i += 0.1) { + const name = `${Math.round(i * 10)}/10` nonHuman.womenswear.dolls[name] = {} // womenswear: Based on womenswear34 for (const [m, val] of Object.entries(womenswear34)) { - nonHuman.womenswear.dolls[name][m] = (m === 'shoulderSlope') - ? val - : round(val * i) + nonHuman.womenswear.dolls[name][m] = m === 'shoulderSlope' ? val : round(val * i) } nonHuman.menswear.dolls[name] = {} // menswear: Based on menswear42 for (const [m, val] of Object.entries(menswear42)) { - nonHuman.menswear.dolls[name][m] = (m === 'shoulderSlope') - ? val - : round(val * i) + nonHuman.menswear.dolls[name][m] = m === 'shoulderSlope' ? val : round(val * i) } } -for (let i=1.5;i<=3;i+=0.5) { +for (let i = 1.5; i <= 3; i += 0.5) { const name = `${i}/1` nonHuman.womenswear.giants[name] = {} // womenswear: Based on womenswear34 for (const [m, val] of Object.entries(womenswear34)) { - nonHuman.womenswear.giants[name][m] = (m === 'shoulderSlope') - ? val - : round(val * i) + nonHuman.womenswear.giants[name][m] = m === 'shoulderSlope' ? val : round(val * i) } nonHuman.menswear.giants[name] = {} // menswear: Based on menswear42 for (const [m, val] of Object.entries(menswear42)) { - nonHuman.menswear.giants[name][m] = (m === 'shoulderSlope') - ? val - : round(val * i) + nonHuman.menswear.giants[name][m] = m === 'shoulderSlope' ? val : round(val * i) } } export default nonHuman - diff --git a/sites/shared/components/workbench/menu/core-settings/index.mjs b/sites/shared/components/workbench/menu/core-settings/index.mjs index 24ce95c14bb..7e2079e9445 100644 --- a/sites/shared/components/workbench/menu/core-settings/index.mjs +++ b/sites/shared/components/workbench/menu/core-settings/index.mjs @@ -1,7 +1,7 @@ import { SettingsIcon } from 'shared/components/icons.mjs' -import { Chevron } from 'shared/components/navigation/primary.js' -import Setting from './setting.js' -import { Ul, Details, TopSummary, TopSumTitle } from '../index.js' +import { Chevron } from 'shared/components/navigation/primary.mjs' +import { Setting } from './setting.mjs' +import { Ul, Details, TopSummary, TopSumTitle } from '../index.mjs' import { useTranslation } from 'next-i18next' export const settings = { diff --git a/sites/shared/components/workbench/menu/design-options/index.mjs b/sites/shared/components/workbench/menu/design-options/index.mjs index 47594ddc6e8..7a2422d0235 100644 --- a/sites/shared/components/workbench/menu/design-options/index.mjs +++ b/sites/shared/components/workbench/menu/design-options/index.mjs @@ -1,8 +1,8 @@ import { OptionsIcon } from 'shared/components/icons.mjs' -import { Chevron } from 'shared/components/navigation/primary.js' +import { Chevron } from 'shared/components/navigation/primary.mjs' import { OptionGroup } from './option-group.mjs' import { OptionComponent } from './option.mjs' -import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu.mjs' +import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu/index.mjs' import { useTranslation } from 'next-i18next' import { optionsMenuStructure } from 'shared/utils.mjs' diff --git a/sites/shared/components/workbench/menu/design-options/option-group.mjs b/sites/shared/components/workbench/menu/design-options/option-group.mjs index b3d3156e9cc..2d9e265361c 100644 --- a/sites/shared/components/workbench/menu/design-options/option-group.mjs +++ b/sites/shared/components/workbench/menu/design-options/option-group.mjs @@ -1,5 +1,5 @@ import { Chevron } from 'shared/components/navigation/primary.mjs' -import { Li, Ul, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu.mjs' +import { Li, Ul, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu/index.mjs' import { useTranslation } from 'next-i18next' export const OptionGroup = (props) => { diff --git a/sites/shared/components/workbench/menu/design-options/option-input.mjs b/sites/shared/components/workbench/menu/design-options/option-input.mjs index 54de231e491..11b97ec48d6 100644 --- a/sites/shared/components/workbench/menu/design-options/option-input.mjs +++ b/sites/shared/components/workbench/menu/design-options/option-input.mjs @@ -1,4 +1,4 @@ -import { PctDegOption } from 'shared/components/workbench/inputs/design-option-pct-deg.mjs' +import { DesignOptionPctDeg } from 'shared/components/workbench/inputs/design-option-pct-deg.mjs' import { CountOption } from 'shared/components/workbench/inputs/design-option-count.mjs' import { ListOption } from 'shared/components/workbench/inputs/design-option-list.mjs' import { Popout } from 'shared/components/popout.mjs' @@ -6,9 +6,9 @@ import { Popout } from 'shared/components/popout.mjs' export const Tmp = (props) =>

not yet

export const inputs = { - pct: PctDegOption, + pct: DesignOptionPctDeg, count: CountOption, - deg: (props) => , + deg: (props) => , list: ListOption, mm: () => ( diff --git a/sites/shared/components/workbench/menu/design-options/option.mjs b/sites/shared/components/workbench/menu/design-options/option.mjs index a230b98a6f7..58f85dc9a2b 100644 --- a/sites/shared/components/workbench/menu/design-options/option.mjs +++ b/sites/shared/components/workbench/menu/design-options/option.mjs @@ -1,6 +1,13 @@ import { Chevron } from 'shared/components/navigation/primary.mjs' import { optionType } from 'shared/utils.mjs' -import { Li, Details, Summary, SumButton, SumDiv, Deg } from 'shared/components/workbench/menu.mjs' +import { + Li, + Details, + Summary, + SumButton, + SumDiv, + Deg, +} from 'shared/components/workbench/menu/index.mjs' import { useTranslation } from 'next-i18next' import { values } from 'shared/components/workbench/menu/design-options/option-value.mjs' import { inputs } from 'shared/components/workbench/menu/design-options/option-input.mjs' diff --git a/sites/shared/components/workbench/menu/index.mjs b/sites/shared/components/workbench/menu/index.mjs index a883bda189c..b4f2b0fdb15 100644 --- a/sites/shared/components/workbench/menu/index.mjs +++ b/sites/shared/components/workbench/menu/index.mjs @@ -1,9 +1,9 @@ import { linkClasses } from 'shared/components/navigation/primary.mjs' import { ViewMenu } from './view.mjs' -import { DesignOptions } from './design-options.mjs' -import { CoreSettings } from './core-settings.mjs' -import { Xray } from './xray' -import { TestDesignOptions } from './test-design-options.mjs' +import { DesignOptions } from './design-options/index.mjs' +import { CoreSettings } from './core-settings/index.mjs' +import { Xray } from './xray/index.mjs' +import { TestDesignOptions } from './test-design-options/index.mjs' export const Ul = (props) =>
    {props.children}
export const Li = (props) => ( @@ -111,11 +111,13 @@ export const WorkbenchMenu = (props) => { {['draft', 'cuttingLayout', 'printingLayout'].indexOf(props.gist?._state?.view) > -1 && ( <> - - {props.gist.renderer === 'react' && } )} {props.gist?._state?.view === 'test' && } ) } + +// +// +//{props.gist.renderer === 'react' && } diff --git a/sites/shared/components/workbench/menu/test-design-options/index.js b/sites/shared/components/workbench/menu/test-design-options/index.mjs similarity index 89% rename from sites/shared/components/workbench/menu/test-design-options/index.js rename to sites/shared/components/workbench/menu/test-design-options/index.mjs index 4642b258b57..248dfdf5cbd 100644 --- a/sites/shared/components/workbench/menu/test-design-options/index.js +++ b/sites/shared/components/workbench/menu/test-design-options/index.mjs @@ -1,8 +1,8 @@ import { OptionsIcon } from 'shared/components/icons.mjs' -import { Chevron } from 'shared/components/navigation/primary.js' -import OptionGroup from '../design-options/option-group' -import Option from './option' -import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu' +import { Chevron } from 'shared/components/navigation/primary.mjs' +import OptionGroup from '../design-options/option-group.mjs' +import Option from './option.mjs' +import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu/index.mjs' import { useTranslation } from 'next-i18next' import { optionsMenuStructure } from 'shared/utils.mjs' import { adult, doll, giant } from '@freesewing/models' @@ -24,10 +24,12 @@ const SampleDesignOption = (props) => { ) } -const DesignOptions = (props) => { +export const TestDesignOptions = (props) => { const { t } = useTranslation(['app']) const optionsMenu = optionsMenuStructure(props.design.patternConfig.options) + // FIXME: This menu is broken right now + const measies = props.draft?.config?.measurements || [] return ( @@ -45,7 +47,7 @@ const DesignOptions = (props) => { type={options} option={group} key={group} - sampleSettings={{ type: 'option', option }} + sampleSettings={{ type: 'option', options }} /> ) : ( { ) } - -export default DesignOptions diff --git a/sites/shared/components/workbench/menu/test-design-options/option.js b/sites/shared/components/workbench/menu/test-design-options/option.mjs similarity index 65% rename from sites/shared/components/workbench/menu/test-design-options/option.js rename to sites/shared/components/workbench/menu/test-design-options/option.mjs index df939ba97b8..efa965a332a 100644 --- a/sites/shared/components/workbench/menu/test-design-options/option.js +++ b/sites/shared/components/workbench/menu/test-design-options/option.mjs @@ -1,11 +1,8 @@ -import { Li, SumButton, SumDiv } from 'shared/components/workbench/menu' +import { Li, SumButton, SumDiv } from 'shared/components/workbench/menu/index.mjs' import { useTranslation } from 'next-i18next' -const Option = props => { - const active = ( - props.sampleSettings?.type === 'option' && - props.active === props.option - ) +const Option = (props) => { + const active = props.sampleSettings?.type === 'option' && props.active === props.option const setSampleSettings = () => { props.updateGist( @@ -19,18 +16,18 @@ const Option = props => {
  • - {active ? : °} - - {props.label} - + {props.label}
  • diff --git a/sites/shared/components/workbench/menu/xray/attributes.js b/sites/shared/components/workbench/menu/xray/attributes.js deleted file mode 100644 index 01d0e272196..00000000000 --- a/sites/shared/components/workbench/menu/xray/attributes.js +++ /dev/null @@ -1,50 +0,0 @@ -import { Chevron } from 'shared/components/navigation/primary' -import { Ul, Li, Details, Summary, SumDiv, NoSumDiv, Deg } from 'shared/components/workbench/menu' - -const XrayAttributes = ({ attr=false, t }) => { - if (!attr || !attr.list || Object.keys(attr.list).length < 1) return null - - return ( -
  • -
    - - - - Attributes - - - -
      - {Object.keys(attr.list).map(at => ( -
    • -
      - - - - {at} - - - -
        - {attr.list[at].map(val => ( -
      • - - - {val === true - ? t('app.yes') - : val - } - -
      • - ))} -
      -
      -
    • - ))} -
    -
    -
  • - ) -} - -export default XrayAttributes diff --git a/sites/shared/components/workbench/menu/xray/attributes.mjs b/sites/shared/components/workbench/menu/xray/attributes.mjs new file mode 100644 index 00000000000..0126811cfb3 --- /dev/null +++ b/sites/shared/components/workbench/menu/xray/attributes.mjs @@ -0,0 +1,45 @@ +import { Chevron } from 'shared/components/navigation/primary' +import { Ul, Li, Details, Summary, SumDiv, NoSumDiv, Deg } from 'shared/components/workbench/menu' + +export const XrayAttributes = ({ attr = false, t }) => { + if (!attr || !attr.list || Object.keys(attr.list).length < 1) return null + + return ( +
  • +
    + + + + Attributes + + + +
      + {Object.keys(attr.list).map((at) => ( +
    • +
      + + + + {at} + + + +
        + {attr.list[at].map((val) => ( +
      • + + + {val === true ? t('app.yes') : val} + +
      • + ))} +
      +
      +
    • + ))} +
    +
    +
  • + ) +} diff --git a/sites/shared/components/workbench/menu/xray/disable.js b/sites/shared/components/workbench/menu/xray/disable.mjs similarity index 69% rename from sites/shared/components/workbench/menu/xray/disable.js rename to sites/shared/components/workbench/menu/xray/disable.mjs index 0b4f37782ae..4a6dadf192d 100644 --- a/sites/shared/components/workbench/menu/xray/disable.js +++ b/sites/shared/components/workbench/menu/xray/disable.mjs @@ -1,7 +1,7 @@ import { Li, SumButton, SumDiv, Deg } from 'shared/components/workbench/menu' import { useTranslation } from 'next-i18next' -const DisableXray = props => { +export const DisableXray = (props) => { const { t } = useTranslation(['cfp', 'settings']) return ( @@ -9,13 +9,9 @@ const DisableXray = props => { props.updateGist(['_state', 'xray', 'enabled'], false)}> - - {t('cfp:thingIsEnabled', { thing: t('settings:xray.t') })} - + {t('cfp:thingIsEnabled', { thing: t('settings:xray.t') })} ) } - -export default DisableXray diff --git a/sites/shared/components/workbench/menu/xray/index.js b/sites/shared/components/workbench/menu/xray/index.mjs similarity index 78% rename from sites/shared/components/workbench/menu/xray/index.js rename to sites/shared/components/workbench/menu/xray/index.mjs index d1bb754aec1..6e04f78c075 100644 --- a/sites/shared/components/workbench/menu/xray/index.js +++ b/sites/shared/components/workbench/menu/xray/index.mjs @@ -1,13 +1,13 @@ import { XrayIcon } from 'shared/components/icons.mjs' -import { linkClasses, Chevron } from 'shared/components/navigation/primary.js' -import Log from './log.js' -import Reset from './reset.js' -import Disable from './disable.js' -import List from './list.js' +import { linkClasses, Chevron } from 'shared/components/navigation/primary.mjs' +import { ConsoleLog } from './log.mjs' +import { XrayReset } from './reset.mjs' +import { XrayDisable } from './disable.mjs' +import { XrayList } from './list.mjs' import { Ul, Details, TopSummary } from 'shared/components/workbench/menu' import { useTranslation } from 'next-i18next' -const Xray = (props) => { +export const XrayMenu = (props) => { const { t } = useTranslation(['app', 'settings']) return ( @@ -36,17 +36,15 @@ const Xray = (props) => { {props.gist?._state?.xray?.enabled && (
      - - - + + + {props.gist?._state?.xray?.parts && Object.keys(props.gist._state.xray.parts).map((partName) => ( - + ))}
    )} ) } - -export default Xray diff --git a/sites/shared/components/workbench/menu/xray/list.js b/sites/shared/components/workbench/menu/xray/list.mjs similarity index 96% rename from sites/shared/components/workbench/menu/xray/list.js rename to sites/shared/components/workbench/menu/xray/list.mjs index d688f7df17c..87f39472878 100644 --- a/sites/shared/components/workbench/menu/xray/list.js +++ b/sites/shared/components/workbench/menu/xray/list.mjs @@ -1,8 +1,8 @@ -import { Chevron } from 'shared/components/navigation/primary.js' +import { Chevron } from 'shared/components/navigation/primary.mjs' import { ClearIcon, FilterIcon, SearchIcon } from 'shared/components/icons.mjs' -import { Ul, Li, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu' -import Path from './path.js' -import Point from './point.js' +import { Ul, Li, Details, Summary, SumDiv, Deg } from 'shared/components/workbench/menu/index.mjs' +import Path from './path.mjs' +import Point from './point.mjs' import { useTranslation } from 'next-i18next' const types = { @@ -10,7 +10,7 @@ const types = { points: Point, } -const XrayList = (props) => { +export const XrayList = (props) => { const { t } = useTranslation(['app', 'parts']) const title = t(`parts:${props.partName}`) + ` (${props.partName})` @@ -160,5 +160,3 @@ const XrayList = (props) => { ) } - -export default XrayList diff --git a/sites/shared/components/workbench/menu/xray/log.js b/sites/shared/components/workbench/menu/xray/log.mjs similarity index 79% rename from sites/shared/components/workbench/menu/xray/log.js rename to sites/shared/components/workbench/menu/xray/log.mjs index 308804dd5c0..6574181b186 100644 --- a/sites/shared/components/workbench/menu/xray/log.js +++ b/sites/shared/components/workbench/menu/xray/log.mjs @@ -1,7 +1,15 @@ -import { Chevron } from 'shared/components/navigation/primary.js' -import { Ul, Li, Details, Summary, SumButton, SumDiv, Deg } from 'shared/components/workbench/menu' +import { Chevron } from 'shared/components/navigation/primary.mjs' +import { + Ul, + Li, + Details, + Summary, + SumButton, + SumDiv, + Deg, +} from 'shared/components/workbench/menu/index.mjs' -const ConsoleLog = (props) => ( +export const ConsoleLog = (props) => (
  • @@ -33,5 +41,3 @@ const ConsoleLog = (props) => (
  • ) - -export default ConsoleLog diff --git a/sites/shared/components/workbench/menu/xray/path-ops.js b/sites/shared/components/workbench/menu/xray/path-ops.mjs similarity index 61% rename from sites/shared/components/workbench/menu/xray/path-ops.js rename to sites/shared/components/workbench/menu/xray/path-ops.mjs index 1498decd982..a2ef6d9fcce 100644 --- a/sites/shared/components/workbench/menu/xray/path-ops.js +++ b/sites/shared/components/workbench/menu/xray/path-ops.mjs @@ -3,25 +3,25 @@ import { Ul, Li, Details, Summary, SumDiv, NoSumDiv, Deg } from 'shared/componen import Point from './point' const MoveLine = ({ op }) => -const Curve = ({ op }) => ['cp1', 'cp2', 'to'].map(pnt => ( -
  • -
    - - - - {pnt} - - - - -
    -
  • -)) +const Curve = ({ op }) => + ['cp1', 'cp2', 'to'].map((pnt) => ( +
  • +
    + + + + {pnt} + + + + +
    +
  • + )) const XrayPathOp = ({ op }) => (
  • - {op.type === 'close' - ? ( + {op.type === 'close' ? ( {op.type} @@ -36,19 +36,13 @@ const XrayPathOp = ({ op }) => ( -
      - {op.type === 'curve' - ? - : - } -
    +
      {op.type === 'curve' ? : }
    - ) - } + )}
  • ) -const XrayPathOps = ({ ops=false }) => { +export const XrayPathOps = ({ ops = false }) => { if (!ops || ops.length < 1) return null return ( @@ -62,11 +56,11 @@ const XrayPathOps = ({ ops=false }) => {
      - {ops.map(op => )} + {ops.map((op) => ( + + ))}
    ) } - -export default XrayPathOps diff --git a/sites/shared/components/workbench/menu/xray/path.js b/sites/shared/components/workbench/menu/xray/path.mjs similarity index 63% rename from sites/shared/components/workbench/menu/xray/path.js rename to sites/shared/components/workbench/menu/xray/path.mjs index dd7bc20185b..03ab75e7a59 100644 --- a/sites/shared/components/workbench/menu/xray/path.js +++ b/sites/shared/components/workbench/menu/xray/path.mjs @@ -1,9 +1,9 @@ -import { Ul, Li, NoSumDiv, Deg } from 'shared/components/workbench/menu' -import { formatMm } from 'shared/utils' -import Attributes from './attributes' -import Ops from './path-ops' +import { Ul, Li, NoSumDiv, Deg } from 'shared/components/workbench/menu/index.mjs' +import { formatMm } from 'shared/utils.mjs' +import Attributes from './attributes.mjs' +import Ops from './path-ops.mjs' -const XrayPath = ({ pathName, partName, draft, t, units }) => { +export const XrayPath = ({ pathName, partName, draft, t, units }) => { const path = draft?.parts?.[partName]?.paths?.[pathName] if (!path) return null @@ -21,14 +21,14 @@ const XrayPath = ({ pathName, partName, draft, t, units }) => { path.length() = - + ) } - -export default XrayPath diff --git a/sites/shared/components/workbench/menu/xray/point.js b/sites/shared/components/workbench/menu/xray/point.js deleted file mode 100644 index 156e5ddc621..00000000000 --- a/sites/shared/components/workbench/menu/xray/point.js +++ /dev/null @@ -1,25 +0,0 @@ -import { Ul, Li, NoSumDiv, Deg } from 'shared/components/workbench/menu' -import { round } from 'shared/utils' -import Attributes from './attributes' - -const XrayPoint = ({ pointName, partName, draft, t }) => { - const point = draft?.parts?.[partName]?.points?.[pointName] - - return point - ? ( -
      - {['x', 'y'].map(coord => ( -
    • - - - {coord} = - {round(point[coord])} - -
    • - ))} - -
    - ) : null -} - -export default XrayPoint diff --git a/sites/shared/components/workbench/menu/xray/point.mjs b/sites/shared/components/workbench/menu/xray/point.mjs new file mode 100644 index 00000000000..8c315579a65 --- /dev/null +++ b/sites/shared/components/workbench/menu/xray/point.mjs @@ -0,0 +1,22 @@ +import { Ul, Li, NoSumDiv, Deg } from 'shared/components/workbench/menu' +import { round } from 'shared/utils' +import Attributes from './attributes' + +export const XrayPoint = ({ pointName, partName, draft, t }) => { + const point = draft?.parts?.[partName]?.points?.[pointName] + + return point ? ( +
      + {['x', 'y'].map((coord) => ( +
    • + + + {coord} = + {round(point[coord])} + +
    • + ))} + +
    + ) : null +} diff --git a/sites/shared/components/workbench/menu/xray/reset.js b/sites/shared/components/workbench/menu/xray/reset.mjs similarity index 79% rename from sites/shared/components/workbench/menu/xray/reset.js rename to sites/shared/components/workbench/menu/xray/reset.mjs index e1746ac8dbe..e9baae031d7 100644 --- a/sites/shared/components/workbench/menu/xray/reset.js +++ b/sites/shared/components/workbench/menu/xray/reset.mjs @@ -1,7 +1,7 @@ import { Li, SumButton, SumDiv, Deg } from 'shared/components/workbench/menu' import { useTranslation } from 'next-i18next' -const ResetXray = props => { +export const ResetXray = (props) => { const { t } = useTranslation(['app']) return ( @@ -9,11 +9,9 @@ const ResetXray = props => { props.updateGist(['_state', 'xray'], { enabled: true })}> - { t(`reset`) } + {t(`reset`)} ) } - -export default ResetXray diff --git a/sites/shared/components/workbench/preloaders.mjs b/sites/shared/components/workbench/preloaders.mjs new file mode 100644 index 00000000000..58cc0674572 --- /dev/null +++ b/sites/shared/components/workbench/preloaders.mjs @@ -0,0 +1,29 @@ +import yaml from 'js-yaml' +import axios from 'axios' + +export const preloaders = { + github: async (id, design) => { + let result + try { + result = await axios.get(`https://api.github.com/gists/${id}`) + } catch (err) { + console.log(err) + return [false, 'An unexpected error occured'] + } + + if (result.data.files['pattern.yaml'].content) { + let g = yaml.load(result.data.files['pattern.yaml'].content) + + if (g.design !== undefined && g.design !== design.designConfig.data.name) + return [ + false, + `You tried loading a configuration for ${g.design} into a ${design.designConfig.data.name} development environment`, + ] + + return g + } + + // TODO notify people of these errors + else return [false, 'This gist does not seem to be a valid pattern configuration'] + }, +} diff --git a/sites/shared/components/workbench/sample.mjs b/sites/shared/components/workbench/sample.mjs index 307a51ec5e0..e349142c763 100644 --- a/sites/shared/components/workbench/sample.mjs +++ b/sites/shared/components/workbench/sample.mjs @@ -1,6 +1,6 @@ import { useTranslation } from 'next-i18next' import { svgattrPlugin } from '@freesewing/plugin-svgattr' -import { SvgWrapper } from './draft/svg-wrapper.mjs' +import { SvgWrapper } from './draft/svg.mjs' import { Error } from './draft/error.mjs' export const LabSample = ({ gist, draft, updateGist, unsetGist, showInfo, app, feedback }) => { diff --git a/sites/shared/components/wrappers/workbench.mjs b/sites/shared/components/wrappers/workbench.mjs index 84e2fa77d72..3c7be6b9b09 100644 --- a/sites/shared/components/wrappers/workbench.mjs +++ b/sites/shared/components/wrappers/workbench.mjs @@ -3,25 +3,24 @@ import { useEffect, useState, useMemo } from 'react' import { useGist } from 'shared/hooks/useGist' // Dependencies import { pluginTheme } from '@freesewing/plugin-theme' -import preloaders from 'shared/components/workbench/preload.js' +import { preloaders } from 'shared/components/workbench/preloaders.mjs' // Components -import { Menu } from 'shared/components/workbench/menu/index.mjs' +import { WorkbenchMenu } from 'shared/components/workbench/menu/index.mjs' import { DraftError } from 'shared/components/workbench/draft/error.mjs' import { Modal } from 'shared/components/modal.mjs' import { ErrorBoundary } from 'shared/components/error/error-boundary.mjs' // Views -import { Measurements } from 'shared/components/workbench/measurements/index.js' -import { LabDraft } from 'shared/components/workbench/draft/index.js' -import { LabSample } from 'shared/components/workbench/sample.js' -import { ExportDraft } from 'shared/components/workbench/exporting/index.js' -import { GistAsJson } from 'shared/components/workbench/gist-as-json.js' -import { GistAsYaml } from 'shared/components/workbench/yaml.js' -import { DraftLogs } from 'shared/components/workbench/logs.js' -import { CutLayout } from 'shared/components/workbench/layout/cut' -import { PrintingLayout } from 'shared/components/workbench/layout/print' +import { WorkbenchMeasurements } from 'shared/components/workbench/measurements/index.mjs' +import { LabDraft } from 'shared/components/workbench/draft/index.mjs' +import { LabSample } from 'shared/components/workbench/sample.mjs' +import { ExportDraft } from 'shared/components/workbench/exporting/index.mjs' +import { GistAsJson, GistAsYaml } from 'shared/components/workbench/gist.mjs' +import { DraftLogs } from 'shared/components/workbench/logs.mjs' +import { CutLayout } from 'shared/components/workbench/layout/cut/index.mjs' +import { PrintingLayout } from 'shared/components/workbench/layout/print/index.mjs' const views = { - measurements: Measurements, + measurements: WorkbenchMeasurements, draft: LabDraft, test: LabSample, printingLayout: PrintingLayout, @@ -156,7 +155,7 @@ export const WorkbenchWrapper = ({ app: app, noSearch: true, workbench: true, - AltMenu: , + AltMenu: , showInfo: setPopup, } diff --git a/sites/shared/prebuild/lab.mjs b/sites/shared/prebuild/lab.mjs index 6c453ec494b..96c206b9411 100644 --- a/sites/shared/prebuild/lab.mjs +++ b/sites/shared/prebuild/lab.mjs @@ -16,12 +16,12 @@ const header = `/* * */` -const pageTemplate = design => `${header} +const pageTemplate = (design) => `${header} import { ${capitalize(design)} } from 'designs/${design}/src/index.mjs' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' -import PageTemplate from 'site/page-templates/workbench.mjs' +import { WorkbenchPage } from 'site/page-templates/workbench.mjs' -const Page = (props) => +const Page = (props) => export default Page export async function getStaticProps({ locale }) { @@ -49,21 +49,16 @@ export const prebuildLab = async (site) => { const pages = ['..', 'lab', 'pages'] await fs.mkdir(path.resolve(...pages, 'v', 'next'), { recursive: true }) promises.push( - fs.writeFile( - path.resolve(...pages, `${design}.mjs`), - page - ), - fs.writeFile( - path.resolve(...pages, section, `${design}.mjs`), - page - ), + fs.writeFile(path.resolve(...pages, `${design}.mjs`), page), + fs.writeFile(path.resolve(...pages, section, `${design}.mjs`), page) ) } } // Write designs file - const header = "// This file is auto-generated by the prebuild script | Any changes will be overwritten\n" - const nl = "\n" + const header = + '// This file is auto-generated by the prebuild script | Any changes will be overwritten\n' + const nl = '\n' promises.push( fs.writeFile( path.resolve('..', 'lab', 'prebuild', 'designs.mjs'), @@ -76,10 +71,8 @@ export const prebuildLab = async (site) => { fs.writeFile( path.resolve('..', 'lab', 'prebuild', 'designs-by-type.mjs'), `${header}export const designsByType = ${JSON.stringify(designsByType)}${nl}` - ), + ) ) await Promise.all(promises) } - - diff --git a/sites/shared/utils.mjs b/sites/shared/utils.mjs index cddd4a19457..2b6e28b1a93 100644 --- a/sites/shared/utils.mjs +++ b/sites/shared/utils.mjs @@ -175,7 +175,7 @@ export const optionsMenuStructure = (options) => { else if (typeof option.menu === 'undefined') console.log( `Warning: Option ${option.name} does not have a menu config. ` + - 'Either configure it, or set it to falseo false to hide this option.' + 'Either configure it, or set it to false to hide this option.' ) } }