diff --git a/sites/shared/components/workbench/measurements/index.js b/sites/shared/components/workbench/measurements/index.js
index 5dcf094aa89..cb92f2945b6 100644
--- a/sites/shared/components/workbench/measurements/index.js
+++ b/sites/shared/components/workbench/measurements/index.js
@@ -1,33 +1,33 @@
import React, {useMemo, useEffect, useState} from 'react'
import MeasurementInput from '../inputs/measurement.js'
-import { withBreasts, withoutBreasts } from '@freesewing/models'
+import { menswear, womenswear } from '@freesewing/models'
import nonHuman from './non-human.js'
-import WithBreastsIcon from 'shared/components/icons/with-breasts.js'
-import WithoutBreastsIcon from 'shared/components/icons/without-breasts.js'
+import WomenswearIcon from 'shared/components/icons/womenswear.js'
+import MenswearIcon from 'shared/components/icons/menswear.js'
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'
+
const groups = {
- people: {
- with: withBreasts,
- without: withoutBreasts,
- },
+ people: { menswear, womenswear },
dolls: {
- with: nonHuman.withBreasts.dolls,
- without: nonHuman.withoutBreasts.dolls,
+ menswear: nonHuman.menswear.dolls,
+ womenswear: nonHuman.womenswear.dolls,
},
giants: {
- with: nonHuman.withBreasts.giants,
- without: nonHuman.withoutBreasts.giants,
+ menswear: nonHuman.menswear.giants,
+ womenswear: nonHuman.womenswear.giants,
}
}
+
const icons = {
- with:
,
- without:
,
+ menswear:
,
+ womenswear:
,
}
+
const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) => {
const { t } = useTranslation(['app', 'cfp'])
@@ -72,7 +72,7 @@ const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) =>
{Object.keys(icons).map(type => (
- {t(`${type}Breasts`)}
+ {t(type)}
{Object.keys(groups[group][type]).map((m) => (
-
@@ -81,9 +81,8 @@ const WorkbenchMeasurements = ({ app, design, gist, updateGist, gistReady }) =>
onClick={() => updateMeasurements(groups[group][type][m], false)}
>
{icons[type]}
- {t('size')}
{ group === 'people'
- ? m.replace('size', '')
+ ? m.slice(-2)
: m
}
diff --git a/sites/shared/components/workbench/measurements/non-human.js b/sites/shared/components/workbench/measurements/non-human.js
index 78fdf30dac9..2b613c68611 100644
--- a/sites/shared/components/workbench/measurements/non-human.js
+++ b/sites/shared/components/workbench/measurements/non-human.js
@@ -1,11 +1,11 @@
-import { withBreasts, withoutBreasts } from '@freesewing/models'
+import { menswear42, womenswear34 } from '@freesewing/models'
const nonHuman = {
- withoutBreasts: {
+ menswear: {
dolls: {},
giants: {}
},
- withBreasts: {
+ womenswear: {
dolls: {},
giants: {}
}
@@ -14,34 +14,34 @@ 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.withBreasts.dolls[name] = {}
- // withBreasts: Based on Anneke (size 34)
- for (const [m, val] of Object.entries(withBreasts.size34)) {
- nonHuman.withBreasts.dolls[name][m] = (m === 'shoulderSlope')
+ 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)
}
- // withoutBreasts: Based on Ronan (size 42)
- nonHuman.withoutBreasts.dolls[name] = {}
- for (const [m, val] of Object.entries(withoutBreasts.size42)) {
- nonHuman.withoutBreasts.dolls[name][m] = (m === 'shoulderSlope')
+ 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)
}
}
for (let i=1.5;i<=3;i+=0.5) {
const name = `${i}/1`
- nonHuman.withBreasts.giants[name] = {}
- // withBreasts: Based on Anneke (size 34)
- for (const [m, val] of Object.entries(withBreasts.size34)) {
- nonHuman.withBreasts.giants[name][m] = (m === 'shoulderSlope')
+ 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.withoutBreasts.giants[name] = {}
- // withoutBreasts: Based on Ronan (size 42)
- for (const [m, val] of Object.entries(withoutBreasts.size42)) {
- nonHuman.withoutBreasts.giants[name][m] = (m === 'shoulderSlope')
+ 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)
}
diff --git a/sites/shared/components/workbench/menu/design-options/index.js b/sites/shared/components/workbench/menu/design-options/index.js
index 2a78ebcdd80..a5327236bf3 100644
--- a/sites/shared/components/workbench/menu/design-options/index.js
+++ b/sites/shared/components/workbench/menu/design-options/index.js
@@ -3,9 +3,11 @@ import { Chevron } from 'shared/components/navigation/primary.js'
import OptionGroup from './option-group'
import { Ul, Details, TopSummary, TopSumTitle } from 'shared/components/workbench/menu'
import { useTranslation } from 'next-i18next'
+import { optionsMenuStructure } from 'shared/utils.mjs'
const DesignOptions = props => {
const { t } = useTranslation(['app'])
+ const optionsMenu = optionsMenuStructure(props.design.config.options)
return (
@@ -14,12 +16,14 @@ const DesignOptions = props => {
- {Object.keys(props.design.config.optionGroups).map(group => (
-
- ))}
+ {Object.entries(optionsMenu).map(([group, options]) => typeof options === "string"
+ ? top-level option
+ :
+ )}
)
}
export default DesignOptions
+
diff --git a/sites/shared/components/workbench/menu/design-options/option-group.js b/sites/shared/components/workbench/menu/design-options/option-group.js
index 71628691f77..64250f266c3 100644
--- a/sites/shared/components/workbench/menu/design-options/option-group.js
+++ b/sites/shared/components/workbench/menu/design-options/option-group.js
@@ -5,7 +5,7 @@ import { useTranslation } from 'next-i18next'
const OptionGroup = props => {
const { t } = useTranslation(['optiongroups'])
- const config = props.config || props.design.config.optionGroups[props.group]
+
return (
-
@@ -19,10 +19,10 @@ const OptionGroup = props => {
- {config.map(option =>
- typeof option === 'string' ?
- : Object.keys(option).map((sub) => )
- )}
+ {Object.entries(props.options).map(([option, type]) => typeof type === "string"
+ ?
+ : )
+ }
diff --git a/sites/shared/components/wrappers/workbench.js b/sites/shared/components/wrappers/workbench.js
index 40c9f3876b9..87fd614c25f 100644
--- a/sites/shared/components/wrappers/workbench.js
+++ b/sites/shared/components/wrappers/workbench.js
@@ -12,7 +12,7 @@ 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/json.js'
+import GistAsJson from 'shared/components/workbench/gist-as-json.js'
import GistAsYaml from 'shared/components/workbench/yaml.js'
import DraftEvents from 'shared/components/workbench/events.js'
import CutLayout from 'shared/components/workbench/layout/cut'
diff --git a/sites/shared/prebuild/lab.mjs b/sites/shared/prebuild/lab.mjs
index c3b72ae44c2..6c453ec494b 100644
--- a/sites/shared/prebuild/lab.mjs
+++ b/sites/shared/prebuild/lab.mjs
@@ -1,7 +1,7 @@
import fs_ from 'fs'
import path from 'path'
import { capitalize } from '../utils.mjs'
-import { designsByType } from '../../../config/software/index.mjs'
+import { designsByType, plugins, designs } from '../../../config/software/index.mjs'
const fs = fs_.promises
@@ -43,7 +43,6 @@ export const prebuildLab = async (site) => {
// Iterate over sections
console.log(`Generating pages for ${section} designs`)
for (const design in designsByType[section]) {
-
// Generate pattern pages for next
console.log(` - ${design}`)
const page = pageTemplate(design)
@@ -62,6 +61,24 @@ export const prebuildLab = async (site) => {
}
}
+ // Write designs file
+ 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'),
+ `${header}export const designs = ${JSON.stringify(Object.keys(designs))}${nl}`
+ ),
+ fs.writeFile(
+ path.resolve('..', 'lab', 'prebuild', 'plugins.mjs'),
+ `${header}export const plugins = ${JSON.stringify(Object.keys(plugins))}${nl}`
+ ),
+ 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 22a4065eaa9..07c53d86590 100644
--- a/sites/shared/utils.mjs
+++ b/sites/shared/utils.mjs
@@ -1,4 +1,5 @@
import get from 'lodash.get'
+import set from 'lodash.set'
// Generic rounding method
export const round = (val, decimals=1) => Math.round(val*Math.pow(10, decimals))/Math.pow(10, decimals)
@@ -159,3 +160,16 @@ export const measurementAsMm = (value, units = "metric") => {
}
return false;
}
+
+export const optionsMenuStructure = options => {
+ if (!options) return options
+ const menu = {}
+ for (const [name, option] of Object.entries(options)) {
+ if (typeof option === 'object') {
+ set(menu, (option.menu ? `${option.menu}.${name}` : name), optionType(option))
+ }
+ }
+
+ return menu
+}
+