You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a Web Component you can scope all your CSS and JS so you don't have any global dependencies.
The user then loads just one JS file defining the Web Component, and does not have to use DIV or classnames
Just a quick proof of concept (not refactoring JS and CSS):
<linkhref="https://evoluteur.github.io/braille-tools/css/braille-big.css" rel="stylesheet" type="text/css"><scriptsrc="https://evoluteur.github.io/braille-tools/braille-tools.js" type="text/javascript" charset="utf-8"></script><braille-string>Hello World!</braille-string><braille-string>I can write Web Components</braille-string><script>customElements.define("braille-string",classextendsHTMLElement{connectedCallback(){constbraille=char=>Object.assign(document.createElement("div"),{className: `br br-${char}`})this.render=(txt)=>this.replaceWith(...txt.split("").map(braille));setTimeout(()=>this.render(this.innerHTML));// wait till innerHTML is parsed}});</script>
Note: Every Braille character is a six bit value, so a PNG with all characters is not required, create them 6 dots dynamically
The text was updated successfully, but these errors were encountered:
In a Web Component you can scope all your CSS and JS so you don't have any global dependencies.
The user then loads just one JS file defining the Web Component, and does not have to use DIV or classnames
Just a quick proof of concept (not refactoring JS and CSS):
JSFiddle: https://jsfiddle.net/WebComponents/yv6scarL/
Note: Every Braille character is a six bit value, so a PNG with all characters is not required, create them 6 dots dynamically
The text was updated successfully, but these errors were encountered: