diff --git a/dist/config/config.d.ts b/dist/config/config.d.ts index 7f906343f34..5358e870f60 100644 --- a/dist/config/config.d.ts +++ b/dist/config/config.d.ts @@ -1,18 +1,24 @@ -declare const config: { - "parts": string[]; - "measurements": string[]; - "options": ({ - "id": string; - "min": number; - "max": number; - "std": number; - "type"?: undefined; - } | { - "id": string; - "type": string; - "min": number; - "max": number; - "std": number; - })[]; +declare const manSize34: { + bicepsCircumference: number; + centerBackNeckToWaist: number; + chestCircumference: number; + hipsCircumference: number; + naturalWaistToHip: number; + neckCircumference: number; + shoulderSlope: number; + shoulderToShoulder: number; + shoulderToWrist: number; + wristCircumference: number; +}; +declare const manSize36: { + bicepsCircumference: number; + centerBackNeckToWaist: number; + chestCircumference: number; + hipsCircumference: number; + naturalWaistToHip: number; + neckCircumference: number; + shoulderSlope: number; + shoulderToShoulder: number; + shoulderToWrist: number; + wristCircumference: number; }; -export default config; diff --git a/dist/config/config.js b/dist/config/config.js index cfa3754c1e1..085f88bfe2d 100644 --- a/dist/config/config.js +++ b/dist/config/config.js @@ -1,75 +1,113 @@ "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var config = { - "parts": [ - "backBlock", - "frontBlock", - "sleeveBlock" - ], - "measurements": [ - "bicepsCircumference", - "centerBackNeckToWaist", - "chestCircumference", - "naturalWaistToHip", - "neckCircumference", - "shoulderSlope", - "shoulderToShoulder", - "hipsCircumference", - "shoulderToWrist", - "wristCircumference" - ], - "options": [ - { - "id": "chestEase", - "min": -40, - "max": 160, - "std": 30 - }, - { - "id": "bicepsEase", - "min": 30, - "max": 80, - "std": 50 - }, - { - "id": "cuffEase", - "min": 0, - "max": 100, - "std": 45 - }, - { - "id": "lengthBonus", - "min": -40, - "max": 120, - "std": 0 - }, - { - "id": "sleeveLengthBonus", - "min": -40, - "max": 80, - "std": 0 - }, - { - "id": "armholeDepthFactor", - "type": "percentage", - "min": 50, - "max": 65, - "std": 50 - }, - { - "id": "sleevecapHeightFactor", - "type": "percentage", - "min": 35, - "max": 75, - "std": 55 - }, - { - "id": "acrossBackFactor", - "type": "percentage", - "min": 93, - "max": 99, - "std": 96 - } - ] +var manSize34 = { + bicepsCircumference: 335, + centerBackNeckToWaist: 489, + chestCircumference: 849, + hipsCircumference: 722, + naturalWaistToHip: 100, + neckCircumference: 366, + shoulderSlope: 43, + shoulderToShoulder: 419, + shoulderToWrist: 670, + wristCircumference: 175 }; -exports.default = config; +var manSize36 = { + bicepsCircumference: 290, + centerBackNeckToWaist: 492, + chestCircumference: 907, + hipsCircumference: 780, + naturalWaistToHip: 105, + neckCircumference: 378, + shoulderSlope: 46, + shoulderToShoulder: 431, + shoulderToWrist: 675, + wristCircumference: 180 +}; +size38: { + bicepsCircumference: 305, + centerBackNeckToWaist; + 495, + chestCircumference; + 965, + hipsCircumference; + 838, + naturalWaistToHip; + 110, + neckCircumference; + 391, + shoulderSlope; + 49, + shoulderToShoulder; + 444, + shoulderToWrist; + 680, + wristCircumference; + 185; +} +; +size40: { + bicepsCircumference: 320, + centerBackNeckToWaist; + 498, + chestCircumference; + 1023, + hipsCircumference; + 896, + naturalWaistToHip; + 115, + neckCircumference; + 404, + shoulderSlope; + 52, + shoulderToShoulder; + 457, + shoulderToWrist; + 685, + wristCircumference; + 190; +} +; +size42: { + bicepsCircumference: 335, + centerBackNeckToWaist; + 501, + chestCircumference; + 1081, + hipsCircumference; + 895, + naturalWaistToHip; + 120, + neckCircumference; + 416, + shoulderSlope; + 55, + shoulderToShoulder; + 470, + shoulderToWrist; + 690, + wristCircumference; + 195; +} +; +size44: { + bicepsCircumference: 350, + centerBackNeckToWaist; + 505, + chestCircumference; + 1139, + hipsCircumference; + 1012, + naturalWaistToHip; + 125, + neckCircumference; + 429, + shoulderSlope; + 58, + shoulderToShoulder; + 483, + shoulderToWrist; + 700, + wristCircumference; + 200; +} +; diff --git a/dist/lib/model.d.ts b/dist/lib/model.d.ts new file mode 100644 index 00000000000..195888a5eaf --- /dev/null +++ b/dist/lib/model.d.ts @@ -0,0 +1,7 @@ +import { PatternOption } from './types'; +export default class Model { + id: string; + config: PatternOption; + val: number; + constructor(config: PatternOption); +} diff --git a/dist/lib/model.js b/dist/lib/model.js new file mode 100644 index 00000000000..7d0ac6e8a87 --- /dev/null +++ b/dist/lib/model.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Model = /** @class */ (function () { + function Model(config) { + this.id = config.id; + this.config = config; + this.val = config.val; + return this; + } + return Model; +}()); +exports.default = Model; diff --git a/dist/lib/option.d.ts b/dist/lib/option.d.ts new file mode 100644 index 00000000000..75b53d4952c --- /dev/null +++ b/dist/lib/option.d.ts @@ -0,0 +1,7 @@ +import { PatternOption } from './types'; +export default class Option { + id: string; + config: PatternOption; + val: number; + constructor(config: PatternOption); +} diff --git a/dist/lib/option.js b/dist/lib/option.js new file mode 100644 index 00000000000..82bae0c4f6b --- /dev/null +++ b/dist/lib/option.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Option = /** @class */ (function () { + function Option(config) { + this.id = config.id; + this.config = config; + this.val = config.val; + return this; + } + return Option; +}()); +exports.default = Option; diff --git a/dist/lib/part.d.ts b/dist/lib/part.d.ts new file mode 100644 index 00000000000..7c8f48f031d --- /dev/null +++ b/dist/lib/part.d.ts @@ -0,0 +1,4 @@ +export default class Part { + id: string; + constructor(id: string); +} diff --git a/dist/lib/part.js b/dist/lib/part.js new file mode 100644 index 00000000000..5ac001f178d --- /dev/null +++ b/dist/lib/part.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Part = /** @class */ (function () { + function Part(id) { + this.id = id; + return this; + } + return Part; +}()); +exports.default = Part; diff --git a/dist/lib/pattern.d.ts b/dist/lib/pattern.d.ts index 26a97ab9f14..ddf72ac0c0d 100644 --- a/dist/lib/pattern.d.ts +++ b/dist/lib/pattern.d.ts @@ -1,5 +1,14 @@ import { PatternConfig } from './types'; +import Part from './part'; +import Option from './option'; export default class Pattern { config: PatternConfig; + parts: { + [propName: string]: Part; + }; + options: { + [propName: string]: Option; + }; constructor(config: PatternConfig); + draft(config: object): void; } diff --git a/dist/lib/pattern.js b/dist/lib/pattern.js index 270c6c5ef8c..d83118b6fb9 100644 --- a/dist/lib/pattern.js +++ b/dist/lib/pattern.js @@ -1,10 +1,28 @@ "use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); +var part_1 = __importDefault(require("./part")); +var option_1 = __importDefault(require("./option")); var Pattern = /** @class */ (function () { function Pattern(config) { this.config = config; + this.parts = {}; + for (var _i = 0, _a = config.parts; _i < _a.length; _i++) { + var id = _a[_i]; + this.parts[id] = new part_1.default(id); + } + this.options = {}; + for (var _b = 0, _c = config.options; _b < _c.length; _b++) { + var conf = _c[_b]; + this.options[conf.id] = new option_1.default(conf); + } return this; } + Pattern.prototype.draft = function (config) { + throw Error('You have to implement the draft() method in your Pattern instance.'); + }; return Pattern; }()); exports.default = Pattern; diff --git a/dist/lib/types.d.ts b/dist/lib/types.d.ts index 5336496e628..2ecc442b594 100644 --- a/dist/lib/types.d.ts +++ b/dist/lib/types.d.ts @@ -1,12 +1,14 @@ +export declare type PatternOptionType = "measure" | "percentage" | "angle" | "choice" | "constant"; export interface PatternOption { - type?: "measure" | "percentage" | "angle" | "choice"; + id: string; + val: number; + type?: string; onlyIf?: { option: string; oneOf: number[]; }; min?: number; max?: number; - std: number; options?: { [index: number]: string; }; @@ -22,3 +24,17 @@ export declare type Pattern = { measurements: string[]; config: PatternConfig; }; +export declare type DraftMode = "sample" | "compare" | "draft"; +export declare type CompareGroup = "men" | "women"; +export declare type Units = "metric" | "imperial"; +export interface DraftConfig { + mode: DraftMode; + units?: Units; + options: PatternOption[]; + measurements?: { + [index: string]: number; + }; + sa?: number; + scope?: string[]; + theme?: string; +} diff --git a/lib/model.ts b/lib/model.ts new file mode 100644 index 00000000000..ae29c30014d --- /dev/null +++ b/lib/model.ts @@ -0,0 +1,14 @@ +import { PatternOption } from './types' +export default class Model { + id: string; + config: PatternOption; + val: number; + + constructor(config: PatternOption) { + this.id = config.id; + this.config = config; + this.val = config.val; + + return this; + } +} diff --git a/lib/option.ts b/lib/option.ts new file mode 100644 index 00000000000..9c4c18d7d0b --- /dev/null +++ b/lib/option.ts @@ -0,0 +1,14 @@ +import { PatternOption } from './types' +export default class Option { + id: string; + config: PatternOption; + val: number; + + constructor(config: PatternOption) { + this.id = config.id; + this.config = config; + this.val = config.val; + + return this; + } +} diff --git a/lib/part.ts b/lib/part.ts new file mode 100644 index 00000000000..9ae7e3a41c3 --- /dev/null +++ b/lib/part.ts @@ -0,0 +1,11 @@ +import { PatternOption } from './types' + +export default class Part { + id: string; + + constructor(id: string) { + this.id = id; + + return this; + } +} diff --git a/lib/pattern.ts b/lib/pattern.ts index a3583a25475..076712cb555 100644 --- a/lib/pattern.ts +++ b/lib/pattern.ts @@ -1,11 +1,29 @@ -import { PatternConfig } from './types' +import { PatternConfig, PatternOption } from './types' +import Part from './part' +import Option from './option' export default class Pattern { config: PatternConfig; + parts: {[propName: string]: Part}; + options: {[propName: string]: Option}; constructor(config: PatternConfig) { this.config = config; + this.parts = {}; + for (let id of config.parts) { + this.parts[id] = new Part(id); + } + + this.options = {}; + for (let conf of config.options) { + this.options[conf.id] = new Option(conf); + } + return this; } + + draft(config: object): void { + throw Error('You have to implement the draft() method in your Pattern instance.'); + } } diff --git a/lib/types.ts b/lib/types.ts index 2f540b8d49a..5de534bb8ac 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,12 +1,15 @@ +export type PatternOptionType = "measure" | "percentage" | "angle" | "choice" | "constant"; + export interface PatternOption { - type?: "measure" | "percentage" | "angle" | "choice"; + id: string; + val: number; + type?: string; onlyIf?: { option: string; oneOf: number[]; } min?: number; max?: number; - std: number; options?: { [index: number]: string; } @@ -24,3 +27,21 @@ export type Pattern = { measurements: string[]; config: PatternConfig; } + +export type DraftMode = "sample" | "compare" | "draft"; +export type CompareGroup = "men" | "women"; +export type Units = "metric" | "imperial"; + +export interface DraftConfig { + mode: DraftMode; + units?: Units; + options: PatternOption[]; + measurements?: { + [index:string]: number; + }; + sa?: number; + scope?: string[]; + theme?: string; +} + +