diff --git a/.github/workflows/tests.teagan.yml b/.github/workflows/tests.teagan.yml new file mode 100644 index 00000000000..bf621d972a4 --- /dev/null +++ b/.github/workflows/tests.teagan.yml @@ -0,0 +1,32 @@ +name: Unit tests - Teagan + +on: [push] + +jobs: + test: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [12.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: cd packages/teagan && npm install + env: + CI: true + - name: Install peer & test dependencies + run: "cd packages/teagan && npm install @freesewing/core@^2.8.1 @freesewing/plugin-bundle@^2.8.1 @freesewing/models@2.8.1 @freesewing/pattern-info@2.8.1 mocha chai" + env: + CI: true + - name: Build pattern + run: cd packages/teagan && npm run build + - name: Run pattern unit tests + run: cd packages/teagan && npm run testci diff --git a/config/changelog.yaml b/config/changelog.yaml index 8221d48fe91..b8565391d74 100644 --- a/config/changelog.yaml +++ b/config/changelog.yaml @@ -1,5 +1,7 @@ Unreleased: date: + Added: + teagan: Teagan is a T-shirt pattern Fixed: benjamin: - Fixed issue with (length of) band diff --git a/config/descriptions.yaml b/config/descriptions.yaml index da759f2b39c..676b1e72451 100644 --- a/config/descriptions.yaml +++ b/config/descriptions.yaml @@ -58,6 +58,7 @@ simone: 'A FreeSewing pattern for a button down shirt (Simone = Simon for people sven: 'A FreeSewing pattern for a straightforward sweater' tamiko: 'A FreeSewing pattern for a zero-waste top' theo: 'A FreeSewing pattern for classic trousers' +teagan: 'A FreeSewing pattern for a T-shirt' titan: 'A FreeSewing block for trousers' trayvon: 'A FreeSewing pattern for a tie' tutorial: "A FreeSewing pattern for a baby bib that's used in our tutorial" diff --git a/packages/brian/src/sleevecap.js b/packages/brian/src/sleevecap.js index 88ed6381367..2c1bba19021 100644 --- a/packages/brian/src/sleevecap.js +++ b/packages/brian/src/sleevecap.js @@ -136,7 +136,7 @@ function draftSleevecap(part, run) { } export default (part) => { - let { store, units, options, Point, points, paths } = part.shorthand() + let { store, units, options, Point, points, paths, raise } = part.shorthand() store.set('sleeveFactor', 1) let run = 0 @@ -146,7 +146,8 @@ export default (part) => { delta = sleevecapDelta(store) sleevecapAdjust(store) run++ - } while (options.brianFitSleeve === true && run < 30 && Math.abs(sleevecapDelta(store)) > 2) + raise.debug(`Fitting Brian sleevecap. Run ${run}: delta is ${units(delta)}`) + } while (options.brianFitSleeve === true && run < 50 && Math.abs(sleevecapDelta(store)) > 2) // Paths paths.sleevecap.attr('class', 'fabric') diff --git a/packages/examples/example/package.json b/packages/examples/example/package.json index be930bc9fc0..fdbf37d68c0 100644 --- a/packages/examples/example/package.json +++ b/packages/examples/example/package.json @@ -20,7 +20,7 @@ "@material-ui/icons": "^4.9.1", "@material-ui/lab": "^v4.0.0-alpha.56", "pattern": "link:..", - "prismjs": "1.21.0", + "prismjs": "1.20.0", "react": "^16.13", "react-dom": "^16.13", "react-scripts": "^3.4.1", diff --git a/packages/i18n/src/locales/en/options/index.js b/packages/i18n/src/locales/en/options/index.js index c351da9b910..6769692975b 100644 --- a/packages/i18n/src/locales/en/options/index.js +++ b/packages/i18n/src/locales/en/options/index.js @@ -14,6 +14,7 @@ import holmes from './holmes.yml' import huey from './huey.yml' import hugo from './hugo.yml' import tamiko from './tamiko.yml' +import teagan from './teagan.yml' import trayvon from './trayvon.yml' import jaeger from './jaeger.yml' import carlton from './carlton.yml' @@ -59,7 +60,8 @@ let patterns = { waralee, holmes, titan, - paco + paco, + teagan } let options = {} diff --git a/packages/i18n/src/locales/en/options/teagan.yml b/packages/i18n/src/locales/en/options/teagan.yml new file mode 100644 index 00000000000..300d8dffcdd --- /dev/null +++ b/packages/i18n/src/locales/en/options/teagan.yml @@ -0,0 +1,7 @@ +necklineDepth: + title: Neckline depth + description: Controls how deep the neck opening plunges down. + +necklineWidth: + title: Neckline width + description: Controls the width of the neck opening. diff --git a/packages/i18n/src/locales/en/patterns.yml b/packages/i18n/src/locales/en/patterns.yml index 2b927ffcabb..0e9fe7e8a7d 100644 --- a/packages/i18n/src/locales/en/patterns.yml +++ b/packages/i18n/src/locales/en/patterns.yml @@ -70,6 +70,9 @@ sven: tamiko: description: Tamiko is a zero-waste top. title: Tamiko top +teagan: + description: Teagan is a fitted T-shirt pattern + title: Teagan T-shirt theo: description: Theo is a classic trouser pattern. title: Theo trousers diff --git a/packages/i18n/src/shared-options.yml b/packages/i18n/src/shared-options.yml index 1493282046f..43ed1ff2a35 100644 --- a/packages/i18n/src/shared-options.yml +++ b/packages/i18n/src/shared-options.yml @@ -142,6 +142,10 @@ sven: dflt: brian tamiko: dflt: brian +teagan: + dflt: brian + other: + hipsEase: aaron theo: dflt: bruce other: diff --git a/packages/pattern-info/src/prebuild.js b/packages/pattern-info/src/prebuild.js index 49d8bd0e636..f43c3de3ebe 100644 --- a/packages/pattern-info/src/prebuild.js +++ b/packages/pattern-info/src/prebuild.js @@ -24,6 +24,7 @@ const simon = require('@freesewing/simon').config const simone = require('@freesewing/simone').config const sven = require('@freesewing/sven').config const tamiko = require('@freesewing/tamiko').config +const teagan = require('@freesewing/teagan').config const theo = require('@freesewing/theo').config const titan = require('@freesewing/titan').config const trayvon = require('@freesewing/trayvon').config @@ -55,6 +56,7 @@ const patterns = { simone, sven, tamiko, + teagan, theo, titan, trayvon, diff --git a/packages/teagan/.prettierignore b/packages/teagan/.prettierignore new file mode 100644 index 00000000000..0df7141f7d5 --- /dev/null +++ b/packages/teagan/.prettierignore @@ -0,0 +1 @@ +config/config.js diff --git a/packages/teagan/CHANGELOG.md b/packages/teagan/CHANGELOG.md new file mode 100644 index 00000000000..1afdb370c85 --- /dev/null +++ b/packages/teagan/CHANGELOG.md @@ -0,0 +1,9 @@ +# Change log for: @freesewing/teagan + + + +This is the **initial release**, and the start of this change log. + +> Prior to version 2, FreeSewing was not a JavaScript project. +> As such, that history is out of scope for this change log. + diff --git a/packages/teagan/README.md b/packages/teagan/README.md new file mode 100644 index 00000000000..e33901a294d --- /dev/null +++ b/packages/teagan/README.md @@ -0,0 +1,100 @@ +![FreeSewing](https://freesewing.org/banner.jpg) +

@freesewing/teagan on NPM + License: MIT + Code quality on DeepScan + Open issues tagged pkg:teagan +

Follow @freesewing_org on Twitter + Chat with us on Gitter + Become a FreeSewing Patron + Follow @freesewing_org on Twitter +

+ +## What am I looking at? 🤔 + +This repository is our *monorepo* holding [all our NPM packages](https://www.npmjs.com/search?q=keywords:freesewing). +This folder holds **@freesewing/teagan** + +A FreeSewing pattern for a T-shirt + + + +## About FreeSewing 💀 + +Where the world of makers and developers collide, that's where you'll find FreeSewing. + +Our [core library](https://freesewing.dev/reference/api/) is a *batteries-included* toolbox +for parametric design of sewing patterns. It's a modular system (check our list +of [plugins](https://freesewing.dev/reference/plugins/) and getting started is as simple as: + +```bash +npm init freesewing-pattern +``` + +The [getting started](https://freesewing.dev/guides/getting-started/) section on [freesewing.dev](https://freesewing.dev/) is a good +entrypoint to our documentation, but you'll find a lot more there, including +our [API reference](https://freesewing.dev/reference/api/), +as well as [our turorial](https://freesewing.dev/tutorials/pattern-design/), +and [howtos](https://freesewing.dev/howtos/). + +If you're a maker, checkout [freesewing.org](https://freesewing/) where you can generate +our sewing patterns adapted to your measurements. + +## Support FreeSewing: Become a patron 🥰 + +FreeSewing is an open source project run by a community, +and financially supported by our patrons. + +If you feel what we do is worthwhile, you too +should [become a patron](https://freesewing.org/patrons/join). + +## Links 👩‍💻 + + - 💻 Makers website: [freesewing.org](https://freesewing.org) + - 💻 Developers website: [freesewing.dev](https://freesewing.dev) + - 💬 Chat: [gitter.im/freesewing](https://gitter.im/freesewing/chat) + - 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org) + - 📷 Instagram: [@freesewing_org](https://instagram.com/freesewing_org) + +## License: MIT 🤓 + +© [Joost De Cock](https://github.com/joostdecock). +See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details. + +## Where to get help 🤯 + +Our [chatroom on Gitter](https://gitter.im/freesewing/chat) is the best place to ask questions, +share your feedback, or just hang out. + +If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new). diff --git a/packages/teagan/] b/packages/teagan/] new file mode 100644 index 00000000000..991938798a2 --- /dev/null +++ b/packages/teagan/] @@ -0,0 +1,113 @@ +import { version } from '../package.json' + +export default { + name: 'teagan', + version, + design: 'Joost De Cock', + code: 'Joost De Cock', + department: 'unisex', + type: 'pattern', + difficulty: 3, + tags: ['top', 'basics'], + optionGroups: { + fit: ['chestEase', 'hipsEase', 'sleeveEase'], + style: ['necklineWidth', 'necklineDepth', 'lengthBonus'], + advanced: [ + 'acrossBackFactor', + 'armholeDepthFactor', + 'backNeckCutout', + 'frontArmholeDeeper', + 'sleeveWidthGuarantee', + { + sleevecap: [ + 'sleevecapEase', + 'sleevecapTopFactorX', + 'sleevecapTopFactorY', + 'sleevecapBackFactorX', + 'sleevecapBackFactorY', + 'sleevecapFrontFactorX', + 'sleevecapFrontFactorY', + 'sleevecapQ1Offset', + 'sleevecapQ2Offset', + 'sleevecapQ3Offset', + 'sleevecapQ4Offset', + 'sleevecapQ1Spread1', + 'sleevecapQ1Spread2', + 'sleevecapQ2Spread1', + 'sleevecapQ2Spread2', + 'sleevecapQ3Spread1', + 'sleevecapQ3Spread2', + 'sleevecapQ4Spread1', + 'sleevecapQ4Spread2' + ] + } + ] + }, + measurements: [ + 'biceps', + 'chest', + 'hpsToWaistBack', + 'waistToHips', + 'neck', + 'shoulderSlope', + 'shoulderToShoulder', + 'hips' + ], + dependencies: { + front: 'base', + back: 'front', + sleevecap: 'back', + sleeve: 'sleevecap' + }, + inject: { + front: 'base', + back: 'front', + sleeve: 'sleevecap' + }, + hide: ['base', 'sleevecap'], + options: { + // Constants + brianFitCollar: false, + brianFitSleeve: true, + bicepsEase: 0.05, + collarFactor: 4.8, + shoulderEase: 0, + collarEase: 0, + frontArmholeDeeper: 0, + shoulderSlopeReduction: 0, + + // Percentages + chestEase: { pct: 12, min: 5, max: 25 }, + hipsEase: { pct: 18, min: 8, max: 30 }, + sleeveEase: { pct: 15, min: 5, max: 35 }, + necklineDepth: { pct: 25, min: 15, max: 40 }, + necklineWidth: { pct: 30, min: 10, max: 50 }, + lengthBonus: { pct: 5, min: -20, max: 60 }, + acrossBackFactor: { pct: 97, min: 93, max: 100 }, + armholeDepthFactor: { pct: 65, min: 60, max: 70 }, + backNeckCutout: { pct: 5, min: 2, max: 8 }, + frontArmholeDeeper: { pct: 0.5, min: 0, max: 1.5 }, + + // Sleevecap (from brian) + sleevecapEase: { pct: 0, min: 0, max: 5 }, + sleevecapTopFactorX: { pct: 50, min: 25, max: 75 }, + sleevecapTopFactorY: { pct: 35, min: 30, max: 40 }, + sleevecapBackFactorX: { pct: 60, min: 35, max: 65 }, + sleevecapBackFactorY: { pct: 33, min: 30, max: 65 }, + sleevecapFrontFactorX: { pct: 53, min: 35, max: 65 }, + sleevecapFrontFactorY: { pct: 33, min: 30, max: 65 }, + sleevecapQ1Offset: { pct: 2, min: 0, max: 7 }, + sleevecapQ2Offset: { pct: 3.5, min: 0, max: 7 }, + sleevecapQ3Offset: { pct: 3, min: 0, max: 7 }, + sleevecapQ4Offset: { pct: 1, min: 0, max: 7 }, + sleevecapQ1Spread1: { pct: 6, min: 4, max: 20 }, + sleevecapQ1Spread2: { pct: 15, min: 4, max: 20 }, + sleevecapQ2Spread1: { pct: 15, min: 4, max: 20 }, + sleevecapQ2Spread2: { pct: 10, min: 4, max: 20 }, + sleevecapQ3Spread1: { pct: 10, min: 4, max: 20 }, + sleevecapQ3Spread2: { pct: 8, min: 4, max: 20 }, + sleevecapQ4Spread1: { pct: 7, min: 4, max: 20 }, + sleevecapQ4Spread2: { pct: 7, min: 4, max: 20 }, + sleeveWidthGuarantee: { pct: 85, min: 25, max: 100 }, + } +} diff --git a/packages/teagan/config/index.js b/packages/teagan/config/index.js new file mode 100644 index 00000000000..49b57f49e06 --- /dev/null +++ b/packages/teagan/config/index.js @@ -0,0 +1,114 @@ +import { version } from '../package.json' + +export default { + name: 'teagan', + version, + design: 'Joost De Cock', + code: 'Joost De Cock', + department: 'unisex', + type: 'pattern', + difficulty: 3, + tags: ['top', 'basics'], + optionGroups: { + fit: ['chestEase', 'hipsEase', 'sleeveEase'], + style: ['necklineWidth', 'necklineDepth', 'necklineBend', 'lengthBonus', 'sleeveLength'], + advanced: [ + 'acrossBackFactor', + 'armholeDepthFactor', + 'backNeckCutout', + { + sleevecap: [ + 'sleevecapEase', + 'sleevecapTopFactorX', + 'sleevecapTopFactorY', + 'sleevecapBackFactorX', + 'sleevecapBackFactorY', + 'sleevecapFrontFactorX', + 'sleevecapFrontFactorY', + 'sleevecapQ1Offset', + 'sleevecapQ2Offset', + 'sleevecapQ3Offset', + 'sleevecapQ4Offset', + 'sleevecapQ1Spread1', + 'sleevecapQ1Spread2', + 'sleevecapQ2Spread1', + 'sleevecapQ2Spread2', + 'sleevecapQ3Spread1', + 'sleevecapQ3Spread2', + 'sleevecapQ4Spread1', + 'sleevecapQ4Spread2' + ] + } + ] + }, + measurements: [ + 'biceps', + 'chest', + 'hpsToWaistBack', + 'waistToHips', + 'neck', + 'shoulderSlope', + 'shoulderToShoulder', + 'hips' + ], + dependencies: { + front: 'base', + back: 'front', + sleevecap: 'back', + sleeve: 'sleevecap' + }, + inject: { + front: 'base', + back: 'front', + sleeve: 'sleevecap' + }, + hide: ['base', 'sleevecap'], + options: { + // Constants + brianFitCollar: false, + brianFitSleeve: true, + bicepsEase: 0.05, + collarFactor: 4.8, + shoulderEase: 0, + collarEase: 0, + frontArmholeDeeper: 0.05, + shoulderSlopeReduction: 0, + backNeckCutout: 0.05, + sleeveWidthGuarantee: 0.85, + + // Percentages + chestEase: { pct: 12, min: 5, max: 25 }, + hipsEase: { pct: 18, min: 8, max: 30 }, + sleeveEase: { pct: 15, min: 5, max: 35 }, + sleeveLength: { pct: 30, min: 20, max: 100 }, + necklineDepth: { pct: 25, min: 20, max: 40 }, + necklineWidth: { pct: 30, min: 10, max: 50 }, + necklineBend: { pct: 30, min: 0, max: 70 }, + lengthBonus: { pct: 5, min: -20, max: 60 }, + acrossBackFactor: { pct: 97, min: 93, max: 100 }, + armholeDepthFactor: { pct: 65, min: 60, max: 70 }, + frontArmholeDeeper: { pct: 0.5, min: 0, max: 1.5 }, + backNeckCutout: { pct: 5, min: 2, max: 8 }, + + // Sleevecap (from brian) + sleevecapEase: { pct: 0, min: 0, max: 5 }, + sleevecapTopFactorX: { pct: 50, min: 25, max: 75 }, + sleevecapTopFactorY: { pct: 35, min: 30, max: 40 }, + sleevecapBackFactorX: { pct: 60, min: 35, max: 65 }, + sleevecapBackFactorY: { pct: 33, min: 30, max: 65 }, + sleevecapFrontFactorX: { pct: 53, min: 35, max: 65 }, + sleevecapFrontFactorY: { pct: 33, min: 30, max: 65 }, + sleevecapQ1Offset: { pct: 2, min: 0, max: 7 }, + sleevecapQ2Offset: { pct: 3.5, min: 0, max: 7 }, + sleevecapQ3Offset: { pct: 3, min: 0, max: 7 }, + sleevecapQ4Offset: { pct: 1, min: 0, max: 7 }, + sleevecapQ1Spread1: { pct: 6, min: 4, max: 20 }, + sleevecapQ1Spread2: { pct: 15, min: 4, max: 20 }, + sleevecapQ2Spread1: { pct: 15, min: 4, max: 20 }, + sleevecapQ2Spread2: { pct: 10, min: 4, max: 20 }, + sleevecapQ3Spread1: { pct: 10, min: 4, max: 20 }, + sleevecapQ3Spread2: { pct: 8, min: 4, max: 20 }, + sleevecapQ4Spread1: { pct: 7, min: 4, max: 20 }, + sleevecapQ4Spread2: { pct: 7, min: 4, max: 20 } + } +} diff --git a/packages/teagan/example/.babelrc b/packages/teagan/example/.babelrc new file mode 100644 index 00000000000..6e3090a4956 --- /dev/null +++ b/packages/teagan/example/.babelrc @@ -0,0 +1,10 @@ +{ + "plugins": [ + ["prismjs", { + "languages": ["javascript", "css", "markup"], + "plugins": ["line-numbers"], + "theme": "twilight", + "css": true + }] + ] +} diff --git a/packages/teagan/example/README.md b/packages/teagan/example/README.md new file mode 100644 index 00000000000..e2290b38cf0 --- /dev/null +++ b/packages/teagan/example/README.md @@ -0,0 +1,96 @@ +

+Freesewing logo +
+FreeSewing v2 +

+

A JavaScript library for made-to-measure sewing patterns

+

Follow @freesewing_org on Twitter + Chat with us on Gitter + Become a FreeSewing Patron + Follow @freesewing_org on Twitter + +

+ +# teagan example + +This project was bootstrapped with [Create Freesewing Pattern](https://en.freesewing.dev/create-freesewing-pattern): + +```js +npm init freesewing-pattern +``` + +This example folder is part of the local development environment. +It is **not** part of the pattern's source code. + +To run this example, follow these steps: + + - In the folder above this one, run: `yarn start` (or `npm start`) + - Then, in new terminal, run the same command in this folder: `yarn start` (or `npm start`) + +This will spin up the development environment, similar to [our online demo](https://teagan.freesewing.dev/). + +## About FreeSewing 🤔 + +Where the world of makers and developers collide, that's where you'll find FreeSewing. + +Our [core library](https://freesewing.dev/en/freesewing) is a *batteries-included* toolbox +for parametric design of sewing patterns. It's a modular system (check our list +of [plugins](https://freesewing.dev/en/plugins) and getting started is as simple as: + +```bash +npm init freesewing-pattern +``` + +The [getting started] section on [freesewing.dev](https://freesewing.dev/) is a good +entrypoint to our documentation, but you'll find a lot more there, including +our [API documentation](https://freesewing.dev/en/freesewing/api), +as well as [examples](https://freesewing.dev/en/freesewing/examples), +and [best practices](https://freesewing.dev/en/do). + +If you're a maker, checkout [freesewing.org](https://freesewing/) where you can generate +our sewing patterns adapted to your measurements. + +## Support FreeSewing: Become a patron 🥰 + +FreeSewing is an open source project run by a community, +and financially supported by our patrons. + +If you feel what we do is worthwhile, you too +should [become a patron](https://freesewing.org/patrons/join). + +## Links 👩‍💻 + + - 💻 Makers website: [freesewing.org](https://freesewing.org) + - 💻 Developers website: [freesewing.dev](https://freesewing.org) + - 💬 Chat: [gitter.im/freesewing](https://gitter.im/freesewing/freesewing) + - 🐦 Twitter: [@freesewing_org](https://twitter.com/freesewing_org) + - 📷 Instagram: [@freesewing_org](https://instagram.com/freesewing_org) + +## License: MIT 🤓 + +© [Joost De Cock](https://github.com/joostdecock). +See [the license file](https://github.com/freesewing/freesewing/blob/develop/LICENSE) for details. + +## Where to get help 🤯 + +Our [chatroom on Gitter](https://gitter.im) is the best place to ask questions, +share your feedback, or just hang out. + +If you want to report a problem, please [create an issue](https://github.com/freesewing/freesewing/issues/new). + diff --git a/packages/teagan/example/package.json b/packages/teagan/example/package.json new file mode 100644 index 00000000000..bc8ca3abfc8 --- /dev/null +++ b/packages/teagan/example/package.json @@ -0,0 +1,49 @@ +{ + "name": "teagan-example", + "homepage": "https://freesewing.github.io/teagan", + "version": "0.0.0", + "private": true, + "dependencies": { + "@freesewing/components": "latest", + "@freesewing/core": "latest", + "@freesewing/css-theme": "latest", + "@freesewing/i18n": "latest", + "@freesewing/models": "latest", + "@freesewing/mui-theme": "latest", + "@freesewing/pattern-info": "latest", + "@freesewing/plugin-bundle": "latest", + "@freesewing/plugin-theme": "latest", + "@freesewing/plugin-i18n": "latest", + "@freesewing/plugin-svgattr": "latest", + "@freesewing/utils": "latest", + "@material-ui/core": "^4.11.0", + "@material-ui/icons": "^4.9.1", + "@material-ui/lab": "^v4.0.0-alpha.56", + "pattern": "link:..", + "prismjs": "1.20.0", + "react": "^16.13", + "react-dom": "^16.13", + "react-scripts": "^3.4.1", + "file-saver": "^2.0.2", + "react-markdown": "4.3.1", + "typeface-roboto-condensed": "latest" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": "react-app" + }, + "browserslist": [ + ">0.2%", + "not dead", + "not ie <= 11", + "not op_mini all" + ], + "devDependencies": { + "babel-plugin-prismjs": "2.0.1" + } +} diff --git a/packages/teagan/example/public/App.js b/packages/teagan/example/public/App.js new file mode 100644 index 00000000000..89c6ad6081f --- /dev/null +++ b/packages/teagan/example/public/App.js @@ -0,0 +1,23 @@ +import React from "react"; +import freesewing from "@freesewing/core"; +import { Workbench } from "@freesewing/components"; +import "typeface-roboto-condensed"; +import "@freesewing/css-theme"; +import "./App.css"; + +import Pattern from "pattern"; + +const App = props => { + let instance = new Pattern(); + let config = instance.config; + return ( + + ); +}; + +export default App; diff --git a/packages/teagan/example/public/favicon.ico b/packages/teagan/example/public/favicon.ico new file mode 100644 index 00000000000..95061a260f1 Binary files /dev/null and b/packages/teagan/example/public/favicon.ico differ diff --git a/packages/teagan/example/public/index.html b/packages/teagan/example/public/index.html new file mode 100644 index 00000000000..8c80e2fa76d --- /dev/null +++ b/packages/teagan/example/public/index.html @@ -0,0 +1,40 @@ + + + + + + + + + + + teagan + + + +
+ + + diff --git a/packages/teagan/example/public/manifest.json b/packages/teagan/example/public/manifest.json new file mode 100644 index 00000000000..d3af574595f --- /dev/null +++ b/packages/teagan/example/public/manifest.json @@ -0,0 +1,15 @@ +{ + "short_name": "teagan", + "name": "teagan", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/packages/teagan/example/src/App.js b/packages/teagan/example/src/App.js new file mode 100644 index 00000000000..77dc815ed3f --- /dev/null +++ b/packages/teagan/example/src/App.js @@ -0,0 +1,32 @@ +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' + +import Pattern from 'pattern' + +const App = (props) => { + let instance = new Pattern() + let config = instance.config + + // You can use this to add transations + /* + let translations = { + JSON: 'JSON', + someOtherString: 'Some other string that needs translation' + } + */ + + return ( + + ) +} + +export default App diff --git a/packages/teagan/example/src/index.js b/packages/teagan/example/src/index.js new file mode 100644 index 00000000000..9dd7ba788d4 --- /dev/null +++ b/packages/teagan/example/src/index.js @@ -0,0 +1,11 @@ +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' + +ReactDOM.render(, document.getElementById('root')) + +// If you want your app to work offline and load faster, you can change +// unregister() to register() below. Note this comes with some pitfalls. +// Learn more about service workers: http://bit.ly/CRA-PWA +serviceWorker.unregister() diff --git a/packages/teagan/example/src/serviceWorker.js b/packages/teagan/example/src/serviceWorker.js new file mode 100644 index 00000000000..44e1b1b2f8c --- /dev/null +++ b/packages/teagan/example/src/serviceWorker.js @@ -0,0 +1,123 @@ +// In production, we register a service worker to serve assets from local cache. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on the "N+1" visit to a page, since previously +// cached resources are updated in the background. + +// To learn more about the benefits of this model, read https://goo.gl/KwvDNy. +// This link also includes instructions on opting out of this behavior. + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) + +export function register(config) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebook/create-react-app/issues/2374 + return + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` + + if (isLocalhost) { + // This is running on localhost. Let's check if a service worker still exists or not. + checkValidServiceWorker(swUrl, config) + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) + } else { + // Is not local host. Just register service worker + registerValidSW(swUrl, config) + } + }) + } +} + +function registerValidSW(swUrl, config) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.') + + // Execute callback + if (config.onUpdate) { + config.onUpdate(registration) + } + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.') + + // Execute callback + if (config.onSuccess) { + config.onSuccess(registration) + } + } + } + } + } + }) + .catch(error => { + console.error('Error during service worker registration:', error) + }) +} + +function checkValidServiceWorker(swUrl, config) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload() + }) + }) + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl, config) + } + }) + .catch(() => { + console.log('No internet connection found. App is running in offline mode.') + }) +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready.then(registration => { + registration.unregister() + }) + } +} diff --git a/packages/teagan/package.json b/packages/teagan/package.json new file mode 100644 index 00000000000..81f38360c3d --- /dev/null +++ b/packages/teagan/package.json @@ -0,0 +1,94 @@ +{ + "name": "@freesewing/teagan", + "version": "2.8.1", + "description": "A FreeSewing pattern for a T-shirt", + "author": "Joost De Cock (https://github.com/joostdecock)", + "homepage": "https://freesewing.org/", + "repository": "github:freesewing/freesewing", + "license": "MIT", + "bugs": { + "url": "https://github.com/freesewing/freesewing/issues" + }, + "keywords": [ + "freesewing", + "design", + "diy", + "fashion", + "made to measure", + "parametric design", + "pattern", + "sewing", + "sewing pattern" + ], + "main": "dist/index.js", + "module": "dist/index.mjs", + "scripts": { + "clean": "rimraf dist", + "build": "rollup -c", + "test": "BABEL_ENV=production ../../node_modules/.bin/_mocha tests/*.test.js --require @babel/register", + "pubtest": "npm publish --registry http://localhost:6662", + "pubforce": "npm publish", + "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -", + "start": "rollup -c -w", + "netlify": "echo \"Not configured yet\"", + "testci": "BABEL_ENV=production ./node_modules/.bin/_mocha tests/*.test.js --require @babel/register" + }, + "peerDependencies": { + "@freesewing/core": "^2.8.1", + "@freesewing/plugin-bundle": "^2.8.1" + }, + "dependencies": {}, + "devDependencies": { + "react": "^16.13.1", + "react-dom": "^16.13.1", + "@babel/plugin-proposal-class-properties": "^7.10.4", + "babel-eslint": "^10.1.0", + "eslint": "^7.6.0", + "babel-jest": "^26.2.2", + "jest": "26.2.2", + "@freesewing/components": "^2.8.1", + "@freesewing/css-theme": "^2.8.1", + "@freesewing/i18n": "^2.8.1", + "@freesewing/mui-theme": "^2.8.1", + "@freesewing/plugin-bust": "^2.8.1", + "@freesewing/plugin-buttons": "^2.8.1", + "@freesewing/plugin-flip": "^2.8.1", + "@freesewing/utils": "^2.8.1", + "@svgr/rollup": "^2.4.1", + "cross-env": "^7.0.2", + "react-scripts": "^3.4.1", + "webpack": "^4.44.1", + "rollup": "^2.23.0", + "@rollup/plugin-babel": "^5.1.0", + "rollup-plugin-terser": "^6.1.0", + "@rollup/plugin-commonjs": "^14.0.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^8.4.0", + "rollup-plugin-peer-deps-external": "^2.2.3", + "@material-ui/core": "^4.11.0", + "@material-ui/icons": "4.9.1", + "@material-ui/lab": "^v4.0.0-alpha.56", + "react-intl": "^5.4.5", + "prop-types": "^15.7.2", + "mocha": "^8.1.0", + "chai": "^4.2.0", + "chai-string": "^1.5.0", + "@babel/register": "^7.10.5" + }, + "files": [ + "dist/*", + "README.md", + "package.json" + ], + "publishConfig": { + "access": "public", + "tag": "latest" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=6" + }, + "rollup": { + "exports": "default" + } +} diff --git a/packages/teagan/rollup.config.js b/packages/teagan/rollup.config.js new file mode 100644 index 00000000000..a885f4cb4ec --- /dev/null +++ b/packages/teagan/rollup.config.js @@ -0,0 +1,37 @@ +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import json from '@rollup/plugin-json' +import { terser } from 'rollup-plugin-terser' +import peerDepsExternal from 'rollup-plugin-peer-deps-external' +import { name, version, description, author, license, main, module, rollup } from './package.json' + +const output = [ + { + file: main, + format: 'cjs', + sourcemap: true, + exports: rollup.exports + } +] +if (typeof module !== 'undefined') + output.push({ + file: module, + format: 'es', + sourcemap: true + }) + +export default { + input: 'src/index.js', + output, + plugins: [ + peerDepsExternal(), + resolve({ modulesOnly: true }), + commonjs(), + json(), + terser({ + output: { + preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */` + } + }) + ] +} diff --git a/packages/teagan/src/back.js b/packages/teagan/src/back.js new file mode 100644 index 00000000000..d0fdbbe1df6 --- /dev/null +++ b/packages/teagan/src/back.js @@ -0,0 +1,76 @@ +import { dimensions } from './shared' + +export default function (part) { + let { + store, + sa, + Point, + points, + Path, + paths, + options, + complete, + paperless, + macro, + utils, + units, + measurements + } = part.shorthand() + + // Adjust neckline + points.cbNeck = new Point(0, points.neck.y + options.backNeckCutout * measurements.neck) + points.cbNeckCp1 = points.cbNeck.shift(0, points.neck.x / 2) + points.neckCp2 = utils.beamIntersectsY(points.neck, points.neckCp2, points.cbNeck.y) + + // Adjust armhole + points.shoulderCp1 = points.shoulderCp1.shiftFractionTowards(points.shoulder, 0.25) + + // Draw seamline + paths.seam = new Path() + .move(points.cfHem) + .line(points.hem) + .line(points.waist) + .curve_(points.waistCp2, points.armhole) + .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) + .curve(points.armholeHollowCp2, points.shoulderCp1, points.shoulder) + .line(points.neck) + .curve(points.neckCp2, points.cbNeckCp1, points.cbNeck) + .line(points.cfHem) + .close() + + // Set store values required to draft sleevecap + store.set('sleevecapEase', 0) + store.set( + 'backArmholeLength', + new Path() + .move(points.armhole) + .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) + .curve(points.armholeHollowCp2, points.shoulderCp1, points.shoulder) + .length() + ) + + // Complete pattern? + if (complete) { + macro('cutonfold', { + from: points.cfNeck, + to: points.cfHem, + grainline: true + }) + + macro('title', { at: points.title, nr: 2, title: 'back' }) + points.scaleboxAnchor = points.scalebox = points.title.shift(90, 100) + macro('scalebox', { at: points.scalebox }) + } + + // Paperless? + if (paperless) { + //dimensions(macro, points, sa) + //macro('vd', { + // from: points.cbHem, + // to: points.cbNeck, + // x: points.cbHem.x - sa - 15 + //}) + } + + return part +} diff --git a/packages/teagan/src/front.js b/packages/teagan/src/front.js new file mode 100644 index 00000000000..22237780bef --- /dev/null +++ b/packages/teagan/src/front.js @@ -0,0 +1,135 @@ +import { dimensions } from './shared' + +export default function (part) { + let { + utils, + store, + sa, + Point, + points, + Path, + paths, + Snippet, + snippets, + options, + measurements, + complete, + paperless, + macro + } = part.shorthand() + + // Hide Brian paths + for (let key of Object.keys(paths)) paths[key].render = false + + // Adapt fit to waist + let width + if (measurements.waist > measurements.hips) + width = (measurements.waist * (1 + options.hipsEase)) / 4 + else width = (measurements.hips * (1 + options.hipsEase)) / 4 + points.hem.x = width + points.hips.x = width + points.waist.x = width + points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 3) + + // Clone cb (center back) into cf (center front) + for (let key of ['Neck', 'Shoulder', 'Armhole', 'Hips', 'Hem']) { + points[`cf${key}`] = points[`cb${key}`].clone() + } + + // Neckline + points.cfNeck = new Point(0, options.necklineDepth * measurements.hpsToWaistBack) + points.cfNeckCp1 = points.cfNeck.shift(0, points.neck.x * options.necklineBend * 2) + points.neck = points.hps.shiftFractionTowards(points.shoulder, options.necklineWidth) + points.neckCp2 = points.neck + .shiftTowards(points.shoulder, points.neck.dy(points.cfNeck) * (0.2 + options.necklineBend)) + .rotate(-90, points.neck) + + // Redraw armhole + points.shoulderCp1 = utils.beamIntersectsY( + points.shoulder, + points.shoulderCp1, + points.armholePitch.y + ) + points.armholeHollowCp2 = utils.beamIntersectsX( + points.armholeHollow, + points.armholeHollowCp2, + points.armholePitch.x + ) + + // Draw seamline + paths.seam = new Path() + .move(points.cfHem) + .line(points.hem) + .line(points.waist) + .curve_(points.waistCp2, points.armhole) + .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) + .curve(points.armholeHollowCp2, points.shoulderCp1, points.shoulder) + .line(points.neck) + .curve(points.neckCp2, points.cfNeckCp1, points.cfNeck) + .line(points.cfHem) + .close() + + // Store front sleevecap length + store.set( + 'frontArmholeLength', + new Path() + .move(points.armhole) + .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) + .curve(points.armholeHollowCp2, points.shoulderCp1, points.shoulder) + .length() + ) + + // Complete pattern? + if (complete) { + macro('cutonfold', { + from: points.cfNeck, + to: points.cfHem, + grainline: true + }) + points.title = new Point(points.waist.x / 2, points.waist.y) + macro('title', { at: points.title, nr: 1, title: 'front' }) + points.logo = points.title.shift(-90, 75) + snippets.logo = new Snippet('logo', points.logo) + + if (sa) { + /* + let saShoulder = new Path().move(points.strapRight).line(points.strapLeft).offset(sa) + paths.saShoulder = new Path() + .move(points.strapRight) + .line(saShoulder.start()) + .join(saShoulder) + .line(points.strapLeft) + .attr('class', 'fabric sa') + paths.sa = new Path() + .move(points.cfHem) + .line(points.cfHem) + .join( + new Path() + .move(points.cfHem) + .line(points.hem) + .offset(sa * 2.5) + ) + .join( + new Path() + .move(points.hem) + .curve_(points.waist, points.armhole) + .offset(sa) + .line(points.armhole) + ) + .attr('class', 'fabric sa') + */ + } + } + + // Paperless? + if (paperless) { + //dimensions(macro, points, sa) + //macro('vd', { + // from: points.cfHem, + // to: points.cfNeck, + // x: points.cfHem.x - sa - 15 + //}) + } + + return part +} diff --git a/packages/teagan/src/index.js b/packages/teagan/src/index.js new file mode 100644 index 00000000000..605f5791e05 --- /dev/null +++ b/packages/teagan/src/index.js @@ -0,0 +1,27 @@ +import freesewing from '@freesewing/core' +import Brian from '@freesewing/brian' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' +// Parts +import draftBack from './back' +import draftFront from './front' +import draftSleeve from './sleeve' + +// Create design +const Pattern = new freesewing.Design(config, plugins) + +// Attach draft methods to prototype +Pattern.prototype.draftBase = function (part) { + // Getting the base part from Brian + return new Brian(this.settings).draftBase(part) +} +Pattern.prototype.draftSleevecap = function (part) { + // Getting the sleevecap part from Brian + let brian = new Brian(this.settings) + return brian.draftSleevecap(part) +} +Pattern.prototype.draftFront = (part) => draftFront(part) +Pattern.prototype.draftBack = (part) => draftBack(part) +Pattern.prototype.draftSleeve = (part) => draftSleeve(part) + +export default Pattern diff --git a/packages/teagan/src/shared.js b/packages/teagan/src/shared.js new file mode 100644 index 00000000000..3c4fc43915f --- /dev/null +++ b/packages/teagan/src/shared.js @@ -0,0 +1,37 @@ +export function dimensions(macro, points, sa) { + macro('hd', { + from: points.cfHem, + to: points.hem, + y: points.hem.y + sa * 2.5 + 15 + }) + macro('hd', { + from: points.cfNeck, + to: points.strapLeft, + y: points.neck.y - sa - 15 + }) + macro('hd', { + from: points.cfNeck, + to: points.strapRight, + y: points.neck.y - sa - 30 + }) + macro('vd', { + from: points.hem, + to: points.armhole, + x: points.armhole.x + sa + 15 + }) + macro('vd', { + from: points.hem, + to: points.strapRight, + x: points.armhole.x + sa + 30 + }) + macro('vd', { + from: points.hem, + to: points.strapLeft, + x: points.armhole.x + sa + 45 + }) + macro('hd', { + from: points.cfNeck, + to: points.armhole, + y: points.neck.y - sa - 45 + }) +} diff --git a/packages/teagan/src/sleeve.js b/packages/teagan/src/sleeve.js new file mode 100644 index 00000000000..e5357d88f81 --- /dev/null +++ b/packages/teagan/src/sleeve.js @@ -0,0 +1,67 @@ +import { dimensions } from './shared' + +export default function (part) { + let { + store, + sa, + Point, + points, + Path, + paths, + options, + complete, + paperless, + macro, + utils, + units, + measurements + } = part.shorthand() + + let height = points.bicepsRight.x * options.sleeveLength + let width = measurements.biceps * (1 + options.bicepsEase) * (1 + options.sleeveEase) + if (width > points.bicepsRight.x * 2) width = points.bicepsRight.x * 2 + points.hemLeft = new Point(width / -2, height) + points.hemRight = new Point(width / 2, height) + + paths.sleevecap = new Path() + .move(points.bicepsRight) + .curve(points.bicepsRight, points.capQ1Cp1, points.capQ1) + .curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2) + .curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3) + .curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4) + .curve(points.capQ4Cp2, points.bicepsLeft, points.bicepsLeft) + .line(points.hemLeft) + .line(points.hemRight) + .line(points.bicepsRight) + + let target = store.get('frontArmholeLength') + store.get('backArmholeLength') + let ist = paths.sleevecap.length() + console.log({ target, ist }) + + return part + + // Complete pattern? + if (complete) { + macro('cutonfold', { + from: points.cfNeck, + to: points.cfHem, + grainline: true + }) + + macro('title', { at: points.title, nr: 2, title: 'back' }) + points.scaleboxAnchor = points.scalebox = points.title.shift(90, 100) + macro('scalebox', { at: points.scalebox }) + } + + // Paperless? + if (paperless) { + //dimensions(macro, points, sa) + //macro('vd', { + // from: points.cbHem, + // to: points.cbNeck, + // x: points.cbHem.x - sa - 15 + //}) + } + + return part +} diff --git a/packages/teagan/tests/shared.test.js b/packages/teagan/tests/shared.test.js new file mode 100644 index 00000000000..6886d615f41 --- /dev/null +++ b/packages/teagan/tests/shared.test.js @@ -0,0 +1,39 @@ +// This file is auto-generated. +// Changes you make will be overwritten. +const expect = require("chai").expect; +const models = require("@freesewing/models") +const patterns = require("@freesewing/pattern-info") + +const Teagan = require('../dist') + +// Shared tests +const testPatternConfig = require('../../../tests/patterns/config') +const testPatternDrafting = require('../../../tests/patterns/drafting') +const testPatternSampling = require('../../../tests/patterns/sampling') + +// Test config +testPatternConfig( + 'teagan', + new Teagan(), + expect, + models, + patterns +) + +// Test drafting +testPatternDrafting( + 'teagan', + Teagan, + expect, + models, + patterns +) + +// Test sampling +testPatternSampling( + 'teagan', + Teagan, + expect, + models, + patterns +)