diff options
| author | Petri Hienonen <petri.hienonen@gmail.com> | 2025-11-04 17:07:24 +0200 |
|---|---|---|
| committer | Petri Hienonen <petri.hienonen@gmail.com> | 2025-11-09 22:48:55 +0200 |
| commit | be7ec90b500ac68e053f2b58feb085247ef95817 (patch) | |
| tree | aef7732ce0bbe505c6bc8486e1d0da2c06990e6a /app/svg.js | |
| parent | a4ed99a370930b1a0c0f065906ed99c15a015fd4 (diff) | |
| download | housing-be7ec90b500ac68e053f2b58feb085247ef95817.tar.zst | |
Refactor application to use couchbase
Diffstat (limited to 'app/svg.js')
| -rw-r--r-- | app/svg.js | 32 |
1 files changed, 7 insertions, 25 deletions
@@ -1,19 +1,11 @@ import { LineString, Point, Polygon } from "geom"; -/** - * Class representing options for SVG elements - * @property {Record<string, string>} attributes - SVG attributes - * @property {Record<string, string>} styles - CSS styles - * @property {string} id - Element ID - * @property {string[]} classes - CSS classes - * @property {SVGElement[]} children - Child elements - */ export class SvgOptions { attributes; - styles; - id; - classes; children; + classes; + id; + styles; /** * @param {Object} [options] @@ -25,10 +17,10 @@ export class SvgOptions { */ constructor({ attributes = {}, styles = {}, id = "", classes = [], children = [] } = {}) { this.attributes = attributes; - this.styles = styles; - this.id = id; - this.classes = classes; this.children = children; + this.classes = classes; + this.id = id; + this.styles = styles; } } @@ -127,7 +119,7 @@ export class Svg { static path(lineString, options = new SvgOptions()) { const element = document.createElementNS("http://www.w3.org/2000/svg", "path"); element.setAttribute("d", Svg.getPath(lineString.coordinates)); - for (const [key, value] of Object.entries({ fill: "none", ...options.attributes })) { + for (const [key, value] of Object.entries(options.attributes)) { element.setAttribute(key, value); } Object.assign(element.style, options.styles); @@ -284,14 +276,4 @@ export class Svg { element.append(...options.children.filter(Boolean)); return element; } - - /** - * Clear all children from an element - * @param {SVGElement} element - */ - static clear(element) { - while (element.firstChild) { - element.removeChild(element.firstChild); - } - } } |
