1
0
Fork 0

tada: Initial commit based on pattern template

This commit is contained in:
Joost De Cock 2018-08-14 10:22:48 +02:00
parent 5d4291d0c4
commit 5ef66195de
21 changed files with 7571 additions and 3 deletions

View file

@ -0,0 +1,3 @@
{
"plugins": ["transform-object-rest-spread"]
}

View file

@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

62
packages/examples/.gitignore vendored Normal file
View file

@ -0,0 +1,62 @@
dist
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next

View file

@ -0,0 +1,2 @@
src
.editorconfig

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 freesewing
Copyright (c) 2018 Joost De Cock
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -1,2 +1,71 @@
# examples
An freesewing pattern with examples used throughout our documentation
<p align="center">
<a title="Go to freesewing.org" href="https://freesewing.org/"><img src="https://freesewing.org/img/logo/black.svg" align="center" width="150px" alt="Freesewing logo"/></a>
</p>
<h4 align="center"><em>&nbsp;<a title="Go to freesewing.org" href="https://freesewing.org/">freesewing</a></em>
<br><sup>a library for made-to-measure sewing patterns</sup>
</h4>
# freesewing pattern template
This repository contains all the boilerplate to jump-start your freesewing pattern.
It contains:
- A config file with some options and measurements as example
- Code structure with two example pattern parts
- An index HTML file that you can open in your browser to see your progress
- A package.json file with all the scripts to build/lint/publish your work
- A rollup configuration that will transpile your code for Node.js, the browser, and as an ES6 module
- Comes preloaded with the freesewing plugin bundle
- Your HTML preview also loads the theme, designer, validate, and debug plugins
- Comes with both models and antman to test your patterns with
## Getting started
Simply fork this repository, or download a local copy.
Then, in its root directory run:
```js
npm install
```
This will install all dependencies. When you're done, you can run:
```js
npm run build
```
Which will build the code for all targets.
You can open the index.html file in your browser, and it will show your pattern.
## Configuration
To make this pattern your own, all you have to do is pick a name.
Then, change **template** into your own name in both the config file
and package.json.
## Development
The source code is in the src directory. You can make changes and check your
progress in your browser.
Make sure to keep the browser console open, as the debug plugin will provide you
with extra info there. This pattern also comes with the designer plugin that will
log info to the console when you hover over a point.
While developing, you can speed up your build by running:
```js
npm run browserbuild
```
As this will only run the build for the browser.
## Getting help
If you have any questions, help is available.
The [freesewing developer documentation](FIXME) is a good place to start.
Or, [join our chat room on Gitter](https://gitter.im/freesewing/freesewing),
the best place to ask questions.

View file

@ -0,0 +1,3 @@
export default {
name: "examples"
};

View file

@ -0,0 +1,62 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Examples</title>
<script type="text/javascript" src="node_modules/freesewing/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-bundle/dist/browser.js"></script>
<script type="text/javascript" src="dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-theme/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-designer/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-debug/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-validate/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/models/dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/antman/dist/browser.js"></script>
</head>
<body>
<div id="svg"></div>
<script>
var pattern = freesewing.patterns.examples
.with(freesewing.plugins.debug)
.with(freesewing.plugins.theme)
.with(freesewing.plugins.designer)
.with(freesewing.plugins.validate)
;
pattern.settings.measurements = freesewing.models.men.manSize36;
// Uncomment this line to enable paperless
//pattern.settings.paperless = true;
// Some default settings
pattern.settings.sa = 10;
pattern.settings.units = 'metric';
//pattern.sampleOption('chestEase');
//pattern.sampleMeasurement('chestCircumference');
//pattern.sampleModels(freesewing.models.men);
//pattern.sampleModels(freesewing.models.antman);
pattern.draft();
document.getElementById("svg").innerHTML = pattern.render();
function pointHover(evt) {
var point = evt.target;
var id = point.id;
var cx = point.getAttribute('x');
var cy = point.getAttribute('y');
var name = point.getAttribute('data-point');
var part = point.getAttribute('data-part');
console.log(name+' ('+cx+', '+cy+') @ '+part);
var scale = 2;
cx = cx-scale*cx;
cy = cy-scale*cy;
point.setAttribute("transform", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');
pointUnhover(id);
}
function pointUnhover(id) {
setTimeout(function(){
document.getElementById(id).removeAttribute("transform", '');
}, 500);
}
</script>
</body>
</html>

7139
packages/examples/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,85 @@
{
"version": "0.0.1",
"name": "@freesewing/examples",
"description": "Freesewing examples for our documentation",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"homepage": "https://github.com/freesewing/examples#readme",
"repository": "github:freesewing/examples",
"bugs": {
"url": "https://github.com/freesewing/examples/issues"
},
"keywords": [
"freesewing",
"pattern",
"sewing",
"menswear",
"examples"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"unpkg": "dist/browser.js",
"scripts": {
"precommit": "npm run pretty && lint-staged",
"patch": "npm version patch -m ':bookmark: v%s' && npm run build",
"minor": "npm version minor -m ':bookmark: v%s' && npm run build",
"major": "npm version major -m ':bookmark: v%s' && npm run build",
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist",
"pretty": "npx prettier --write 'src/*.js'",
"lint": "eslint --fix 'src/*.js'",
"browserbuild": "rollup -c rollup.js -o dist/browser.js -f iife -n freesewing_patterns_examples --footer 'freesewing.patterns.examples = freesewing_patterns_examples;'",
"nodebuild": "rollup -c rollup.js -o dist/index.js -f cjs",
"modulebuild": "rollup -c rollup.js -o dist/index.mjs -f es",
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,json}": [
"prettier --write",
"git add"
]
},
"dependencies": {
"freesewing": "^0.7.1",
"@freesewing/plugin-bundle": "0.0.1"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.56",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.56",
"@babel/preset-env": "7.0.0-beta.56",
"@freesewing/antman": "0.2.0",
"@freesewing/models": "0.4.0",
"@freesewing/plugin-debug": "0.0.1",
"@freesewing/plugin-designer": "0.6.0",
"@freesewing/plugin-theme": "0.10.0",
"@freesewing/plugin-validate": "0.0.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-loader": "^8.0.0-beta.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"eslint": "5.3.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.2",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"prettier": "1.14.0",
"rimraf": "^2.6.2",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "9.1.3",
"rollup-plugin-filesize": "^4.0.1",
"rollup-plugin-json": "^3.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-terser": "^1.0.1"
},
"files": [
"dist/*",
"README.md",
"package-lock.json",
"package.json"
]
}

View file

@ -0,0 +1,33 @@
import { terser } from "rollup-plugin-terser";
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import json from "rollup-plugin-json";
import path from "path";
import { name, version, description, author, license } from "./package.json";
export default {
input: "src/index.js",
plugins: [
resolve({
browser: true
}),
json(),
commonjs(),
babel({
exclude: "node_modules/**"
}),
terser({
output: {
preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
}
})
],
external: ["freesewing", "@freesewing/plugin-bundle"],
output: {
globals: {
freesewing: "freesewing",
"@freesewing/plugin-bundle": "freesewing.plugins.bundle"
}
}
};

View file

@ -0,0 +1,30 @@
import freesewing from "freesewing";
var back = {
draft: function(part) {
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro} = part.shorthand();
// Do your work here :)
points.start = new Point(0, 0);
points.end = new Point(75, 0);
paths.example = new Path()
.move(points.start)
.line(points.end)
.attr("data-text", "This is the front part")
.attr("data-text-class", "center");
// Final?
if (final) {
}
// Paperless?
if (paperless) {
}
return part;
}
};
export default back;

View file

@ -0,0 +1,23 @@
import freesewing from "freesewing";
var front = {
draft: function(part) {
// prettier-ignore
let {store, sa, Point, points, Path, paths, Snippet, snippets, options, measurements, final, paperless, macro} = part.shorthand();
// Building on top of back, just need to change the text
paths.example.attributes.set("data-text", "This is the back part");
// Final?
if (final) {
}
// Paperless?
if (paperless) {
}
return part;
}
};
export default front;

View file

@ -0,0 +1,24 @@
import freesewing from "freesewing";
import pluginBundle from "@freesewing/plugin-bundle";
import config from "../config/config";
import { version } from "../package.json";
import back from "./back";
import front from "./front";
var pattern = new freesewing.Pattern({ version: version, ...config }).with(
pluginBundle
);
pattern.draft = function() {
this.parts.back = this.draftBack(new pattern.Part());
this.parts.front = this.draftFront(new pattern.Part().copy(this.parts.back));
return pattern;
};
pattern.draftBack = part => back.draft(part);
pattern.draftFront = part => front.draft(part);
export default pattern;

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Brian</title>
</head>
<body>
<div id="svg"></div>
<script type="text/javascript" src="freesewing.js"></script>
<script>
console.log(freesewing);
</script>
</body>
</html>

View file

@ -0,0 +1 @@
../../antmantest/dist/browser.js

View file

@ -0,0 +1 @@
../../plugins/plugin-debug/dist/browser.js

View file

@ -0,0 +1 @@
../../plugins/plugin-designer/dist/browser.js

View file

@ -0,0 +1 @@
../../models/dist/browser.js

View file

@ -0,0 +1 @@
../../plugins/plugin-theme/dist/browser.js

View file

@ -0,0 +1 @@
../../plugins/plugin-validate/dist/browser.js