@sutton-signwriting/sgnw-components
Version:
a javascript package of web components for use with the SignWriting script.
4 lines • 2.22 kB
JavaScript
/*!
* The Sutton SignWriting Web Components
*/
import{r as s,f as t,d as i,H as e,e as o}from"./p-BAJUTSOF.js";import{f as a}from"./p-CsiwdcpL.js";import{C as n,s as r}from"./p-BgrNWcmU.js";const d=class{constructor(t){s(this,t),this.sgnw=window.sgnw,this.items=[]}parseText(s){this.items=a.parse.text(s).map((s=>{let t=a.info(s);return t.text=s,t}))}connectedCallback(){if(this.colorWatch=new n(this.el,this),this.vp?this.parseText(this.vp):this.vp=this.el.innerHTML,!this.sgnw){let s=this;function t(){s.sgnw=window.sgnw,window.removeEventListener("sgnw",t,!1)}window.addEventListener("sgnw",t,!1)}}disconnectedCallback(){this.colorWatch.dispose()}render(){const s=t(this.el),o=r.compose({colorize:this.colorize,detail:s.detail});return i(e,{key:"1b18f185e422580cc19d542ba81957effd155ad5",vp:this.vp},i("span",{key:"29096a55f34654afed7ba52298f3bbdf8928362c",class:"outside"},i("span",{key:"473eb5eb25a017b834ba1729a78b7a17ce54802b",class:"middle"},i("span",{key:"1d75c80f1d07a3b4d5d9a8b51e5be711038dfa33",class:"inside"},this.items.map((t=>{let e,a,n,r,d,l;return"sign"==t.segment?(e=s.zoom*t.zoom,a=t.padding*e,n=t.width*e+2*a,r=t.height*e+2*a,d=(1e3-2*t.minX-t.width)*e-150*s.zoom*t.lane,l=Math.max(0,20*e-a),i("fsw-sign",{styling:o,style:{"font-size":30*s.zoom+"px",width:n+"px",height:r+"px","margin-right":(d>0?d:0)+"px","border-left":(d<0?-d:0)+"px solid transparent",padding:l+"px"}},t.text)):"symbol"==t.segment?(e=s.zoom*t.zoom,a=t.padding*e,n=t.width*e+2*a,r=t.height*e+2*a,l=Math.max(0,20*e-a),i("fsw-symbol",{styling:o,style:{"font-size":30*s.zoom+"px",width:n+"px",height:r+"px","padding-bottom":l+"px"}},t.text)):(console.log("other"),i("div",null,t.text))}))))))}get el(){return o(this)}static get watchers(){return{vp:[{parseText:0}]}}};d.style=":host{writing-mode:vertical-lr;border-right:1px solid blue;height:100%}:host svg{display:block}:host span.outside{font-size:0%;line-height:0%;border-left:1px solid blue;vertical-align:top}:host span.middle{vertical-align:bottom}:host span.inside{border-left:1px dashed red}fsw-sign,fsw-symbol{writing-mode:horizontal-tb;display:inline-block;vertical-align:middle;box-sizing:content-box}:host{transition:color 1ms, background-color 1ms}";export{d as fsw_vp}