diff --git a/packages/freesewing.shared/components/workbench/input-measurement.js b/packages/freesewing.shared/components/workbench/input-measurement.js
index d3a4ecd4ebd..85771b5c6f6 100644
--- a/packages/freesewing.shared/components/workbench/input-measurement.js
+++ b/packages/freesewing.shared/components/workbench/input-measurement.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react'
+import React, { useState, useEffect } from 'react'
/*
* This is a single input for a measurements
@@ -11,7 +11,6 @@ import React, { useState } from 'react'
const MeasurementInput = ({ m, gist, app, updateMeasurements }) => {
const prefix = (app.site === 'org') ? '' : 'https://freesewing.org'
const title = app.t(`measurements.${m}`)
- console.log('render', m)
const isValid = input => {
if (input === null || input === '') return null
return !isNaN(input)
@@ -23,7 +22,7 @@ const MeasurementInput = ({ m, gist, app, updateMeasurements }) => {
console.log({ok})
if (ok) {
setValid(true)
- updateMeasurements(evt.target.value, m)
+ updateMeasurements(evt.target.value*10, m)
} else setValid(false)
}
@@ -33,6 +32,11 @@ const MeasurementInput = ({ m, gist, app, updateMeasurements }) => {
isValid(gist.measurements[m])
)
+ useEffect(() => {
+ console.log(gist.measurements)
+ if (gist?.measurements?.[m]) setVal(gist.measurements[m]/10)
+ }, [gist])
+
if (!m) return null
return (
diff --git a/packages/freesewing.shared/components/workbench/measurements.js b/packages/freesewing.shared/components/workbench/measurements.js
index 7337fea8c3e..561dbbd947a 100644
--- a/packages/freesewing.shared/components/workbench/measurements.js
+++ b/packages/freesewing.shared/components/workbench/measurements.js
@@ -1,4 +1,27 @@
import MeasurementInput from './input-measurement.js'
+import { withBreasts, withoutBreasts } from 'pkgs/models/src/index.js'
+import nonHuman from './non-human-measurements.js'
+import WithBreastsIcon from 'shared/components/icons/with-breasts.js'
+import WithoutBreastsIcon from 'shared/components/icons/without-breasts.js'
+
+const groups = {
+ people: {
+ with: withBreasts,
+ without: withoutBreasts,
+ },
+ dolls: {
+ with: nonHuman.withBreasts.dolls,
+ without: nonHuman.withoutBreasts.dolls,
+ },
+ giants: {
+ with: nonHuman.withBreasts.giants,
+ without: nonHuman.withoutBreasts.giants,
+ }
+}
+const icons = {
+ with: ,
+ without: ,
+}
const WorkbenchMeasurements = ({ app, pattern, gist, updateGist }) => {
@@ -6,10 +29,11 @@ const WorkbenchMeasurements = ({ app, pattern, gist, updateGist }) => {
const updateMeasurements = (value, m=false) => {
if (m === false) {
// Set all measurements
+ updateGist('measurements', value)
} else {
// Set one measurement
const newValues = {...gist.measurements}
- newValues[m] = value.trim()
+ newValues[m] = value
updateGist('measurements', newValues)
}
}
@@ -24,22 +48,63 @@ const WorkbenchMeasurements = ({ app, pattern, gist, updateGist }) => {
{app.t('measurements')}
- {pattern.config.measurements && (
- <>
-
{app.t('requiredMeasurements')}
- {pattern.config.measurements.map(m => (
-
+
+ {app.t('cfp.preloadMeasurements')}
+
+ {Object.keys(groups).map(group => (
+
+ {app.t(`app.${group}`)}
+
+ {Object.keys(icons).map(type => (
+ <>
+
{app.t(`app.${type}Breasts`)}
+
+ {Object.keys(groups[group][type]).map((m) => (
+ -
+
+
+ ))}
+
+ >
+ ))}
+
+
))}
- >
- )}
- {pattern.config.optionalMeasurements && (
- <>
-
{app.t('optionalMeasurements')}
- {pattern.config.optionalMeasurements.map(m => (
-
- ))}
- >
- )}
+
+
+
+
+ {app.t('cfp.enterMeasurements')}
+
+ {pattern.config.measurements && (
+ <>
+
{app.t('requiredMeasurements')}
+ {pattern.config.measurements.map(m => (
+
+ ))}
+ >
+ )}
+ {pattern.config.optionalMeasurements && (
+ <>
+ {app.t('optionalMeasurements')}
+ {pattern.config.optionalMeasurements.map(m => (
+
+ ))}
+ >
+ )}
+
+
+
)
}
diff --git a/packages/freesewing.shared/components/workbench/menu.js b/packages/freesewing.shared/components/workbench/menu.js
index 8b077585597..43a63d645b4 100644
--- a/packages/freesewing.shared/components/workbench/menu.js
+++ b/packages/freesewing.shared/components/workbench/menu.js
@@ -3,51 +3,111 @@ import Link from 'next/link'
import orderBy from 'lodash.orderby'
import OptionsIcon from 'shared/components/icons/options.js'
import SettingsIcon from 'shared/components/icons/settings.js'
+import MenuIcon from 'shared/components/icons/menu.js'
import { linkClasses, Chevron } from 'shared/components/navigation/primary.js'
-const structure = (pattern, app) => ({
- modes: [
- { title: `Draft ${pattern.config.name}`, action: '' },
- ],
- options: [
- { title: `Draft ${pattern.config.name}`, action: '' },
- ],
- settings: [
- { title: `Draft ${pattern.config.name}`, action: '' },
- ],
+// Component that renders a sublevel of navigation
+const ModeButtons = props => props.children.length === 0
+ ? null
+ : (
+
+ {props.children.map(mode => (
+ -
+
+
+ ))}
+
+ )
+
+const groupMaker = (t, setMode, pattern) => ({
+ modes: {
+ icon: ,
+ title: t('app.modes'),
+ children: [
+ {
+ name: 'measurements',
+ title: t('app.measurements'),
+ onClick: () => setMode('measurements')
+ },
+ {
+ name: 'draft',
+ title: t('app.draftThing', { thing: pattern }),
+ onClick: () => setMode('draft')
+ },
+ {
+ name: 'test',
+ title: t('app.testThing', { thing: pattern }),
+ onClick: () => setMode('test')
+ },
+ {
+ name: 'export',
+ title: t('app.export'),
+ onClick: () => setMode('export')
+ },
+ ]
+ },
+ toggles: {
+ icon: ,
+ title: `${t('cfp.turnOn')} / ${t('cfp.turnOff')}`,
+ },
+ options: {
+ icon: ,
+ title: t('app.designOptions'),
+ },
+ settings: {
+ icon: ,
+ title: t('app.settings')
+ },
})
-const TopLevel = ({ icon, title }) => (
-
-
- {icon}
-
- {title}
-
-
-
- fixme
-
-)
-
-const Menu = ({ app, pattern }) => ([
- } pattern={pattern} />,
- } pattern={pattern} />,
- } pattern={pattern} />,
- } pattern={pattern} />,
-])
-
-const WorkbenchMenu = ({ app, pattern }) => (
-
-)
+const WorkbenchMenu = props => {
+ const groups = groupMaker(props.app.t, props.setMode, props.pattern)
+ return (
+
+ )
+}
export default WorkbenchMenu
diff --git a/packages/freesewing.shared/components/workbench/non-human-measurements.js b/packages/freesewing.shared/components/workbench/non-human-measurements.js
new file mode 100644
index 00000000000..78fdf30dac9
--- /dev/null
+++ b/packages/freesewing.shared/components/workbench/non-human-measurements.js
@@ -0,0 +1,51 @@
+import { withBreasts, withoutBreasts } from '@freesewing/models'
+
+const nonHuman = {
+ withoutBreasts: {
+ dolls: {},
+ giants: {}
+ },
+ withBreasts: {
+ dolls: {},
+ giants: {}
+ }
+}
+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')
+ ? 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')
+ ? 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')
+ ? 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')
+ ? val
+ : round(val * i)
+ }
+}
+
+export default nonHuman
+
diff --git a/packages/freesewing.shared/components/wrappers/workbench.js b/packages/freesewing.shared/components/wrappers/workbench.js
index 9817ab7f3df..b1bc8ba9156 100644
--- a/packages/freesewing.shared/components/wrappers/workbench.js
+++ b/packages/freesewing.shared/components/wrappers/workbench.js
@@ -62,7 +62,7 @@ const WorkbenchWrapper = ({ app, pattern }) => {
app: app,
noSearch: true,
workbench: true,
- AltMenu: Menu
+ AltMenu:
}
return (
@@ -75,7 +75,6 @@ const WorkbenchWrapper = ({ app, pattern }) => {
updateGist={updateGist}
/>
)}
- {JSON.stringify(gist, null, 2)}
)
}