@postnord/web-components
Version:
PostNord Web Components
6 lines • 1.38 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
import{r as t,g as i,h as s,a as e}from"./p-C247oTEA.js";const h="pn-illustration{display:inline-block}pn-illustration[data-fill]{display:block}pn-illustration>svg{width:var(--pn-width);height:var(--pn-height);display:block}";const n=class{constructor(i){t(this,i)}get hostElement(){return i(this)}illustration;width;height;fill=false;handleFill(){if(this.fill){this.width="100%";this.height="100%"}}componentWillRender(){this.handleFill();if(this.width||this.height)return this.setSizes();this.getSizeFromSvg()}componentDidRender(){this.hostElement.querySelector("svg")?.setAttribute("width",this.width);this.hostElement.querySelector("svg")?.setAttribute("height",this.height)}getSizeFromSvg(){const t=this.illustration?.match(/<svg[^>]*?viewBox=(["\'])?((?:.(?!\1|>))*.?)\1?/)?.[2];if(!t)return;const[,,i="",s=""]=t?.split(" ")||[];if(!i||!s)return;this.width=`${Number(i)}px`;this.height=`${Number(s)}px`;this.setSizes()}setSizes(){this.hostElement.style.setProperty("--pn-width",this.width);this.hostElement.style.setProperty("--pn-height",this.height)}render(){return s(e,{key:"3f2e44ec10a5a2fc9fd9a69f94963ab4e79fb877",role:"presentation",innerHTML:this.illustration,"data-fill":this.fill})}static get watchers(){return{fill:["handleFill"]}}};n.style=h;export{n as pn_illustration};
//# sourceMappingURL=p-df4c8866.entry.js.map