From 8d74e42d49e191d647b461f8330a0a0ec803385e Mon Sep 17 00:00:00 2001 From: joostdecock Date: Fri, 22 Sep 2023 19:06:29 +0200 Subject: [PATCH] chore(hortensia): Utilize expand for all reactangles and camelCase stuff --- designs/hortensia/i18n/en.json | 30 ++++++----- designs/hortensia/src/bottompanel.mjs | 50 ++++++++++++++++--- designs/hortensia/src/bottomsidepanel.mjs | 2 +- designs/hortensia/src/frontpanel.mjs | 42 +++++++++++++--- designs/hortensia/src/index.mjs | 22 ++++---- designs/hortensia/src/sidepanel.mjs | 10 ++-- .../hortensia/src/sidepanelreinforcement.mjs | 14 +++--- designs/hortensia/src/strap.mjs | 33 ++++++++---- designs/hortensia/src/zipperpanel.mjs | 17 ++++--- 9 files changed, 152 insertions(+), 68 deletions(-) diff --git a/designs/hortensia/i18n/en.json b/designs/hortensia/i18n/en.json index f9523f8c863..4e2b5f00af2 100644 --- a/designs/hortensia/i18n/en.json +++ b/designs/hortensia/i18n/en.json @@ -4,23 +4,29 @@ "p": { "top": "Top", "bottom": "Bottom", - "bottompanel": "Bottom panel", - "frontpanel": "Front panel", - "sidepanel": "Side panel", - "sidepanelreinforcement": "Side panel reinforcement", + "bottomPanel": "Bottom panel", + "frontPanel": "Front panel", + "sidePanel": "Side panel", + "sidePanelReinforcement": "Side panel reinforcement", "strap": "Strap", - "zipperpanel": "Zipper panel" + "zipperPanel": "Zipper panel" }, "s": { - "SidePanel": "Side Panel", - "FrontBackPanel": "Front and Back Panel", - "BottomPanel": "Bottom Panel", - "ZipperPanel": "Zipper Panel", - "Strap": "Handle", + "cutBottomPanel.t": "The bottom panel is not shown", + "cutBottomPanel.d": "The **Bottom panel** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 1 from the main fabric, and 1 from the lining fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.", + "cutFrontPanel.t": "The front panel is not shown", + "cutFrontPanel.d": "The **Front panel** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 2 from the main fabric, and 2 from the lining fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.", + "cutStrap.t": "The strap is not shown", + "cutStrap.d": "The **Strap** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 2 from the main fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.", + "cutStrapReducedSa.t": "The strap is not shown (and has reduced seam allowance)", + "cutStrapReducedSa.d": "The **Strap** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes a reduced seam allowance of 80% of the strap width). You need to cut 2 from the main fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.", + "cutZipperPanel.t": "The zipper panel is not shown", + "cutZipperPanel.d": "The **Zipper panel** is a rectangular of {{{ width }}} wide and {{{ length }}} long (this includes seam allowance). You need to cut 1 from the main fabric. \n\nThis part is not shown because the **expand** core setting is currently disabled. Enable it to show this pattern part.", "strapLength": "Length of the handles", + "strapSaReduced.t": "The strap seam allowance is reduced", + "strapSaReduced.d": "Because of how narrow the strap is, we have reduced the seam allowance on it to be 80% of the strap width", "handleWidth": "Width of the handles", - "zipperSize": "Standard zipper size", - "SidePanelReinforcement": "Side Reinforcement Panel" + "zipperSize": "Standard zipper size" }, "o": { "size": { diff --git a/designs/hortensia/src/bottompanel.mjs b/designs/hortensia/src/bottompanel.mjs index 10cb4bf30fe..d8b95f016b2 100644 --- a/designs/hortensia/src/bottompanel.mjs +++ b/designs/hortensia/src/bottompanel.mjs @@ -1,12 +1,50 @@ -import { sidepanel } from './sidepanel.mjs' +import { sidePanel } from './sidepanel.mjs' -export const bottompanel = { - name: 'hortensia.bottompanel', - after: sidepanel, - draft: ({ store, options, Point, Path, points, paths, Snippet, snippets, sa, macro, part }) => { +export const bottomPanel = { + name: 'hortensia.bottomPanel', + after: sidePanel, + draft: ({ + store, + expand, + units, + options, + Point, + Path, + points, + paths, + Snippet, + snippets, + sa, + macro, + part, + }) => { const w = store.get('bottomPanelLength') const h = store.get('depth') + if (expand) { + store.flag.preset('expandIsOn') + } else { + // Expand is off, do not draw the part but flag this to the user + store.flag.note({ + msg: `hortensia:cutBottomPanel`, + replace: { + width: units(w + 2 * sa), + length: units(h + 2 * sa), + }, + suggest: { + text: 'flag:show', + icon: 'expand', + update: { + settings: ['expand', 1], + }, + }, + }) + // Also hint about expand + store.flag.preset('expandIsOff') + + return part.hide() + } + points.topLeft = new Point(0, 0) points.topRight = new Point(w, 0) points.bottomLeft = new Point(0, h) @@ -33,7 +71,7 @@ export const bottompanel = { macro('title', { at: points.title, nr: 3, - title: 'BottomPanel', + title: 'bottomPanel', align: 'center', }) diff --git a/designs/hortensia/src/bottomsidepanel.mjs b/designs/hortensia/src/bottomsidepanel.mjs index afab0248ad5..989b621d4e7 100644 --- a/designs/hortensia/src/bottomsidepanel.mjs +++ b/designs/hortensia/src/bottomsidepanel.mjs @@ -1,4 +1,4 @@ -export function bottomsidepanel(points, topMiddle, w, h, sizeRatio) { +export function bottomSidePanel(points, topMiddle, w, h, sizeRatio) { const c = 0.551915024494 // circle constant const cornerCP = 20 * sizeRatio diff --git a/designs/hortensia/src/frontpanel.mjs b/designs/hortensia/src/frontpanel.mjs index dbdd702a632..5baa4bed5bc 100644 --- a/designs/hortensia/src/frontpanel.mjs +++ b/designs/hortensia/src/frontpanel.mjs @@ -1,8 +1,8 @@ -import { sidepanel } from './sidepanel.mjs' +import { sidePanel } from './sidepanel.mjs' -export const frontpanel = { - name: 'hortensia.frontpanel', - after: sidepanel, +export const frontPanel = { + name: 'hortensia.frontPanel', + after: sidePanel, options: { minHandleSpaceWidth: 80, maxHandleSpaceWidth: 250, @@ -21,12 +21,38 @@ export const frontpanel = { Snippet, snippets, sa, + expand, + units, macro, part, }) => { const w = store.get('frontPanelLength') const h = store.get('depth') + if (expand) { + store.flag.preset('expandIsOn') + } else { + // Expand is off, do not draw the part but flag this to the user + store.flag.note({ + msg: `hortensia:cutFrontPanel`, + replace: { + width: units(w + 2 * sa), + length: units(h + 2 * sa), + }, + suggest: { + text: 'flag:show', + icon: 'expand', + update: { + settings: ['expand', 1], + }, + }, + }) + // Also hint about expand + store.flag.preset('expandIsOff') + + return part.hide() + } + points.topLeft = new Point(0, 0) points.topRight = new Point(w, 0) points.bottomLeft = new Point(0, h) @@ -86,8 +112,10 @@ export const frontpanel = { id: 'att2', }) - store.cutlist.addCut({ cut: 2, from: 'fabric' }) - store.cutlist.addCut({ cut: 2, material: 'lining' }) + store.cutlist.setCut([ + { cut: 2, from: 'fabric' }, + { cut: 2, from: 'lining' }, + ]) points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) snippets.logo = new Snippet('logo', points.logo) @@ -98,7 +126,7 @@ export const frontpanel = { macro('title', { at: points.title, nr: 2, - title: 'FrontPanel', + title: 'frontPanel', align: 'center', }) diff --git a/designs/hortensia/src/index.mjs b/designs/hortensia/src/index.mjs index 1b954e73c30..24c27502460 100644 --- a/designs/hortensia/src/index.mjs +++ b/designs/hortensia/src/index.mjs @@ -2,26 +2,26 @@ import { Design } from '@freesewing/core' import { data } from '../data.mjs' import { i18n } from '../i18n/index.mjs' // Parts -import { sidepanel } from './sidepanel.mjs' -import { frontpanel } from './frontpanel.mjs' -import { bottompanel } from './bottompanel.mjs' -import { zipperpanel } from './zipperpanel.mjs' -import { sidepanelreinforcement } from './sidepanelreinforcement.mjs' +import { sidePanel } from './sidepanel.mjs' +import { frontPanel } from './frontpanel.mjs' +import { bottomPanel } from './bottompanel.mjs' +import { zipperPanel } from './zipperpanel.mjs' +import { sidePanelReinforcement } from './sidepanelreinforcement.mjs' import { strap } from './strap.mjs' // Create new design const Hortensia = new Design({ data, - parts: [sidepanel, frontpanel, bottompanel, zipperpanel, sidepanelreinforcement, strap], + parts: [sidePanel, frontPanel, bottomPanel, zipperPanel, sidePanelReinforcement, strap], }) // Named exports export { - sidepanel, - frontpanel, - bottompanel, - zipperpanel, - sidepanelreinforcement, + sidePanel, + frontPanel, + bottomPanel, + zipperPanel, + sidePanelReinforcement, strap, Hortensia, i18n, diff --git a/designs/hortensia/src/sidepanel.mjs b/designs/hortensia/src/sidepanel.mjs index 01eedaa5646..15d877f19ac 100644 --- a/designs/hortensia/src/sidepanel.mjs +++ b/designs/hortensia/src/sidepanel.mjs @@ -1,11 +1,11 @@ -import { bottomsidepanel } from './bottomsidepanel.mjs' +import { bottomSidePanel } from './bottomsidepanel.mjs' // Default width and height: const width = 230 const height = 330 -export const sidepanel = { - name: 'hortensia.sidepanel', +export const sidePanel = { + name: 'hortensia.sidePanel', options: { width, height, @@ -80,7 +80,7 @@ export const sidepanel = { points.topMiddleCPL = points.topMiddle.shift(180, topCP) points.topMiddleCPR = points.topMiddle.shift(0, topCP * 1.1) - bottomsidepanel(points, points.topMiddle, w, h, sizeRatio) + bottomSidePanel(points, points.topMiddle, w, h, sizeRatio) points.shoulderLeft = points.bottomLeft.shift(90, sideLength) points.shoulderLeftCP = points.shoulderLeft.shift(90, shoulderCP) @@ -155,7 +155,7 @@ export const sidepanel = { macro('title', { at: points.title, nr: 1, - title: 'sidepanel', + title: 'sidePanel', align: 'center', }) diff --git a/designs/hortensia/src/sidepanelreinforcement.mjs b/designs/hortensia/src/sidepanelreinforcement.mjs index 52cc3271a44..57e4e0e870c 100644 --- a/designs/hortensia/src/sidepanelreinforcement.mjs +++ b/designs/hortensia/src/sidepanelreinforcement.mjs @@ -1,9 +1,9 @@ -import { sidepanel } from './sidepanel.mjs' -import { bottomsidepanel } from './bottomsidepanel.mjs' +import { sidePanel } from './sidepanel.mjs' +import { bottomSidePanel } from './bottomsidepanel.mjs' -export const sidepanelreinforcement = { - name: 'hortensia.sidepanelreinforcement', - after: sidepanel, +export const sidePanelReinforcement = { + name: 'hortensia.sidePanelReinforcement', + after: sidePanel, draft: ({ store, Point, Path, points, paths, sa, macro, part }) => { const w = store.get('width') const h = store.get('sidePanelReinforcementHeight') @@ -13,7 +13,7 @@ export const sidepanelreinforcement = { points.topLeft = points.topMiddle.shift(180, w / 2) points.topRight = points.topMiddle.shift(0, w / 2) - bottomsidepanel(points, points.topMiddle, w, h, sizeRatio) + bottomSidePanel(points, points.topMiddle, w, h, sizeRatio) paths.seam = new Path() .move(points.topMiddle) @@ -35,7 +35,7 @@ export const sidepanelreinforcement = { macro('title', { at: points.title, nr: 4, - title: 'sidepanelreinforcement', + title: 'sidePanelReinforcement', scale: 0.25, align: 'center', }) diff --git a/designs/hortensia/src/strap.mjs b/designs/hortensia/src/strap.mjs index 203a9093b8d..5a8ca133e2d 100644 --- a/designs/hortensia/src/strap.mjs +++ b/designs/hortensia/src/strap.mjs @@ -1,8 +1,8 @@ -import { sidepanel } from './sidepanel.mjs' +import { sidePanel } from './sidepanel.mjs' export const strap = { name: 'hortensia.strap', - after: sidepanel, + after: sidePanel, options: { strapLength: { pct: 160, min: 75, max: 250, menu: 'style' }, handleWidth: { pct: 8.6, min: 4, max: 25, menu: 'style' }, @@ -11,13 +11,28 @@ export const strap = { const w = store.get('width') * options.handleWidth const h = store.get('depth') * options.strapLength - if (!expand) { + let reducedSa = false + if (sa > w * 0.8) { + sa = w * 0.8 + reducedSa = true + + store.flag.warn({ + msg: `hortensia:strapSaReduced`, + replace: { + width: units(w + 2 * sa), + length: units(h + 2 * sa), + }, + }) + } + + if (expand) store.flag.preset('expandIsOn') + else { // Expand is on, do not draw the part but flag this to the user store.flag.note({ - msg: `hortensia:strap`, + msg: reducedSa ? `hortensia:cutStrapReducedSa` : `hortensia:cutStrap`, replace: { - width: units(w), - length: units(h), + width: units(w + 2 * sa), + length: units(h + 2 * sa), }, suggest: { text: 'flag:show', @@ -28,15 +43,11 @@ export const strap = { }, }) // Also hint about expand - store.flag.preset('expand') + store.flag.preset('expandIsOff') return part.hide() } - if (sa > w * 0.8) { - sa = w * 0.8 - } - points.topLeft = new Point(-w, 0) points.topMiddle = new Point(0, 0) points.topRight = new Point(w, 0) diff --git a/designs/hortensia/src/zipperpanel.mjs b/designs/hortensia/src/zipperpanel.mjs index 5418b0948ad..d420f5f1458 100644 --- a/designs/hortensia/src/zipperpanel.mjs +++ b/designs/hortensia/src/zipperpanel.mjs @@ -1,17 +1,18 @@ -import { sidepanel } from './sidepanel.mjs' +import { sidePanel } from './sidepanel.mjs' -export const zipperpanel = { - name: 'hortensia.zipperpanel', - after: sidepanel, +export const zipperPanel = { + name: 'hortensia.zipperPanel', + after: sidePanel, draft: ({ store, Point, Path, points, paths, sa, macro, expand, units, part }) => { const z = store.get('zipperWidth') const w = (store.get('zipperPanelWidth') - z) / 2 const h = store.get('depth') - if (!expand) { - // Expand is on, do not draw the part but flag this to the user + if (expand) store.flag.preset('expandIsOn') + else { + // Expand is off, do not draw the part but flag this to the user store.flag.note({ - msg: `hortensia:zipperpanel`, + msg: `hortensia:cutZipperPanel`, replace: { width: units(w), length: units(h), @@ -25,7 +26,7 @@ export const zipperpanel = { }, }) // Also hint about expand - store.flag.preset('expand') + store.flag.preset('expandIsOff') return part.hide() }