tada: Initial commit
This commit is contained in:
parent
a9eb16a021
commit
3b62ee3ad1
10 changed files with 5034 additions and 2 deletions
13
packages/plugin-grainline/.editorconfig
Normal file
13
packages/plugin-grainline/.editorconfig
Normal 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/plugin-grainline/.gitignore
vendored
Normal file
62
packages/plugin-grainline/.gitignore
vendored
Normal 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
|
4
packages/plugin-grainline/.npmignore
Normal file
4
packages/plugin-grainline/.npmignore
Normal file
|
@ -0,0 +1,4 @@
|
|||
src
|
||||
.editorconfig
|
||||
rollup.browser.js
|
||||
rollup.node.js
|
|
@ -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
|
||||
|
|
|
@ -1,2 +1,88 @@
|
|||
<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> <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>
|
||||
|
||||
# plugin-grainline
|
||||
A freesewing macro to add grainline indicators to your patterns
|
||||
|
||||
A freesewing plugin to add grainline indicators to your patterns.
|
||||
|
||||
## Install
|
||||
|
||||
On node.js:
|
||||
|
||||
```sh
|
||||
npm install @freesewing/plugin-grainline
|
||||
```
|
||||
|
||||
in the browser, simply include this script:
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-grainline"></script>
|
||||
```
|
||||
|
||||
## Loading this plugin
|
||||
|
||||
To load this plugin, add it to your instantiated pattern.
|
||||
|
||||
On node.js:
|
||||
|
||||
```js
|
||||
import pattern from '@freesewing/pattern-brian'
|
||||
import grainline from '@freesewing/plugin-grainline'
|
||||
|
||||
pattern.with(grainline);
|
||||
```
|
||||
|
||||
In the browser, this plugin will register as `freesewing.plugins.grainline`.
|
||||
Since it's a build-time plugin, it will be loaded by the pattern.
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="https://unpkg.com/freesewing"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-grainline"></script>
|
||||
<script type="text/javascript" src="https://unpkg.com/@freesewing/pattern-brian"></script>
|
||||
|
||||
<script>
|
||||
var pattern = freesewing.patterns.brian;
|
||||
</script>
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This plugin provides the `grainline` macro.
|
||||
|
||||
> The macro method is available from the `shorthand()` method on an instantiated pattern part.
|
||||
|
||||
```js
|
||||
macro('grainline', {
|
||||
from: points.cbNeck
|
||||
, to: points.cbHips
|
||||
});
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- `to`: A point object at the start of the grainline indicator
|
||||
- `from`: A point object at the end of the grainline indicator
|
||||
|
||||
As all freesewing macros, bundle these parameters into a single object.
|
||||
|
||||
## Example
|
||||
|
||||

|
||||
|
||||
|
||||
## Build
|
||||
|
||||
To build this plugin, run:
|
||||
|
||||
```sh
|
||||
npm run build
|
||||
```
|
||||
|
||||
## License: MIT
|
||||
|
||||
See [the license file](https://github.com/freesewing/plugin-theme/blob/master/LICENSE)
|
||||
for details.
|
||||
|
|
4738
packages/plugin-grainline/package-lock.json
generated
Normal file
4738
packages/plugin-grainline/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
69
packages/plugin-grainline/package.json
Normal file
69
packages/plugin-grainline/package.json
Normal file
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"name": "@freesewing/plugin-grainline",
|
||||
"version": "0.0.1",
|
||||
"description": "A freesewing plugin to add grainline indicators on your patterns",
|
||||
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/freesewing/plugin-grainline#readme",
|
||||
"repository": "github:freesewing/plugin-grainline",
|
||||
"bugs": {
|
||||
"url": "https://github.com/freesewing/plugin-grainline/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"freesewing",
|
||||
"plugin",
|
||||
"sewing",
|
||||
"patterns",
|
||||
"grainline"
|
||||
],
|
||||
"main": "dist/index.js",
|
||||
"unpkg": "dist/browser.js",
|
||||
"module": "dist/index.mjs",
|
||||
"scripts": {
|
||||
"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",
|
||||
"precommit": "npm run pretty && lint-staged",
|
||||
"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 --file dist/browser.js --format iife --name freesewing.plugins.grainline",
|
||||
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs",
|
||||
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format 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"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^8.2.6",
|
||||
"eslint": "^5.2.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-plugin-prettier": "^2.6.2",
|
||||
"husky": "^0.14.3",
|
||||
"lint-staged": "^7.2.0",
|
||||
"prettier": "^1.13.7",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup-plugin-babel": "^3.0.7",
|
||||
"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"
|
||||
]
|
||||
}
|
23
packages/plugin-grainline/rollup.js
Normal file
23
packages/plugin-grainline/rollup.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { terser } from "rollup-plugin-terser";
|
||||
import babel from "rollup-plugin-babel";
|
||||
import resolve from "rollup-plugin-node-resolve";
|
||||
import json from "rollup-plugin-json";
|
||||
import { version, name, description, author, license } from "./package.json";
|
||||
|
||||
export default {
|
||||
input: "src/index.js",
|
||||
plugins: [
|
||||
resolve({
|
||||
browser: true
|
||||
}),
|
||||
json(),
|
||||
babel({
|
||||
exclude: "node_modules/**"
|
||||
}),
|
||||
terser({
|
||||
output: {
|
||||
preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
||||
}
|
||||
})
|
||||
]
|
||||
};
|
29
packages/plugin-grainline/src/index.js
Normal file
29
packages/plugin-grainline/src/index.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import markers from "./lib/markers";
|
||||
import { version, name } from "../package.json";
|
||||
|
||||
export default {
|
||||
name: name,
|
||||
version: version,
|
||||
hooks: {
|
||||
preRender: function(next) {
|
||||
this.defs += markers;
|
||||
this.attributes.add(`freesewing:${name}`, version);
|
||||
next();
|
||||
}
|
||||
},
|
||||
macros: {
|
||||
grainline: function(so) {
|
||||
let points = this.points;
|
||||
points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05);
|
||||
points.grainlineTo = so.to.shiftFractionTowards(so.from, 0.05);
|
||||
this.paths.grainline = new this.Path()
|
||||
.move(points.grainlineFrom)
|
||||
.line(points.grainlineTo)
|
||||
.attr("class", "note")
|
||||
.attr("marker-start", "url(#grainlineFrom)")
|
||||
.attr("marker-end", "url(#grainlineTo)")
|
||||
.attr("data-text", "grainline")
|
||||
.attr("data-text-class", "center fill-note");
|
||||
}
|
||||
}
|
||||
};
|
8
packages/plugin-grainline/src/lib/markers.js
Normal file
8
packages/plugin-grainline/src/lib/markers.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
export default `
|
||||
<marker orient="auto" refY="0.0" refX="0.0" id="grainlineFrom" style="overflow:visible;" >
|
||||
<path class="note fill-note" d="M 0,0 L 12,-4 C 10,-2 10,2 12, 4 z" />
|
||||
</marker>
|
||||
<marker orient="auto" refY="0.0" refX="0.0" id="grainlineToTo" style="overflow:visible;" >
|
||||
<path class="note fill-note" d="M 0,0 L -12,-4 C -10,-2 -10,2 -12, 4 z" />
|
||||
</marker>
|
||||
`;
|
Loading…
Add table
Add a link
Reference in a new issue