sparkles: Properly formatted title
This commit is contained in:
parent
ddc8775275
commit
83aaa56bdf
10 changed files with 2694 additions and 4101 deletions
6551
packages/plugin-title/package-lock.json
generated
6551
packages/plugin-title/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,38 +1,65 @@
|
||||||
{
|
{
|
||||||
"name": "@freesewing-plugins/macro-title",
|
"name": "@freesewing/plugin-title",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
|
"description": "A freesewing plugin to add a title to your pattern parts",
|
||||||
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "A freesewing macro to add a title to your pattern parts",
|
"homepage": "https://github.com/freesewing/plugin-title#readme",
|
||||||
|
"repository": "github:freesewing/plugin-title",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/freesewing/plugin-title/issues"
|
||||||
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"freesewing",
|
"freesewing",
|
||||||
"macro",
|
"plugin",
|
||||||
"sewing",
|
"sewing",
|
||||||
"patterns",
|
"patterns",
|
||||||
"title"
|
"title"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/freesewing-plugins/macro-title#readme",
|
"main": "dist/node.js",
|
||||||
"repository": "github:freesewing-plugins/macro-title",
|
"unpkg": "dist/browser.js",
|
||||||
"bugs": {
|
"browser": "dist/browser.js",
|
||||||
"url": "https://github.com/freesewing-plugins/macro-title/issues"
|
"module": "src/index.js",
|
||||||
},
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"unpkg": "dist/_bundle.js",
|
|
||||||
"scripts": {
|
"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",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"nodebuild": "babel src -d dist --no-babelrc",
|
"pretty": "npx prettier --write \"src/*.js\"",
|
||||||
"browserbuild": "npx webpack-cli --config webpack.config.js",
|
"lint": "eslint --fix \"src/*.js\"",
|
||||||
"build": "npm run clean && npm run nodebuild && npm run browserbuild"
|
"browserbuild": "rollup -c rollup.browser.js",
|
||||||
|
"nodebuild": "rollup -c rollup.node.js",
|
||||||
|
"build": "npm run clean && npm run browserbuild && npm run nodebuild"
|
||||||
|
},
|
||||||
|
"husky": {
|
||||||
|
"hooks": {
|
||||||
|
"pre-commit": "lint-staged"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{js,json}": [
|
||||||
|
"prettier --write",
|
||||||
|
"git add"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "7.0.0-beta.53",
|
"babel-core": "^6.26.3",
|
||||||
"@babel/preset-env": "7.0.0-beta.53",
|
"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",
|
"rimraf": "^2.6.2",
|
||||||
"babel-cli": "6.26.0",
|
"rollup-plugin-babel": "^3.0.7",
|
||||||
"babel-loader": "8.0.0-beta.4",
|
"rollup-plugin-commonjs": "^9.1.3",
|
||||||
"webpack": "4.16.0",
|
"rollup-plugin-filesize": "^4.0.1",
|
||||||
"webpack-cli": "3.0.8"
|
"rollup-plugin-json": "^3.0.0",
|
||||||
|
"rollup-plugin-node-resolve": "^3.3.0",
|
||||||
|
"rollup-plugin-terser": "^1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
|
|
34
packages/plugin-title/rollup.browser.js
Normal file
34
packages/plugin-title/rollup.browser.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
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 meta from "./package.json";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: "src/index.js",
|
||||||
|
output: {
|
||||||
|
file: "dist/browser.js",
|
||||||
|
format: "iife",
|
||||||
|
name: "freesewing.plugins.title"
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
browser: true
|
||||||
|
}),
|
||||||
|
json(),
|
||||||
|
commonjs(),
|
||||||
|
babel({
|
||||||
|
exclude: "node_modules/**"
|
||||||
|
}),
|
||||||
|
terser({
|
||||||
|
output: {
|
||||||
|
preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
|
||||||
|
meta.description
|
||||||
|
}\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
|
||||||
|
meta.license
|
||||||
|
}\n */`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
33
packages/plugin-title/rollup.node.js
Normal file
33
packages/plugin-title/rollup.node.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import { terser } from "rollup-plugin-terser";
|
||||||
|
import filesize from "rollup-plugin-filesize";
|
||||||
|
import babel from "rollup-plugin-babel";
|
||||||
|
import json from "rollup-plugin-json";
|
||||||
|
import resolve from "rollup-plugin-node-resolve";
|
||||||
|
import meta from "./package.json";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: "src/index.js",
|
||||||
|
output: {
|
||||||
|
file: "dist/node.js",
|
||||||
|
format: "es"
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
browser: false
|
||||||
|
}),
|
||||||
|
json(),
|
||||||
|
babel({
|
||||||
|
exclude: "node_modules/**"
|
||||||
|
}),
|
||||||
|
filesize()
|
||||||
|
//terser({
|
||||||
|
// output: {
|
||||||
|
// preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
|
||||||
|
// meta.description
|
||||||
|
// }\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
|
||||||
|
// meta.license
|
||||||
|
// }\n */`
|
||||||
|
// }
|
||||||
|
//})
|
||||||
|
]
|
||||||
|
};
|
|
@ -1,26 +1,30 @@
|
||||||
import style from './lib/style';
|
import style from "./lib/style";
|
||||||
const VERSION = require('../package.json').version;
|
import { version } from "../package.json";
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
hooks: {
|
hooks: {
|
||||||
preRenderSvg: function(next) {
|
preRenderSvg: function(next) {
|
||||||
// Without this, our custom attribute won't be valid
|
this.attributes.add("freesewing:plugin-title", version);
|
||||||
this.attributes.add("xmlns:freesewing-plugins", "http://freesewing.org/namespaces/freesewing-plugins");
|
|
||||||
this.attributes.add("freesewing-plugins:macro-title", VERSION);
|
|
||||||
this.style += style;
|
this.style += style;
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
, macros: {
|
macros: {
|
||||||
title: function(next, so) {
|
title: function(next, so) {
|
||||||
so.at.attr('data-text', so.nr).attr('data-text-class', 'title-nr');
|
console.log("in plugin, so", so, this);
|
||||||
this.points.titleName = so.at.shift(-90, 20)
|
so.at.attr("data-text", so.nr).attr("data-text-class", "title-nr note");
|
||||||
.attr('data-text', title)
|
this.points.titleName = so.at
|
||||||
.attr('data-text-class', 'title-name');
|
.shift(-90, 13)
|
||||||
this.points.titlePattern = so.at.shift(-90, 40)
|
.attr("data-text", so.title || this.id)
|
||||||
.attr('data-text', pattern)
|
.attr("data-text-class", "title-name");
|
||||||
.attr('data-text-class', 'title-pattern');
|
this.points.titlePattern = so.at
|
||||||
|
.shift(-90, 20)
|
||||||
|
.attr(
|
||||||
|
"data-text",
|
||||||
|
this.context.config.name + " v" + this.context.config.version
|
||||||
|
)
|
||||||
|
.attr("data-text-class", "title-pattern fill-note");
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
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>
|
|
||||||
`;
|
|
20
packages/plugin-title/src/lib/style.css
Normal file
20
packages/plugin-title/src/lib/style.css
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
text.title-nr {
|
||||||
|
font-size: 24pt;
|
||||||
|
font-weight: 700;
|
||||||
|
fill: none;
|
||||||
|
text-anchor: middle;
|
||||||
|
dominant-baseline: reset-size;
|
||||||
|
}
|
||||||
|
text.title-name {
|
||||||
|
font-size: 7pt;
|
||||||
|
font-weight: 500;
|
||||||
|
text-anchor: middle;
|
||||||
|
dominant-baseline: reset-size;
|
||||||
|
}
|
||||||
|
text.title-pattern {
|
||||||
|
font-size: 4pt;
|
||||||
|
font-weight: 500;
|
||||||
|
dominant-baseline: reset-size;
|
||||||
|
text-anchor: middle;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
|
@ -1,5 +1 @@
|
||||||
module.exports = `
|
export default `text.title-nr{font-size:24pt;font-weight:700;fill:none;text-anchor:middle;dominant-baseline:reset-size}text.title-name{font-size:7pt;font-weight:500;text-anchor:middle;dominant-baseline:reset-size}text.title-pattern{font-size:4pt;font-weight:500;dominant-baseline:reset-size;text-anchor:middle;font-style:italic}`;
|
||||||
text.title-nr{ font-size: 24; }
|
|
||||||
text.title-name{ font-size: 16; }
|
|
||||||
text.title-pattern{ font-size: 6; }
|
|
||||||
`;
|
|
||||||
|
|
1
packages/plugin-title/src/lib/style.min.css
vendored
Normal file
1
packages/plugin-title/src/lib/style.min.css
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
text.title-nr{font-size:24pt;font-weight:700;fill:none;text-anchor:middle;dominant-baseline:reset-size}text.title-name{font-size:7pt;font-weight:500;text-anchor:middle;dominant-baseline:reset-size}text.title-pattern{font-size:4pt;font-weight:500;dominant-baseline:reset-size;text-anchor:middle;font-style:italic}
|
|
@ -1,39 +0,0 @@
|
||||||
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'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
};
|
|
Loading…
Add table
Add a link
Reference in a new issue