@alegendstale/holly-components 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,11 +6,11 @@ type EventMap = {
6
6
  export declare class DrawSvg extends ResponsiveSvg {
7
7
  static styles: import("lit").CSSResult[];
8
8
  isIntersecting: boolean;
9
+ protected svgClasses(): {};
9
10
  protected intersectionObserver: IntersectionObserver;
10
11
  emitter: EventEmitter<EventMap>;
11
12
  connectedCallback(): void;
12
13
  disconnectedCallback(): void;
13
- render(): import("lit-html").TemplateResult<1>;
14
14
  }
15
15
  declare global {
16
16
  interface HTMLElementTagNameMap {
@@ -1 +1 @@
1
- {"version":3,"file":"draw-svg.d.ts","sourceRoot":"","sources":["../../../src/components/draw-svg/draw-svg.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,KAAK,QAAQ,GAAG;IACf,YAAY,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;CACrC,CAAA;AAED,qBACa,OAAQ,SAAQ,aAAa;IACzC,MAAM,CAAC,MAAM,4BAoCX;IAGF,cAAc,EAAE,OAAO,CAAS;IAEhC,SAAS,CAAC,oBAAoB,uBAG5B;IAEK,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAsB;IAE5D,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;IAM5B,MAAM;CAsBN;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,UAAU,EAAE,OAAO,CAAC;KACpB;CACD"}
1
+ {"version":3,"file":"draw-svg.d.ts","sourceRoot":"","sources":["../../../src/components/draw-svg/draw-svg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,KAAK,QAAQ,GAAG;IACf,YAAY,EAAE,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;CACrC,CAAA;AAED,qBACa,OAAQ,SAAQ,aAAa;IACzC,MAAM,CAAC,MAAM,4BAoCX;IAGF,cAAc,EAAE,OAAO,CAAS;IAEhC,SAAS,CAAC,UAAU,IAAI,EAAE;IAQ1B,SAAS,CAAC,oBAAoB,uBAG5B;IAEK,OAAO,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAsB;IAE5D,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;CAK5B;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,UAAU,EAAE,OAAO,CAAC;KACpB;CACD"}
@@ -4,10 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { html, css } from 'lit';
7
+ import { css } from 'lit';
8
8
  import { state } from 'lit/decorators.js';
9
- import { styleMap } from 'lit/directives/style-map.js';
10
- import { classMap } from 'lit/directives/class-map.js';
11
9
  import { ResponsiveSvg } from '../responsive-svg/responsive-svg.js';
12
10
  import { EventEmitter } from '../../utils/EventEmitter.js';
13
11
  import { condCustomElement } from '../../decorators/condCustomElement.js';
@@ -21,6 +19,12 @@ let DrawSvg = class DrawSvg extends ResponsiveSvg {
21
19
  });
22
20
  this.emitter = new EventEmitter();
23
21
  }
22
+ svgClasses() {
23
+ super.svgClasses();
24
+ return {
25
+ animation: this.isIntersecting
26
+ };
27
+ }
24
28
  connectedCallback() {
25
29
  super.connectedCallback();
26
30
  this.intersectionObserver.observe(this);
@@ -29,26 +33,6 @@ let DrawSvg = class DrawSvg extends ResponsiveSvg {
29
33
  super.disconnectedCallback();
30
34
  this.intersectionObserver.disconnect();
31
35
  }
32
- render() {
33
- const styles = {
34
- '--svg-width': `${this.width}em`,
35
- '--svg-height': `${this.height}em`,
36
- };
37
- const classes = {
38
- animation: this.isIntersecting
39
- };
40
- return html `
41
- <svg
42
- class=${classMap(classes)}
43
- style=${styleMap(styles)}
44
- viewBox="0 0 ${this.width} ${this.height}"
45
- fill="none"
46
- xmlns="http://www.w3.org/2000/svg"
47
- >
48
- ${this.svgFragment}
49
- </svg>
50
- `;
51
- }
52
36
  };
53
37
  DrawSvg.styles = [
54
38
  ...ResponsiveSvg.styles,
@@ -2,11 +2,13 @@ import type { Meta, StoryObj } from '@storybook/web-components';
2
2
  declare const meta: Meta;
3
3
  export default meta;
4
4
  type Props = {
5
- svgPath: string;
5
+ fontSize: number;
6
6
  stroke: string;
7
7
  fill: string;
8
- fontSize: number;
9
8
  autofit: boolean;
9
+ height: number;
10
+ width: number;
11
+ svg: SVGElement | string;
10
12
  };
11
13
  type Story = StoryObj<Props>;
12
14
  export declare const DrawSVG: Story;
@@ -1 +1 @@
1
- {"version":3,"file":"draw-svg.stories.d.ts","sourceRoot":"","sources":["../../../src/components/draw-svg/draw-svg.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAMhE,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnG,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AA+B7B,eAAO,MAAM,OAAO,EAAE,KAQrB,CAAC"}
1
+ {"version":3,"file":"draw-svg.stories.d.ts","sourceRoot":"","sources":["../../../src/components/draw-svg/draw-svg.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAKhE,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAAA;CAAE,CAAC;AAE3I,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AA6B7B,eAAO,MAAM,OAAO,EAAE,KAWrB,CAAC"}
@@ -1,6 +1,6 @@
1
- import { html, svg } from 'lit';
1
+ import { html } from 'lit';
2
2
  import { styleMap } from 'lit/directives/style-map.js';
3
- const DrawSVGPath = "M145.965 70.84q0 27.26-29.56 27.26-4.74 0-12.55-1.15l7.17-37.82q.51-2.56.83-4.03 9.73-.71 14.05-.71t8.29.9q3.97.89 6.59 2.88 5.18 3.9 5.18 12.67Zm-13.18-2.37q0-9.53-6.85-9.53h-.64q-.32 0-.64.06l-6.59 34.37q.26.13.51.13h.51q2.37 0 4.84-1.48 2.46-1.47 4.38-4.48 4.48-6.97 4.48-19.07Zm36.48 10.95q2.3-4.1 2.3-8.26 0-2.75-1.98-2.75-1.54 0-3.14 2.62-1.66 2.63-2.17 6.02l-3.33 20.35-13.25 1.28 6.53-33.92 10.56-1.28-1.15 6.46q3.13-6.46 10.17-6.46 3.72 0 5.73 1.92 2.02 1.92 2.02 5.86 0 3.93-2.59 6.43-2.6 2.49-7.01 2.49-1.92 0-2.69-.76Zm16.1 16.06q-1.51-1.66-2.18-4.29-.67-2.62-.67-6.91t1.47-8.19q1.47-3.91 4.16-6.72 5.5-5.89 14.59-5.89 3.27 0 5.63 1.09l10.95-1.09-4.74 24.96q-.19.77-.19 2.18 0 1.4.86 2.3.87.9 2.15 1.02-.64 2.18-2.98 3.46-2.33 1.28-4.96 1.28-2.62 0-4.38-.99-1.76-.99-2.27-2.66-1.03 1.6-3.2 2.63-2.18 1.02-5.09 1.02-2.91 0-5.28-.77t-3.87-2.43Zm13.5-25.98q-.74 1.15-1.38 3.1-.64 1.95-1.69 7.17-1.06 5.21-1.06 8.93 0 3.71.58 4.8.57 1.08 1.6 1.08 2.05 0 3.55-1.95t2.08-5.41l3.39-18.75q-1.34-1.15-2.91-1.15t-2.5.51q-.92.51-1.66 1.67Zm71.65 17.21q-4.23 5.83-8.29 8.9-4.06 3.07-8.26 3.07-4.19 0-5.66-.83V83.77q-3.65 9.73-10.18 13.5-2.36 1.41-4.6 1.41-4.29 0-6.15-.83-.45-14.66-.83-18.72-.38-4.07-.7-6.56-.64-4.99-2.82-7.04 2.75-2.05 6.59-2.05 7.43 0 8.45 9.22.26 2.17.26 4.48 0 3.45-.77 15.48 1.53-.7 3.17-3.23 1.63-2.53 2.97-5.98 3.01-8 3.01-14.91 0-1.09-.29-2.24-.29-1.16-.61-1.48 2.24-1.34 5.67-1.34 3.42 0 5.05 2.34 1.64 2.33 2.08 6.62.52 5.44.52 8.7 0 4.55-.45 11.27 3.2-2.31 5.82-9.86 2.63-7.55 2.63-12.93 0-2.36-.39-3.77 2.11-2.37 5.76-2.37 2.24 0 3.87 1.22 1.64 1.21 1.64 3.48 0 2.28-.68 4.71-.67 2.43-1.76 4.93-2.11 4.99-5.05 8.89Zm34.17-18.88q.96-1.92.96-3.71t-.19-2.78q-.19-1-.64-1.76-.96-1.67-2.88-1.67-2.37 0-4.29 1.73-2.04 1.79-2.04 4.61 0 1.79 1.24 3.17 1.25 1.37 3.17 2.65 1.92 1.28 4.1 2.56 2.17 1.28 4.09 2.82 4.42 3.52 4.42 8.25 0 3.2-1.7 5.92-1.69 2.72-4.51 4.71-6.14 4.35-14.27 4.35-6.59 0-9.98-2.14-3.4-2.15-3.4-5.41 0-5.83 4.55-7.3 1.28-.45 3.23-.45t4.19.84q-1.02 2.62-1.02 4.99 0 5.12 3.65 5.12 2.36 0 4.32-1.73 1.95-1.73 1.95-3.68 0-1.95-1.25-3.36t-3.1-2.53q-1.86-1.12-4-2.21-2.15-1.08-4-2.62-4.36-3.52-4.36-9.15 0-3.65 1.8-6.5 1.79-2.85 4.67-4.77 5.76-3.9 12.83-3.9t10.5 2.11q3.42 2.11 3.42 5.7 0 3.13-2.43 5.12-2.11 1.66-4.67 1.66t-4.36-.64Zm14.4-10.11q1.86-3.84 7.01-3.84 5.15 0 7.55 2.98 2.4 2.97 2.4 9.82v22.85l15.56-34.31h7.61l-19.9 42.18h-14.98l-1.92-30.72q-.19-3.39-1.12-5.7-.93-2.3-2.21-3.26Zm63.04 19.07 12.93-1.15q-4.61 10.11-4.61 21.82-1.72 1.22-4.25 1.22-2.53 0-4.13-1.18-1.6-1.19-1.92-2.4-1.6 1.66-4.19 2.62-2.59.96-5.35.96-2.75 0-5.15-.9-2.4-.89-4.25-2.88-4.1-4.35-4.1-12.6 0-12.8 6.85-20.48 7.04-7.94 19.52-7.94 8.64 0 11.71 4.48.96 1.41.96 3.1 0 1.7-.74 3.14-.73 1.44-1.88 2.59-2.76 2.56-6.15 2.56-1.34 0-2.62-.45.25-1.92.25-4.16t-.16-3.26q-.16-1.02-.54-1.86-.83-1.72-2.66-1.72-1.82 0-3.84 1.95-2.01 1.95-3.61 5.15-3.52 7.17-3.52 15.81 0 3.97 1.53 6.78 1.67 3.07 4.61 3.07 1.03 0 1.95-.51.93-.51 1.32-.89l2.04-12.87Z";
3
+ import DrawSVGRaw from '../../assets/DrawSVG.svg?raw';
4
4
  const meta = {
5
5
  title: 'Draw SVG',
6
6
  tags: ['autodocs'],
@@ -8,8 +8,7 @@ const meta = {
8
8
  };
9
9
  export default meta;
10
10
  const Template = {
11
- render: ({ svgPath, stroke, fill, fontSize, autofit }) => {
12
- const DrawSVG = svg `<path part="PathPart" d=${svgPath}`;
11
+ render: ({ fontSize, stroke, fill, autofit, height, width, svg }) => {
13
12
  const styles = {
14
13
  stroke,
15
14
  fill,
@@ -17,17 +16,17 @@ const Template = {
17
16
  };
18
17
  return html `
19
18
  <style>
20
- draw-svg::part(PathPart) {
19
+ draw-svg::part(svg-path) {
21
20
  animation-iteration-count: infinite;
22
21
  }
23
22
  </style>
24
23
 
25
24
  <draw-svg
26
- .svgFragment=${DrawSVG}
27
- width=${645}
28
- height=${122}
29
- style=${styleMap(styles)}
30
25
  ?autofit=${autofit}
26
+ height=${height}
27
+ width=${width}
28
+ .svg=${svg}
29
+ style=${styleMap(styles)}
31
30
  >
32
31
  </draw-svg>
33
32
  `;
@@ -36,9 +35,12 @@ const Template = {
36
35
  export const DrawSVG = {
37
36
  ...Template,
38
37
  args: {
39
- svgPath: DrawSVGPath,
38
+ fontSize: 128,
40
39
  stroke: 'red',
41
40
  fill: 'black',
42
- fontSize: 128
41
+ autofit: false,
42
+ height: 0,
43
+ width: 0,
44
+ svg: DrawSVGRaw
43
45
  },
44
46
  };
@@ -1,15 +1,44 @@
1
- import { LitElement, TemplateResult, nothing } from 'lit';
1
+ import { LitElement, nothing, PropertyValues, TemplateResult } from 'lit';
2
+ type ViewBoxType = {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ };
2
8
  export declare class ResponsiveSvg extends LitElement {
3
9
  static styles: import("lit").CSSResult[];
10
+ autofit: boolean;
4
11
  height: number;
5
12
  width: number;
6
- svgFragment: TemplateResult<2> | typeof nothing;
7
- autofit: boolean;
8
- render(): TemplateResult<1>;
13
+ /** Must use a property expression (.) to set */
14
+ svg: SVGElement | TemplateResult<2> | string;
15
+ private _svg;
16
+ private _viewBox;
17
+ protected svgClasses(): {};
18
+ protected willUpdate(_changedProperties: PropertyValues): void;
19
+ render(): TemplateResult<1> | typeof nothing | undefined;
20
+ /**
21
+ * Builds an SVG from an Element or TemplateResult<2> input
22
+ * @param svg
23
+ * @param width
24
+ * @param height
25
+ * @returns
26
+ */
27
+ private buildSVG;
28
+ /**
29
+ * Applies a part name to all paths in the given element
30
+ */
31
+ private applyPartToPaths;
32
+ /**
33
+ * @param svg
34
+ * @returns The SVG viewbox x, y, width, and height
35
+ */
36
+ getViewBoxSize(svg: SVGElement): ViewBoxType | null;
9
37
  }
10
38
  declare global {
11
39
  interface HTMLElementTagNameMap {
12
40
  'responsive-svg': ResponsiveSvg;
13
41
  }
14
42
  }
43
+ export {};
15
44
  //# sourceMappingURL=responsive-svg.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responsive-svg.d.ts","sourceRoot":"","sources":["../../../src/components/responsive-svg/responsive-svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAKrE,qBACa,aAAc,SAAQ,UAAU;IAC5C,MAAM,CAAC,MAAM,4BA6CX;IAGF,MAAM,EAAE,MAAM,CAAK;IAGnB,KAAK,EAAE,MAAM,CAAK;IAGlB,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,OAAO,CAAW;IAG1D,OAAO,EAAE,OAAO,CAAS;IAEzB,MAAM;CAkBN;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
1
+ {"version":3,"file":"responsive-svg.d.ts","sourceRoot":"","sources":["../../../src/components/responsive-svg/responsive-svg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAkB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ1F,KAAK,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACd,CAAA;AAED,qBACa,aAAc,SAAQ,UAAU;IAC5C,MAAM,CAAC,MAAM,4BA6CX;IAGF,OAAO,EAAE,OAAO,CAAS;IAGzB,MAAM,EAAE,MAAM,CAAK;IAGnB,KAAK,EAAE,MAAM,CAAK;IAElB,gDAAgD;IAEhD,GAAG,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAAM;IAGlD,OAAO,CAAC,IAAI,CAAyC;IAGrD,OAAO,CAAC,QAAQ,CAAoD;IAGpE,SAAS,CAAC,UAAU;IAIpB,SAAS,CAAC,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAa9D,MAAM;IAiBN;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAsBhB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;OAGG;IACI,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI;CAM1D;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,aAAa,CAAC;KAChC;CACD"}
@@ -4,34 +4,102 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { LitElement, html, css, nothing } from 'lit';
8
- import { property } from 'lit/decorators.js';
7
+ import { LitElement, html, svg, css, nothing } from 'lit';
8
+ import { property, state } from 'lit/decorators.js';
9
9
  import { styleMap } from 'lit/directives/style-map.js';
10
10
  import { condCustomElement } from '../../decorators/condCustomElement.js';
11
+ import { parseSVG } from '../../utils/basicUtils.js';
12
+ import { classMap } from 'lit/directives/class-map.js';
13
+ import { isTemplateResult } from 'lit/directive-helpers.js';
11
14
  let ResponsiveSvg = class ResponsiveSvg extends LitElement {
12
15
  constructor() {
13
16
  super(...arguments);
17
+ this.autofit = false;
14
18
  this.height = 0;
15
19
  this.width = 0;
16
- this.svgFragment = nothing;
17
- this.autofit = false;
20
+ /** Must use a property expression (.) to set */
21
+ this.svg = '';
22
+ this._svg = svg ``;
23
+ this._viewBox = { x: 0, y: 0, width: 0, height: 0 };
24
+ }
25
+ // For classes inheriting from responsive-svg (e.g. draw-svg)
26
+ svgClasses() {
27
+ return {};
28
+ }
29
+ willUpdate(_changedProperties) {
30
+ super.willUpdate(_changedProperties);
31
+ if (_changedProperties.has('svg')) {
32
+ const svgSource = this.svg instanceof SVGElement ? this.svg : isTemplateResult(this.svg) ? this.svg : parseSVG(this.svg);
33
+ this._svg = svgSource || svg ``;
34
+ if (svgSource instanceof Element) {
35
+ this._viewBox = this.getViewBoxSize(svgSource) || { x: 0, y: 0, width: 0, height: 0 };
36
+ }
37
+ }
18
38
  }
19
39
  render() {
40
+ const width = this.width !== 0 ? this.width : this._viewBox.width;
41
+ const height = this.height !== 0 ? this.height : this._viewBox.height;
42
+ if (this._svg instanceof Element) {
43
+ const clonedSVG = this._svg.cloneNode(true);
44
+ this.applyPartToPaths(clonedSVG, 'path');
45
+ const svgContent = Array.from(clonedSVG.children);
46
+ return this.buildSVG(svgContent, width, height);
47
+ }
48
+ else if (isTemplateResult(this._svg))
49
+ return this.buildSVG(this._svg, width, height);
50
+ else
51
+ return nothing;
52
+ }
53
+ /**
54
+ * Builds an SVG from an Element or TemplateResult<2> input
55
+ * @param svg
56
+ * @param width
57
+ * @param height
58
+ * @returns
59
+ */
60
+ buildSVG(svg, width, height) {
20
61
  const styles = {
21
- '--svg-width': `${this.width}em`,
22
- '--svg-height': `${this.height}em`,
62
+ '--svg-width': `${width}em`,
63
+ '--svg-height': `${height}em`,
23
64
  };
24
- return html `
25
- <svg
26
- part="svg"
27
- style=${styleMap(styles)}
28
- viewBox="0 0 ${this.width} ${this.height}"
29
- fill="none"
30
- xmlns="http://www.w3.org/2000/svg"
31
- >
32
- ${this.svgFragment}
33
- </svg>
34
- `;
65
+ if (svg) {
66
+ return html `
67
+ <svg
68
+ part="svg"
69
+ class=${classMap(this.svgClasses())}
70
+ style=${styleMap(styles)}
71
+ viewBox="0 0 ${width} ${height}"
72
+ fill="none"
73
+ xmlns="http://www.w3.org/2000/svg"
74
+ >
75
+ ${svg}
76
+ </svg>
77
+ `;
78
+ }
79
+ }
80
+ /**
81
+ * Applies a part name to all paths in the given element
82
+ */
83
+ applyPartToPaths(element, partValue) {
84
+ if (element instanceof Element) {
85
+ if (element.tagName.toLowerCase() === 'path') {
86
+ element.setAttribute('part', partValue);
87
+ }
88
+ // Recursively check each child
89
+ for (const child of Array.from(element.children)) {
90
+ this.applyPartToPaths(child, partValue);
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * @param svg
96
+ * @returns The SVG viewbox x, y, width, and height
97
+ */
98
+ getViewBoxSize(svg) {
99
+ const viewBox = svg.getAttribute('viewBox')?.split(' ');
100
+ if (!viewBox)
101
+ return null;
102
+ return { x: +viewBox[0], y: +viewBox[1], width: +viewBox[2], height: +viewBox[3] };
35
103
  }
36
104
  };
37
105
  ResponsiveSvg.styles = [
@@ -81,17 +149,23 @@ ResponsiveSvg.styles = [
81
149
  `,
82
150
  ];
83
151
  __decorate([
84
- property({ type: Number, reflect: true })
152
+ property({ type: Boolean, reflect: true })
153
+ ], ResponsiveSvg.prototype, "autofit", void 0);
154
+ __decorate([
155
+ property({ type: Number })
85
156
  ], ResponsiveSvg.prototype, "height", void 0);
86
157
  __decorate([
87
- property({ type: Number, reflect: true })
158
+ property({ type: Number })
88
159
  ], ResponsiveSvg.prototype, "width", void 0);
89
160
  __decorate([
90
161
  property({ type: Object })
91
- ], ResponsiveSvg.prototype, "svgFragment", void 0);
162
+ ], ResponsiveSvg.prototype, "svg", void 0);
92
163
  __decorate([
93
- property({ type: Boolean, reflect: true })
94
- ], ResponsiveSvg.prototype, "autofit", void 0);
164
+ state()
165
+ ], ResponsiveSvg.prototype, "_svg", void 0);
166
+ __decorate([
167
+ state()
168
+ ], ResponsiveSvg.prototype, "_viewBox", void 0);
95
169
  ResponsiveSvg = __decorate([
96
170
  condCustomElement('responsive-svg')
97
171
  ], ResponsiveSvg);
@@ -1,13 +1,17 @@
1
1
  import type { Meta, StoryObj } from '@storybook/web-components';
2
+ import { TemplateResult } from 'lit';
2
3
  declare const meta: Meta;
3
4
  export default meta;
4
5
  type Props = {
5
- svgPath: string;
6
+ fontSize: number;
6
7
  stroke: string;
7
8
  fill: string;
8
- fontSize: number;
9
9
  autofit: boolean;
10
+ height: number;
11
+ width: number;
12
+ svg: SVGElement | TemplateResult<2> | string;
10
13
  };
11
14
  type Story = StoryObj<Props>;
12
- export declare const ResponsiveSVG: Story;
15
+ export declare const SVG: Story;
16
+ export declare const TemplateResult2: Story;
13
17
  //# sourceMappingURL=responsive-svg.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responsive-svg.stories.d.ts","sourceRoot":"","sources":["../../../src/components/responsive-svg/responsive-svg.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAMhE,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAEnG,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAyB7B,eAAO,MAAM,aAAa,EAAE,KAS3B,CAAC"}
1
+ {"version":3,"file":"responsive-svg.stories.d.ts","sourceRoot":"","sources":["../../../src/components/responsive-svg/responsive-svg.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAIhD,QAAA,MAAM,IAAI,EAAE,IAIX,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,MAAM,CAAA;CAAE,CAAC;AAE/J,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAuB7B,eAAO,MAAM,GAAG,EAAE,KAWjB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAW7B,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { html, svg } from 'lit';
2
2
  import { styleMap } from 'lit/directives/style-map.js';
3
- const ResponsiveSVGPath = "M24.435 104.76h-13.7l7.81-42.05q6.34-.7 15.58-.7 9.25 0 13.54 2.69 4.29 2.68 4.29 8.09t-2.79 8.8q-2.78 3.39-7.58 4.48 1.09 5.31 3.58 9.6 2.31 4.03 5 5.31-.96 2.69-2.92 3.88-1.95 1.18-4.73 1.18-2.79 0-4.96-1.63-2.18-1.63-3.91-4.64-3.64-6.53-4.03-16.83h.45q4.74-.13 7.1-2.6 2.37-2.46 2.37-7.64 0-6.47-5.44-6.72h-1.41q-.57 0-.89.06l-7.36 38.72Zm56.38-10.82q1.6 1.09 1.6 3.49 0 2.4-1.21 3.94-1.22 1.53-3.2 2.56-4.1 2.11-8.52 2.11-4.41 0-7-.96-2.6-.96-4.32-2.75-3.4-3.39-3.4-9.6 0-9.67 5.25-15.55 5.63-6.34 15.43-6.34 6.08 0 9.08 2.56 2.24 1.92 2.24 5.06 0 11.26-19.45 11.26-.26 1.66-.26 3.07 0 2.95 1.31 4.07 1.32 1.12 3.75 1.12 2.43 0 5.02-1.12 2.59-1.12 3.68-2.92Zm-13.05-6.97q4.54 0 7.16-2.82 2.63-2.69 2.63-6.97 0-1.48-.55-2.28-.54-.8-1.63-.8-1.09 0-2.01.42-.93.42-1.89 1.82-2.37 3.2-3.71 10.63Zm40.32-4.67q.89-2.37.89-4.42 0-3.78-3.07-3.78-1.6 0-2.91 1.44t-1.31 3.24q0 1.28 1.02 2.3 1.47 1.41 5.25 3.71 3.77 2.31 5.21 4.19 1.44 1.89 1.44 4.48 0 2.6-1.24 4.96-1.25 2.37-3.49 4.04-4.8 3.58-12.48 3.58-4.16 0-7.36-2.18-3.2-2.11-3.2-4.6 0-2.5 1.82-3.97 1.83-1.47 4.51-1.47 2.69 0 4.36 1.02-.84 2.11-.84 3.52 0 4.22 3.59 4.22 1.53 0 2.56-.96 1.02-.96 1.02-2.62 0-3.26-5.5-6.72-4.48-2.94-5.51-4.1-1.72-2.04-1.72-4.6 0-2.56 1.21-5 1.22-2.43 3.46-4.16 4.67-3.58 12.8-3.58 4.16 0 6.62 1.66 2.47 1.67 2.47 4.48 0 2.82-1.7 4.42t-4.77 1.6q-2.11 0-3.13-.7Zm41.79 18.08q-2.69 2.72-6.37 4.19-3.68 1.47-7.33 1.47t-4.93-.64l-1.98 10.88-12.99 1.28 8.83-45.44 10.43-1.09-.83 4.42q2.69-4.55 8.26-4.55 6.27 0 9.6 4.04 2.94 3.64 2.94 9.21t-1.47 9.54q-1.47 3.97-4.16 6.69Zm-14.47-17.96-3.39 18.76q1.35 1.15 3.01 1.15 1.66 0 2.62-.64.96-.64 1.67-1.92 1.92-3.46 3.45-13.95.45-3.08.45-6.08 0-3.01-.67-3.97-.67-.96-1.95-.96-3.91 0-5.19 7.61Zm37.89 23.62q-14.08 0-14.08-13.25 0-9.41 5.19-15.49 5.5-6.46 15.04-6.46 6.91 0 10.43 3.2 3.52 3.2 3.52 9.92 0 10.24-5.51 16.19-5.37 5.89-14.59 5.89Zm1.67-27.84q-.77 1.73-1.38 4.32-.61 2.59-1.38 6.69-.76 4.09-.76 9.15 0 1.66.54 2.75t2.02 1.09q1.47 0 2.4-.7.92-.71 1.63-2.37 1.28-2.95 2.3-8.42 1.03-5.47 1.12-7.84.1-2.37.1-4.13 0-1.76-.51-2.91-.52-1.15-1.96-1.15t-2.4.9q-.96.89-1.72 2.62Zm49.28 27.84q-7.75 0-7.75-6.02.07-1.66.58-4.48l1.15-5.88q1.73-8.32 1.73-10.18 0-3.71-2.18-3.71-3.65 0-5.57 9.53l-3.77 19.46-12.87 1.28 6.66-33.98 10.5-1.22-1.03 6.27q3.01-6.27 12.23-6.27 4.48 0 6.36 1.89 1.89 1.89 1.89 6.11 0 3.97-2.05 13.25-.96 4.16-.96 5.73 0 1.56.87 2.46.86.9 2.14 1.02-.64 2.18-2.85 3.46-2.2 1.28-5.08 1.28Zm32.19-23.74q.89-2.37.89-4.42 0-3.78-3.07-3.78-1.6 0-2.91 1.44t-1.31 3.24q0 1.28 1.02 2.3 1.47 1.41 5.25 3.71 3.78 2.31 5.22 4.19 1.44 1.89 1.44 4.48 0 2.6-1.25 4.96-1.25 2.37-3.49 4.04-4.8 3.58-12.48 3.58-4.16 0-7.36-2.18-3.2-2.11-3.2-4.6 0-2.5 1.82-3.97 1.83-1.47 4.52-1.47 2.68 0 4.35 1.02-.83 2.11-.83 3.52 0 4.22 3.58 4.22 1.54 0 2.56-.96t1.02-2.62q0-3.26-5.5-6.72-4.48-2.94-5.5-4.1-1.73-2.04-1.73-4.6 0-2.56 1.21-5 1.22-2.43 3.46-4.16 4.67-3.58 12.8-3.58 4.16 0 6.62 1.66 2.47 1.67 2.47 4.48 0 2.82-1.7 4.42-1.69 1.6-4.77 1.6-2.11 0-3.13-.7Zm27.33 18.94q-1.99 4.8-8.32 4.8-3.27 0-5.32-2.24-1.72-1.98-1.72-3.97 0-5.18 2.36-15.29l2.37-12.42 12.99-1.28-3.9 20.22q-1.09 4.74-1.09 6.4 0 3.65 2.63 3.78Zm-9.48-38.02q0-2.49 2.08-3.84 2.08-1.34 5.09-1.34t4.83 1.34q1.83 1.35 1.83 3.84 0 2.5-2.02 3.78-2.01 1.28-5.02 1.28t-4.9-1.28q-1.89-1.28-1.89-3.78Zm38.15 9.99q2.11-2.37 5.76-2.37 2.24 0 3.97 1.22 1.72 1.21 1.72 3.48 0 2.28-.7 4.71t-1.79 4.93q-2.18 4.86-5.19 8.89-4.22 5.83-8.28 8.9-4.07 3.07-8.48 3.07-3.59 0-5.76-.83-.39-13.44-.87-18.24-.48-4.8-.86-7.43-.64-5.12-2.56-6.33 1.47-1.28 2.91-1.83 1.44-.54 4.42-.54 2.97 0 5.08 2.34 2.12 2.33 2.53 6.46.42 4.13.42 9.12 0 4.99-.39 11.01 1.99-1.41 4.1-5.7 2.88-5.95 3.9-13.12.32-2.17.32-4.48 0-2.3-.25-3.26Zm39.1 20.73q1.6 1.09 1.6 3.49 0 2.4-1.21 3.94-1.22 1.53-3.2 2.56-4.1 2.11-8.52 2.11-4.41 0-7-.96-2.6-.96-4.32-2.75-3.4-3.39-3.4-9.6 0-9.67 5.25-15.55 5.63-6.34 15.43-6.34 6.08 0 9.08 2.56 2.24 1.92 2.24 5.06 0 11.26-19.45 11.26-.26 1.66-.26 3.07 0 2.95 1.31 4.07 1.32 1.12 3.75 1.12 2.43 0 5.02-1.12 2.59-1.12 3.68-2.92Zm-13.05-6.97q4.54 0 7.16-2.82 2.63-2.69 2.63-6.97 0-1.48-.55-2.28-.54-.8-1.63-.8-1.09 0-2.01.42-.93.42-1.89 1.82-2.37 3.2-3.71 10.63Zm59.32-11.78q.96-1.92.96-3.71t-.19-2.78q-.19-1-.64-1.76-.96-1.67-2.88-1.67-2.37 0-4.29 1.73-2.04 1.79-2.04 4.61 0 1.79 1.24 3.17 1.25 1.37 3.17 2.65 1.92 1.28 4.1 2.56 2.17 1.28 4.09 2.82 4.42 3.52 4.42 8.25 0 3.2-1.7 5.92-1.69 2.72-4.51 4.71-6.14 4.35-14.27 4.35-6.59 0-9.98-2.14-3.4-2.15-3.4-5.41 0-5.83 4.55-7.3 1.28-.45 3.23-.45t4.19.84q-1.02 2.62-1.02 4.99 0 5.12 3.65 5.12 2.36 0 4.32-1.73 1.95-1.73 1.95-3.68 0-1.95-1.25-3.36t-3.1-2.53q-1.86-1.12-4-2.21-2.15-1.08-4-2.62-4.36-3.52-4.36-9.15 0-3.65 1.8-6.5 1.79-2.85 4.67-4.77 5.76-3.9 12.83-3.9t10.5 2.11q3.42 2.11 3.42 5.7 0 3.13-2.43 5.12-2.11 1.66-4.67 1.66t-4.36-.64Zm14.4-10.11q1.86-3.84 7.01-3.84 5.15 0 7.55 2.98 2.4 2.97 2.4 9.82v22.85l15.56-34.31h7.61l-19.9 42.18h-14.98l-1.92-30.72q-.19-3.39-1.12-5.7-.93-2.3-2.21-3.26Zm63.04 19.07 12.93-1.15q-4.61 10.11-4.61 21.82-1.72 1.22-4.25 1.22-2.53 0-4.13-1.18-1.6-1.19-1.92-2.4-1.6 1.66-4.19 2.62-2.59.96-5.35.96-2.75 0-5.15-.9-2.4-.89-4.25-2.88-4.1-4.35-4.1-12.6 0-12.8 6.85-20.48 7.04-7.94 19.52-7.94 8.64 0 11.71 4.48.96 1.41.96 3.1 0 1.7-.74 3.14-.73 1.44-1.88 2.59-2.76 2.56-6.15 2.56-1.34 0-2.62-.45.25-1.92.25-4.16t-.16-3.26q-.16-1.02-.54-1.86-.83-1.72-2.66-1.72-1.82 0-3.84 1.95-2.01 1.95-3.61 5.15-3.52 7.17-3.52 15.81 0 3.97 1.53 6.78 1.67 3.07 4.61 3.07 1.03 0 1.95-.51.93-.51 1.32-.89l2.04-12.87Z";
3
+ import ResponsiveSVGRaw from '../../assets/ResponsiveSVG.svg?raw';
4
4
  const meta = {
5
5
  title: 'Responsive SVG',
6
6
  tags: ['autodocs'],
@@ -8,32 +8,45 @@ const meta = {
8
8
  };
9
9
  export default meta;
10
10
  const Template = {
11
- render: ({ svgPath, stroke, fill, fontSize, autofit }) => {
12
- const ResponsiveSVG = svg `<path d=${svgPath}`;
11
+ render: ({ fontSize, stroke, fill, autofit, height, width, svg }) => {
13
12
  const styles = {
13
+ 'font-size': `${fontSize}px`,
14
14
  stroke,
15
- fill,
16
- 'font-size': `${fontSize}px`
15
+ fill
17
16
  };
18
17
  return html `
19
18
  <responsive-svg
20
- .svgFragment=${ResponsiveSVG}
21
- width=${645}
22
- height=${122}
23
- style=${styleMap(styles)}
24
19
  ?autofit=${autofit}
20
+ height=${height}
21
+ width=${width}
22
+ .svg=${svg}
23
+ style=${styleMap(styles)}
25
24
  >
26
25
  </responsive-svg>
27
26
  `;
28
27
  },
29
28
  };
30
- export const ResponsiveSVG = {
29
+ export const SVG = {
31
30
  ...Template,
32
31
  args: {
33
- svgPath: ResponsiveSVGPath,
32
+ fontSize: 128,
34
33
  stroke: 'rebeccapurple',
35
34
  fill: 'black',
36
- fontSize: 128,
37
- autofit: false
35
+ autofit: false,
36
+ height: 0,
37
+ width: 0,
38
+ svg: ResponsiveSVGRaw
38
39
  },
39
40
  };
41
+ export const TemplateResult2 = {
42
+ ...Template,
43
+ args: {
44
+ fontSize: 128,
45
+ stroke: 'rebeccapurple',
46
+ fill: 'black',
47
+ autofit: false,
48
+ height: 128,
49
+ width: 128,
50
+ svg: svg `<path part="path" d="M 30 50 h 60 a 1 1 0 0 1 0 20 h -60 a 1 1 0 0 1 0 -40 h 30 v 70"/>`
51
+ }
52
+ };
@@ -46,4 +46,10 @@ export declare function copyToClipboard(text: string, copyFormat?: CopyFormat):
46
46
  */
47
47
  export declare function getAdjustedFontSize(colorsCount: number): number;
48
48
  export declare function isColorValid(color: string | CommonColorTuple | CommonColoraTuple): boolean;
49
+ /**
50
+ * Parse a raw string based SVG
51
+ * @param rawSVG SVG represented as a string
52
+ * @returns SVG element if it could be parsed
53
+ */
54
+ export declare function parseSVG(rawSVG: string): SVGSVGElement | null;
49
55
  //# sourceMappingURL=basicUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"basicUtils.d.ts","sourceRoot":"","sources":["../../src/utils/basicUtils.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAO,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EAAmB,MAAM,oDAAoD,CAAC;AAExI;;GAEG;AACH,wBAAgB,mBAAmB,CAAE,QAAQ,EAAE,eAAe,wCAsB7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAE,QAAQ,EAAE,eAAe,GAAG,oBAAoB,WAUnF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAE,QAAQ,EAAE,eAAe,sBAGrE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,OAY9D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,YAQnC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,oBAAoB,GAAG,eAAe,CAW7F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAA,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,GAAG,MAAM,GAAG,MAAM,CAGnH;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAMxC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,iBAU1E;AAED;;EAEE;AACF,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,UAItD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,OAAO,CAS1F"}
1
+ {"version":3,"file":"basicUtils.d.ts","sourceRoot":"","sources":["../../src/utils/basicUtils.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAO,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EAAmB,MAAM,oDAAoD,CAAC;AAExI;;GAEG;AACH,wBAAgB,mBAAmB,CAAE,QAAQ,EAAE,eAAe,wCAsB7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAE,QAAQ,EAAE,eAAe,GAAG,oBAAoB,WAUnF;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAE,QAAQ,EAAE,eAAe,sBAGrE;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,OAY9D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,YAQnC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,oBAAoB,GAAG,eAAe,CAW7F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAA,QAAQ,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAA;CAAE,GAAG,MAAM,GAAG,MAAM,CAGnH;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,UAMxC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,UAAU,iBAU1E;AAED;;EAEE;AACF,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,UAItD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,GAAG,OAAO,CAS1F;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,wBAItC"}
@@ -148,3 +148,13 @@ export function isColorValid(color) {
148
148
  return false;
149
149
  }
150
150
  }
151
+ /**
152
+ * Parse a raw string based SVG
153
+ * @param rawSVG SVG represented as a string
154
+ * @returns SVG element if it could be parsed
155
+ */
156
+ export function parseSVG(rawSVG) {
157
+ const parser = new DOMParser();
158
+ const svgDoc = parser.parseFromString(rawSVG, 'image/svg+xml');
159
+ return svgDoc.querySelector('svg');
160
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "private": false,
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "name": "@alegendstale/holly-components",
5
5
  "description": "Reusable UI components created using lit",
6
6
  "type": "module",