1
0
Fork 0

tada: Initial commit

This commit is contained in:
Joost De Cock 2018-12-22 14:45:07 +01:00
parent 90f088c6d0
commit 89de4d4499
14 changed files with 10335 additions and 1 deletions

View file

@ -0,0 +1,10 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
}
]
]
}

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/plugin-buttons/.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,4 @@
src
.editorconfig
rollup.browser.js
rollup.node.js

View file

@ -0,0 +1,21 @@
MIT License
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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1,2 +1,59 @@
<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>
<p align="center">
<a href="https://travis-ci.org/freesewing/plugin-buttons"><img src="https://badgen.net/travis/freesewing/plugin-buttons/master" alt="Travis build"></a>
<a href="https://www.npmjs.com/package/@freesewing/plugin-buttons"><img src="https://badgen.net/npm/v/@freesewing/plugin-buttons" alt="Version"></a>
<a href="https://www.npmjs.com/package/@freesewing/plugin-buttons"><img src="https://badgen.net/npm/license/@freesewing/plugin-buttons" alt="License"></a>
<a href="https://codecov.io/gh/freesewing/plugin-buttons"><img src="https://badgen.net/codecov/c/github/freesewing/plugin-buttons/master" alt="Code coverage"></a>
<a href="https://deepscan.io/dashboard#view=project&pid=3267&bid=27574"><img src="https://deepscan.io/api/projects/3267/branches/27574/badge/grade.svg" alt="DeepScan grade"></a>
<a href="https://gitter.im/freesewing/freesewing"><img src="https://badgen.net/badge/chat/on%20Gitter/cyan" alt="Chat on Gitter"></a>
<a href="https://freesewing.org/patrons/join"><img src="https://badgen.net/badge/become/a%20Patron/FF5B77" alt="Become a Patron"></a>
</p>
# plugin-buttons
A freesewing plugin that provides button and buttonhole snippets
A freesewing plugin that provides button and buttonhole snippets.
## Install
Install this plugin from NPM:
```sh
npm install --save @freesewing/plugin-buttons
```
## Usage
To load this plugin, add it to your instantiated pattern:
```js
import freesewing from 'freesewing'
import buttons from '@freesewing/plugin-buttons'
const Simon = function(settings) {
freesewing.Pattern.call(this, config);
this
.use(buttons)
.apply(settings);
return this;
}
```
You now have the `button` and `buttonhole` snippets available:
```js
snippets.btn = new Snippet("button", points.buttonAnchor);
snippets.btnhole = new Snippet("buttonhole", points.buttonholeAnchor);
```
FIXME: Link to documentation
## Where to get help
Questions? Stuck? The [freesewing chat room on Gitter](https://gitter.im/freesewing/freesewing)
is the best place to ask for help.

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

10030
packages/plugin-buttons/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,79 @@
{
"name": "@freesewing/plugin-buttons",
"version": "0.0.1",
"description": "A freesewing plugin that provides button and buttonhole snippets",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"homepage": "https://github.com/freesewing/plugin-buttons#readme",
"repository": "github:freesewing/plugin-buttons",
"bugs": {
"url": "https://github.com/freesewing/plugin-buttons/issues"
},
"keywords": [
"freesewing",
"plugin",
"sewing patterns",
"snippets"
],
"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": "nyc mocha --require @babel/register tests/*.test.js",
"report": "nyc report --reporter=html mocha --require @babel/register tests/*.test.js",
"coverage": "nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && ./node_modules/.bin/codecov",
"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.buttons",
"nodebuild": "rollup -c rollup.js --file dist/index.js --format cjs",
"modulebuild": "rollup -c rollup.js --file dist/index.mjs --format es",
"rebuild": "npm run nodebuild && npm run modulebuild",
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/*.{js,json}": [
"prettier --write",
"git add"
]
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0",
"chai": "^4.1.2",
"chai-string": "1.4.0",
"codecov": "^3.1.0",
"eslint": "^5.2.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.6.2",
"freesewing": "^0.26.1",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"mocha": "^5.2.0",
"nyc": "12.0.2",
"prettier": "^1.13.7",
"rimraf": "^2.6.2",
"rollup": "^0.66.2",
"rollup-plugin-babel": "^4.0.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,27 @@
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 */`
}
})
]
};

View file

@ -0,0 +1 @@
export default '<g id="button"><circle cx="0" cy="0" r="3.4" style="stroke:#000000;fill:none;stroke-width:1;"/><circle cx="-1" cy="-1" r="0.5" style="stroke:none;fill:#000000;"/><circle cx="1" cy="-1" r="0.5" style="stroke:none;fill:#000000;" /><circle cx="1" cy="1" r="0.5" style="stroke:none;fill:#000000;" /><circle cx="-1" cy="1" r="0.5" style="stroke:none;fill:#000000;" /></g>';

View file

@ -0,0 +1 @@
export default '<g id="buttonhole"><path style="fill:none;stroke:#000000;" d="M -1,-5 L 1,-5 L 1,5 L -1,5 z" /><path style="fill:#000000;stroke:none;" d="M -1,-5 L 1,-5 L 1,-4 L -1,-4 z M -1,5 L 1,5 L 1,4 L -1,4 z" /></g>';

View file

@ -0,0 +1,15 @@
import button from "./button";
import buttonhole from "./buttonhole";
import { name, version } from "../package.json";
export default {
name: name,
version: version,
hooks: {
preRender: function(svg) {
if (svg.attributes.get("freesewing:plugin-buttons") === false)
svg.attributes.set("freesewing:plugin-buttons", version);
svg.defs += button+buttonhole;
}
}
};

View file

@ -0,0 +1,14 @@
import freesewing from "freesewing";
import { version } from "../package.json";
let chai = require("chai");
let expect = chai.expect;
chai.use(require('chai-string'));
let plugin = require("../dist/index.js");
it("Should set the plugin name:version attribute", () => {
let pattern = new freesewing.Pattern();
pattern.use(plugin).draft().render();
expect(pattern.svg.attributes.get("freesewing:plugin-buttons")).to.equal(
version
);
});