- added `npm build:dev` to let you develop without getting too annoyed
- added `beziere()` and `steps()` to generate easing functions
- added `insertAfter()` and `insertBefore`
+- added `SVG.Style` which can be created with `style()` or `fontface()`
### Removed
- removed `SVG.Array.split()` function
* @copyright Wout Fierens <wout@mick-wout.com>
* @license MIT
*
-* BUILT: Thu Nov 08 2018 11:10:36 GMT+0100 (GMT+01:00)
+* BUILT: Thu Nov 08 2018 11:29:15 GMT+0100 (GMT+01:00)
*/;
var SVG = (function () {
'use strict';
return s.toLowerCase().replace(/-(.)/g, function (m, g) {
return g.toUpperCase();
});
+ } // Convert camel cased string to string seperated
+
+ function unCamelCase(s) {
+ return s.replace(/([A-Z])/g, function (m, g) {
+ return '-' + g.toLowerCase();
+ });
} // Capitalize first letter of a string
function capitalize(s) {
});
register(Mask);
+ function cssRule(selector, rule) {
+ if (!selector) return '';
+ if (!rule) return selector;
+ var ret = selector + '{';
+
+ for (var i in rule) {
+ ret += unCamelCase(i) + ':' + rule[i] + ';';
+ }
+
+ ret += '}';
+ return ret;
+ }
+
+ var Style =
+ /*#__PURE__*/
+ function (_Element) {
+ _inherits(Style, _Element);
+
+ function Style(node) {
+ _classCallCheck(this, Style);
+
+ return _possibleConstructorReturn(this, _getPrototypeOf(Style).call(this, nodeOrNew('style', node), Style));
+ }
+
+ _createClass(Style, [{
+ key: "words",
+ value: function words(w) {
+ this.node.textContent += w || '';
+ return this;
+ }
+ }, {
+ key: "font",
+ value: function font(name, src) {
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
+ return this.rule('@font-face', _objectSpread({
+ fontFamily: name,
+ src: src
+ }, params));
+ }
+ }, {
+ key: "rule",
+ value: function rule(selector, obj) {
+ return this.words(cssRule(selector, obj));
+ }
+ }]);
+
+ return Style;
+ }(Element);
+ registerMethods('Element', {
+ style: function style(selector, obj) {
+ return this.put(new Style()).rule(selector, obj);
+ },
+ fontface: function fontface(name, src, params) {
+ return this.put(new Style()).font(name, src, params);
+ }
+ });
+
var _Symbol =
/*#__PURE__*/
function (_Container) {
Rect: Rect,
Shape: Shape,
Stop: Stop,
+ Style: Style,
Symbol: _Symbol,
Text: Text,
TextPath: TextPath,
radians: radians,
degrees: degrees,
camelCase: camelCase,
+ unCamelCase: unCamelCase,
capitalize: capitalize,
proportionalSize: proportionalSize,
getOrigin: getOrigin,
--- /dev/null
+import { nodeOrNew } from '../utils/adopter.js'
+import { registerMethods } from '../utils/methods.js'
+import { unCamelCase } from '../utils/utils.js'
+import Element from './Element.js'
+
+function cssRule (selector, rule) {
+ if (!selector) return ''
+ if (!rule) return selector
+
+ var ret = selector + '{'
+
+ for (var i in rule) {
+ ret += unCamelCase(i) + ':' + rule[i] + ';'
+ }
+
+ ret += '}'
+
+ return ret
+}
+
+export default class Style extends Element {
+ constructor (node) {
+ super(nodeOrNew('style', node), Style)
+ }
+
+ words (w) {
+ this.node.textContent += (w || '')
+ return this
+ }
+
+ font (name, src, params = {}) {
+ return this.rule('@font-face', {
+ fontFamily: name,
+ src: src,
+ ...params
+ })
+ }
+
+ rule (selector, obj) {
+ return this.words(cssRule(selector, obj))
+ }
+}
+
+registerMethods('Element', {
+ style (selector, obj) {
+ return this.put(new Style()).rule(selector, obj)
+ },
+ fontface (name, src, params) {
+ return this.put(new Style()).font(name, src, params)
+ }
+})
export { default as Rect } from './elements/Rect.js'
export { default as Shape } from './elements/Shape.js'
export { default as Stop } from './elements/Stop.js'
+export { default as Style } from './elements/Style.js'
export { default as Symbol } from './elements/Symbol.js'
export { default as Text } from './elements/Text.js'
export { default as TextPath } from './elements/TextPath.js'
})
}
+// Convert camel cased string to string seperated
+export function unCamelCase (s) {
+ return s.replace(/([A-Z])/g, function (m, g) {
+ return '-' + g.toLowerCase()
+ })
+}
+
// Capitalize first letter of a string
export function capitalize (s) {
return s.charAt(0).toUpperCase() + s.slice(1)
- Element.js
- svg
- attr.js
+- Style.js