1
0
Fork 0

🚧 WIP:Work on types and exports

This commit is contained in:
Joost De Cock 2018-07-10 19:29:09 +02:00
parent 145272c546
commit c8d502c698
16 changed files with 312 additions and 95 deletions

View file

@ -1,18 +1,24 @@
declare const config: { declare const manSize34: {
"parts": string[]; bicepsCircumference: number;
"measurements": string[]; centerBackNeckToWaist: number;
"options": ({ chestCircumference: number;
"id": string; hipsCircumference: number;
"min": number; naturalWaistToHip: number;
"max": number; neckCircumference: number;
"std": number; shoulderSlope: number;
"type"?: undefined; shoulderToShoulder: number;
} | { shoulderToWrist: number;
"id": string; wristCircumference: number;
"type": string; };
"min": number; declare const manSize36: {
"max": number; bicepsCircumference: number;
"std": number; centerBackNeckToWaist: number;
})[]; chestCircumference: number;
hipsCircumference: number;
naturalWaistToHip: number;
neckCircumference: number;
shoulderSlope: number;
shoulderToShoulder: number;
shoulderToWrist: number;
wristCircumference: number;
}; };
export default config;

184
dist/config/config.js vendored
View file

@ -1,75 +1,113 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); var manSize34 = {
var config = { bicepsCircumference: 335,
"parts": [ centerBackNeckToWaist: 489,
"backBlock", chestCircumference: 849,
"frontBlock", hipsCircumference: 722,
"sleeveBlock" naturalWaistToHip: 100,
], neckCircumference: 366,
"measurements": [ shoulderSlope: 43,
"bicepsCircumference", shoulderToShoulder: 419,
"centerBackNeckToWaist", shoulderToWrist: 670,
"chestCircumference", wristCircumference: 175
"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
}
]
}; };
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;
}
;

7
dist/lib/model.d.ts vendored Normal file
View file

@ -0,0 +1,7 @@
import { PatternOption } from './types';
export default class Model {
id: string;
config: PatternOption;
val: number;
constructor(config: PatternOption);
}

12
dist/lib/model.js vendored Normal file
View file

@ -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;

7
dist/lib/option.d.ts vendored Normal file
View file

@ -0,0 +1,7 @@
import { PatternOption } from './types';
export default class Option {
id: string;
config: PatternOption;
val: number;
constructor(config: PatternOption);
}

12
dist/lib/option.js vendored Normal file
View file

@ -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;

4
dist/lib/part.d.ts vendored Normal file
View file

@ -0,0 +1,4 @@
export default class Part {
id: string;
constructor(id: string);
}

10
dist/lib/part.js vendored Normal file
View file

@ -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;

View file

@ -1,5 +1,14 @@
import { PatternConfig } from './types'; import { PatternConfig } from './types';
import Part from './part';
import Option from './option';
export default class Pattern { export default class Pattern {
config: PatternConfig; config: PatternConfig;
parts: {
[propName: string]: Part;
};
options: {
[propName: string]: Option;
};
constructor(config: PatternConfig); constructor(config: PatternConfig);
draft(config: object): void;
} }

18
dist/lib/pattern.js vendored
View file

@ -1,10 +1,28 @@
"use strict"; "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var part_1 = __importDefault(require("./part"));
var option_1 = __importDefault(require("./option"));
var Pattern = /** @class */ (function () { var Pattern = /** @class */ (function () {
function Pattern(config) { function Pattern(config) {
this.config = 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; return this;
} }
Pattern.prototype.draft = function (config) {
throw Error('You have to implement the draft() method in your Pattern instance.');
};
return Pattern; return Pattern;
}()); }());
exports.default = Pattern; exports.default = Pattern;

20
dist/lib/types.d.ts vendored
View file

@ -1,12 +1,14 @@
export declare type PatternOptionType = "measure" | "percentage" | "angle" | "choice" | "constant";
export interface PatternOption { export interface PatternOption {
type?: "measure" | "percentage" | "angle" | "choice"; id: string;
val: number;
type?: string;
onlyIf?: { onlyIf?: {
option: string; option: string;
oneOf: number[]; oneOf: number[];
}; };
min?: number; min?: number;
max?: number; max?: number;
std: number;
options?: { options?: {
[index: number]: string; [index: number]: string;
}; };
@ -22,3 +24,17 @@ export declare type Pattern = {
measurements: string[]; measurements: string[];
config: PatternConfig; 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;
}

14
lib/model.ts Normal file
View file

@ -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;
}
}

14
lib/option.ts Normal file
View file

@ -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;
}
}

11
lib/part.ts Normal file
View file

@ -0,0 +1,11 @@
import { PatternOption } from './types'
export default class Part {
id: string;
constructor(id: string) {
this.id = id;
return this;
}
}

View file

@ -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 { export default class Pattern {
config: PatternConfig; config: PatternConfig;
parts: {[propName: string]: Part};
options: {[propName: string]: Option};
constructor(config: PatternConfig) { constructor(config: PatternConfig) {
this.config = config; 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; return this;
} }
draft(config: object): void {
throw Error('You have to implement the draft() method in your Pattern instance.');
}
} }

View file

@ -1,12 +1,15 @@
export type PatternOptionType = "measure" | "percentage" | "angle" | "choice" | "constant";
export interface PatternOption { export interface PatternOption {
type?: "measure" | "percentage" | "angle" | "choice"; id: string;
val: number;
type?: string;
onlyIf?: { onlyIf?: {
option: string; option: string;
oneOf: number[]; oneOf: number[];
} }
min?: number; min?: number;
max?: number; max?: number;
std: number;
options?: { options?: {
[index: number]: string; [index: number]: string;
} }
@ -24,3 +27,21 @@ export type Pattern = {
measurements: string[]; measurements: string[];
config: PatternConfig; 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;
}