From e82cebe445b7f423038a9de7a3b5eb100839a16c Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Mon, 5 Sep 2022 13:37:46 +0200 Subject: [PATCH] chore(octopussy): Ported to v3 --- designs/octoplushy/config/index.js | 49 ------------------- .../src/{armSection.mjs => arm.mjs} | 15 +++++- designs/octoplushy/src/eye.mjs | 20 +++++++- .../src/{headSection.mjs => head.mjs} | 40 +++++++++++++-- designs/octoplushy/src/index.mjs | 35 +++++-------- 5 files changed, 79 insertions(+), 80 deletions(-) delete mode 100644 designs/octoplushy/config/index.js rename designs/octoplushy/src/{armSection.mjs => arm.mjs} (96%) rename designs/octoplushy/src/{headSection.mjs => head.mjs} (95%) diff --git a/designs/octoplushy/config/index.js b/designs/octoplushy/config/index.js deleted file mode 100644 index b992ca79a34..00000000000 --- a/designs/octoplushy/config/index.js +++ /dev/null @@ -1,49 +0,0 @@ -import pkg from '../package.json' assert { type: 'json' } - -const { version } = pkg - -export default { - name: 'octoplushy', - version: version, - design: 'Wouter Van Wageningen', - code: 'Wouter Van Wageningen', - department: 'accessories', - type: 'pattern', - difficulty: 5, - optionGroups: { - style: ['size','type','armWidth','armLength','neckWidth','armTaper','bottomTopArmRatio','bottomArmReduction','bottomArmReductionPlushy'], - }, - parts: ['headSection0', 'headSection1', 'armSection0', 'armSection1', 'eye0', 'eye1', 'eye2'], - measurements: [], - dependencies: { - eye0: 'headSection0', - eye1: 'headSection0', - eye2: 'headSection0', - armSection0: 'headSection0', - armSection1: 'headSection1', - }, - inject: {}, - hide: [], - options: { - sizeConstant: 200, - size: { pct: 100, min: 5, max: 500 }, - type: { dflt: 'octoplushy', list: ['octoplushy', 'octopus', 'squid'] }, - armWidth: { pct: 15, min: 10, max: 30 }, - armLength: { pct: 200, min: 100, max: 500 }, - neckWidth: { pct: 25, min: 25, max: 45 }, - armTaper: { pct: 25, min: 0, max: 50 }, - bottomTopArmRatio: { pct: 87, min: 75, max: 100 }, - bottomArmReduction: { - pct: 90, - min: 75, - max: 125, - hide: ({ options }) => options.type == 'octoplushy', - }, - bottomArmReductionPlushy: { - pct: 80, - min: 75, - max: 125, - hide: ({ options }) => options.type != 'octoplushy', - }, - }, -} diff --git a/designs/octoplushy/src/armSection.mjs b/designs/octoplushy/src/arm.mjs similarity index 96% rename from designs/octoplushy/src/armSection.mjs rename to designs/octoplushy/src/arm.mjs index 44fc7d67e92..05efede4704 100644 --- a/designs/octoplushy/src/armSection.mjs +++ b/designs/octoplushy/src/arm.mjs @@ -1,4 +1,6 @@ -export default function (partNumber, part) { +import { headSection1, headSection2 } from './head.mjs' + +function octoplushyArmSection(partNumber, part) { const { options, Point, @@ -309,3 +311,14 @@ export default function (partNumber, part) { return part } + +export const armSection1 = { + name: 'octoplushy.armSection1', + after: headSection1, + draft: (part) => octoplushyArmSection(0, part), +} +export const armSection2 = { + name: 'octoplushy.armSection2', + after: headSection2, + draft: (part) => octoplushyArmSection(1, part), +} diff --git a/designs/octoplushy/src/eye.mjs b/designs/octoplushy/src/eye.mjs index 83faad86caa..f0685069cdf 100644 --- a/designs/octoplushy/src/eye.mjs +++ b/designs/octoplushy/src/eye.mjs @@ -1,4 +1,6 @@ -export default function (partNumber, part) { +import { headSection1 } from './head.mjs' + +function octoplushyEye(partNumber, part) { const { options, Point, @@ -127,3 +129,19 @@ export default function (partNumber, part) { return part } + +export const eye1 = { + name: 'octoplushy.eye1', + after: headSection1, + draft: (part) => octoplushyEye(0, part), +} +export const eye2 = { + name: 'octoplushy.eye2', + after: headSection1, + draft: (part) => octoplushyEye(1, part), +} +export const eye3 = { + name: 'octoplushy.eye3', + after: headSection1, + draft: (part) => octoplushyEye(2, part), +} diff --git a/designs/octoplushy/src/headSection.mjs b/designs/octoplushy/src/head.mjs similarity index 95% rename from designs/octoplushy/src/headSection.mjs rename to designs/octoplushy/src/head.mjs index 390b19be31f..0a649b5866b 100644 --- a/designs/octoplushy/src/headSection.mjs +++ b/designs/octoplushy/src/head.mjs @@ -1,8 +1,4 @@ -// import mirror from '@freesewing/plugin-mirror' -// import { PostAddSharp } from '@material-ui/icons' -// import { Store } from "@material-ui/icons"; - -export default function (partNumber, part) { +function octoplushyHeadSection(partNumber, part) { const { options, Point, @@ -607,3 +603,37 @@ export default function (partNumber, part) { } return part } + +const options = { + sizeConstant: 200, + size: { pct: 100, min: 5, max: 500, menu: 'style' }, + type: { dflt: 'octoplushy', list: ['octoplushy', 'octopus', 'squid'], menu: 'style' }, + armWidth: { pct: 15, min: 10, max: 30, menu: 'style' }, + armLength: { pct: 200, min: 100, max: 500, menu: 'style' }, + neckWidth: { pct: 25, min: 25, max: 45, menu: 'style' }, + armTaper: { pct: 25, min: 0, max: 50, menu: 'style' }, + bottomTopArmRatio: { pct: 87, min: 75, max: 100, menu: 'style' }, + bottomArmReduction: { + pct: 90, + min: 75, + max: 125, + menu: ({ options }) => (options.type == 'octoplushy' ? 'style' : false), + }, + bottomArmReductionPlushy: { + pct: 80, + min: 75, + max: 125, + menu: ({ options }) => (options.type != 'octoplushy' ? 'style' : false), + }, +} + +export const headSection1 = { + name: 'octoplushy.headSection1', + options, + draft: (part) => octoplushyHeadSection(0, part), +} +export const headSection2 = { + name: 'octoplushy.headSection2', + options, + draft: (part) => octoplushyHeadSection(1, part), +} diff --git a/designs/octoplushy/src/index.mjs b/designs/octoplushy/src/index.mjs index 87668795ae5..4cf5714dbf8 100644 --- a/designs/octoplushy/src/index.mjs +++ b/designs/octoplushy/src/index.mjs @@ -1,27 +1,14 @@ -import freesewing from '@freesewing/core' -import plugins from '@freesewing/plugin-bundle' -import config from '../config' -import draftHeadSection from './headSection' -import draftArmSection from './armSection' -import draftEye from './eye' +import { Design } from '@freesewing/core' +import { data } from '../data.mjs' +import { headSection1, headSection2 } from './head.mjs' +import { armSection1, armSection2 } from './arm.mjs' +import { eye1, eye2, eye3 } from './eye.mjs' -// Create new design -const Octoplushy = new freesewing.Design(config, plugins) - -// Attach the draft methods to the prototype -// Octoplushy.prototype.draftHeadSection = draftHeadSection -for (let i = 0; i < 2; i++) { - Octoplushy.prototype[`draftHeadSection${i}`] = (part) => draftHeadSection(i, part) -} -for (let i = 0; i < 2; i++) { - Octoplushy.prototype[`draftArmSection${i}`] = (part) => draftArmSection(i, part) -} -for (let i = 0; i < 3; i++) { - Octoplushy.prototype[`draftEye${i}`] = (part) => draftEye(i, part) -} +// Setup our new design +const Octoplushy = new Design({ + data, + parts: [headSection1, headSection2, armSection1, armSection2, eye1, eye2, eye3], +}) // Named exports -export { config, Octoplushy } - -// Default export -export default Octoplushy +export { headSection1, headSection2, armSection1, armSection2, eye1, eye2, eye3, Octoplushy }