From 3e8c23a2cea03bcaf594dbc0e73c7d4d82f31add Mon Sep 17 00:00:00 2001 From: joostdecock Date: Sat, 3 Sep 2022 17:20:29 +0200 Subject: [PATCH] chore(teagan): Ported to v3 --- designs/teagan/config/index.js | 60 ---------------------------------- designs/teagan/src/back.mjs | 12 +++++-- designs/teagan/src/front.mjs | 32 ++++++++++++++++-- designs/teagan/src/index.mjs | 51 +++++++---------------------- designs/teagan/src/sleeve.mjs | 15 +++++++-- 5 files changed, 64 insertions(+), 106 deletions(-) delete mode 100644 designs/teagan/config/index.js diff --git a/designs/teagan/config/index.js b/designs/teagan/config/index.js deleted file mode 100644 index 43b967a374b..00000000000 --- a/designs/teagan/config/index.js +++ /dev/null @@ -1,60 +0,0 @@ -import { config as brianConfig } from '@freesewing/brian' -import pkg from '../package.json' assert { type: 'json' } - -const { version } = pkg - -const config = { - version, - name: 'teagan', - design: 'Joost De Cock', - code: 'Joost De Cock', - department: 'tops', - type: 'pattern', - difficulty: 2, - optionGroups: { - fit: ['chestEase', 'hipsEase', 'sleeveEase', 'draftForHighBust'], - style: ['necklineWidth', 'necklineDepth', 'necklineBend', 'lengthBonus', 'sleeveLength'], - advanced: brianConfig.optionGroups.advanced, - }, - measurements: [...brianConfig.measurements, 'hips', 'waist'], - optionalMeasurements: ['highBust'], - dependencies: { - front: 'base', - back: 'front', - sleevecap: 'back', - sleeve: 'sleevecap', - }, - inject: { - front: 'base', - back: 'front', - sleeve: 'sleevecap', - }, - hide: ['base', 'sleevecap'], - options: { - ...brianConfig.options, - - // Constants - bicepsEase: 0.05, - shoulderEase: 0, - collarEase: 0, - shoulderSlopeReduction: 0, - sleeveWidthGuarantee: 0.85, - frontArmholeDeeper: 0.005, - - // Brian overrides - chestEase: { pct: 12, min: 5, max: 25 }, - sleeveLength: { pct: 30, min: 20, max: 100 }, - lengthBonus: { pct: 5, min: -20, max: 60 }, - backNeckCutout: { pct: 8, min: 4, max: 12 }, - - // Teagan specific - draftForHighBust: { bool: false }, - hipsEase: { pct: 18, min: 8, max: 30 }, - sleeveEase: { pct: 15, min: 5, max: 35 }, - necklineDepth: { pct: 25, min: 20, max: 40 }, - necklineWidth: { pct: 30, min: 10, max: 50 }, - necklineBend: { pct: 30, min: 0, max: 70 }, - }, -} - -export default config diff --git a/designs/teagan/src/back.mjs b/designs/teagan/src/back.mjs index 7d36a684415..e1f7fb52d1b 100644 --- a/designs/teagan/src/back.mjs +++ b/designs/teagan/src/back.mjs @@ -1,5 +1,7 @@ -export default function (part) { - let { +import { front } from './front.mjs' + +function teaganBack(part) { + const { store, sa, Point, @@ -88,3 +90,9 @@ export default function (part) { return part } + +export const back = { + name: 'teagan.back', + from: front, + draft: teaganBack, +} diff --git a/designs/teagan/src/front.mjs b/designs/teagan/src/front.mjs index 335a5565d81..e56573a93e2 100644 --- a/designs/teagan/src/front.mjs +++ b/designs/teagan/src/front.mjs @@ -1,5 +1,7 @@ -export default function (part) { - let { +import { base } from '@freesewing/brian' + +function teaganFront(part) { + const { utils, store, sa, @@ -160,3 +162,29 @@ export default function (part) { return part } + +export const front = { + name: 'teagan.front', + from: base, + measurements: ['hips', 'waist'], + options: { + bicepsEase: 0.05, + shoulderEase: 0, + collarEase: 0, + shoulderSlopeReduction: 0, + sleeveWidthGuarantee: 0.85, + frontArmholeDeeper: 0.005, + // Brian overrides + chestEase: { pct: 12, min: 5, max: 25, menu: 'fit' }, + sleeveLength: { pct: 30, min: 20, max: 100, menu: 'fit' }, + lengthBonus: { pct: 5, min: -20, max: 60, menu: 'style' }, + backNeckCutout: { pct: 8, min: 4, max: 12, menu: 'fit' }, + // Teagan specific + draftForHighBust: { bool: false, menu: 'fit' }, + hipsEase: { pct: 18, min: 8, max: 30, menu: 'fit' }, + necklineDepth: { pct: 25, min: 20, max: 40, menu: 'style' }, + necklineWidth: { pct: 30, min: 10, max: 50, menu: 'style' }, + necklineBend: { pct: 30, min: 0, max: 70, menu: 'style' }, + }, + draft: teaganFront, +} diff --git a/designs/teagan/src/index.mjs b/designs/teagan/src/index.mjs index a5c491cc41e..7d66547092e 100644 --- a/designs/teagan/src/index.mjs +++ b/designs/teagan/src/index.mjs @@ -1,43 +1,14 @@ -import freesewing from '@freesewing/core' -import Brian from '@freesewing/brian' -import plugins from '@freesewing/plugin-bundle' -import plugin from '@freesewing/plugin-bust' // Note: conditional plugin -import config from '../config' -// Parts -import draftBack from './back' -import draftFront from './front' -import draftSleeve from './sleeve' +import { Design } from '@freesewing/core' +import { data } from '../data.mjs' +import { back } from './back.mjs' +import { front } from './front.mjs' +import { sleeve } from './sleeve.mjs' -/* Check to see whether we should load the bust plugin - * Only of the `draftForHighBust` options is set - * AND the highBust measurement is available - */ -const condition = (settings = false) => - settings && - settings.options && - settings.options.draftForHighBust && - settings.measurements.highBust - ? true - : false - -// Create design -const Teagan = new freesewing.Design(config, plugins, { plugin, condition }) - -// Attach draft methods to prototype -Teagan.prototype.draftBase = function (part) { - // Getting the base part from Brian - return new Brian(this.settings).draftBase(part) -} -Teagan.prototype.draftSleevecap = function (part) { - // Getting the sleevecap part from Brian - return new Brian(this.settings).draftSleevecap(part) -} -Teagan.prototype.draftFront = (part) => draftFront(part) -Teagan.prototype.draftBack = (part) => draftBack(part) -Teagan.prototype.draftSleeve = (part) => draftSleeve(part) +// Setup our new design +const Teagan = new Design({ + data, + parts: [back, front, sleeve], +}) // Named exports -export { config, Teagan } - -// Default export -export default Teagan +export { back, front, sleeve, Teagan } diff --git a/designs/teagan/src/sleeve.mjs b/designs/teagan/src/sleeve.mjs index 4a4dc9ca5e0..ba9f740034c 100644 --- a/designs/teagan/src/sleeve.mjs +++ b/designs/teagan/src/sleeve.mjs @@ -1,5 +1,7 @@ -export default function (part) { - let { sa, Point, points, Path, paths, options, complete, paperless, macro, measurements } = +import { sleevecap } from '@freesewing/brian' + +function teaganSleeve(part) { + const { sa, Point, points, Path, paths, options, complete, paperless, macro, measurements } = part.shorthand() let height = points.bicepsRight.x * options.sleeveLength @@ -81,3 +83,12 @@ export default function (part) { return part } + +export const sleeve = { + name: 'teagan.sleeve', + from: sleevecap, + options: { + sleeveEase: { pct: 15, min: 5, max: 35, menu: 'style' }, + }, + draft: teaganSleeve, +}