1
0
Fork 0

tada: First commit

This commit is contained in:
Joost De Cock 2018-07-22 18:54:58 +02:00
parent 3d82690400
commit 6efda92f63
11 changed files with 6455 additions and 3 deletions

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

View file

@ -1,3 +1,4 @@
dist
# Logs
logs
*.log

View file

@ -0,0 +1,4 @@
src
.editorconfig
.babelrc
webpack.config.js

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 freesewing / plugins
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,55 @@
# macro-title
A freesewing macro to add a tile to your pattern parts
<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 / plugins / macro-title
This is a macro for [freesewing](https://github.com/freesewing/freesewing)
to add a title to your pattern part.
## Install
```sh
npm install @freesewing-plugins/macro-title --save
```
## Loading the plugin
Plugins are loaded by the `withPlugin` method of an instantiated freesewing pattern:
```js
import F from 'freesewing';
import partTitle from '@freesewing-plugins/macro-title';
var pattern = new F.pattern()
.withPlugin(partTitle);
```
## Using the plugin
This plugin provides the `title` macro which you can call with the `macro` method on an instantiated pattern part:
```js
part.macro('title', {
at: points.titleAnchor
, nr: 2
, name: 'backBlock'
, pattern: 'brian'
});
```
### Parameters
- `at`: A point object to anchor the title on
- `nr`: The part number
- `name`: The part name
- `pattern`: The name of the pattern
As all freesewing macros, bundle these parameters into a single object.
## Example
FIXME: include example

6258
packages/plugin-title/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,43 @@
{
"name": "@freesewing-plugins/macro-title",
"version": "0.1.0",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"description": "A freesewing macro to add a title to your pattern parts",
"keywords": [
"freesewing",
"macro",
"sewing",
"patterns",
"title"
],
"homepage": "https://github.com/freesewing-plugins/macro-title#readme",
"repository": "github:freesewing-plugins/macro-title",
"bugs": {
"url": "https://github.com/freesewing-plugins/macro-title/issues"
},
"main": "dist/index.js",
"unpkg": "dist/_bundle.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf dist",
"nodebuild": "babel src -d dist --no-babelrc",
"browserbuild": "npx webpack-cli --config webpack.config.js",
"build": "npm run clean && npm run nodebuild && npm run browserbuild"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.53",
"@babel/preset-env": "7.0.0-beta.53",
"rimraf": "^2.6.2",
"babel-cli": "6.26.0",
"babel-loader": "8.0.0-beta.4",
"webpack": "4.16.0",
"webpack-cli": "3.0.8"
},
"files": [
"dist/*",
"README.md",
"package-lock.json",
"package.json"
]
}

View file

@ -0,0 +1,28 @@
import style from './lib/style';
const VERSION = require('../package.json').version;
module.exports = {
hooks: {
preRenderSvg: function(next) {
// Without this, our custom attribute won't be valid
this.attributes.add("xmlns:freesewing-plugins", "http://freesewing.org/namespaces/freesewing-plugins");
this.attributes.add("freesewing-plugins:macro-title", VERSION);
this.style += style;
next();
}
}
, macros: {
title: function(next, so) {
let points = this.points;
so.at.attr('data-text', so.nr)
.attr('data-text-class', 'title-nr');
points.titleName = so.at.shift(-90, 20)
.attr('data-text', title)
.attr('data-text-class', 'title-name');
points.titlePattern = so.at.shift(-90, 40)
.attr('data-text', pattern)
.attr('data-text-class', 'title-pattern');
next();
}
}
}

View file

@ -0,0 +1,8 @@
module.exports = `
<marker orient="auto" refY="0.0" refX="0.0" id="cutonfoldFrom" style="overflow:visible;" >
<path style="stroke: #ff5b77; fill: #ff5b77;" 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="cutonfoldTo" style="overflow:visible;" >
<path style="stroke: #ff5b77; fill: #ff5b77;" d="M 0,0 L -12,-4 C -10,-2 -10,2 -12, 4 z" />
</marker>
`;

View file

@ -0,0 +1,5 @@
module.exports = `
text.title-nr{ font-size: 24; }
text.title-name{ font-size: 16; }
text.title-pattern{ font-size: 6; }
`;

View file

@ -0,0 +1,39 @@
const path = require('path');
var webpack = require('webpack');
module.exports = {
mode: 'production',
target: 'web',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '_bundle.js',
libraryTarget: 'var',
library: 'freesewing_macro_title'
},
plugins: [
new webpack.DefinePlugin({
VERSION: JSON.stringify(require("./package.json").version)
}),
new webpack.IgnorePlugin(/^\.\.\/package.json$/)
],
module: {
rules:[
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.txt$/,
exclude: /node_modules/,
use: 'raw-loader'
},
]
}
};