Skip to content

Instantly share code, notes, and snippets.

@joelalejandro
Created September 5, 2020 00:10
Show Gist options
  • Save joelalejandro/f80af2b410b1e3733d65f7cbf2797825 to your computer and use it in GitHub Desktop.
Save joelalejandro/f80af2b410b1e3733d65f7cbf2797825 to your computer and use it in GitHub Desktop.
Tabifit: Web Components: Botón con texto
<boton-texto id="comenzar">
Comenzar
</boton-texto>
<template id="boton-texto">
<style>
button {
padding:16px;
border-radius:25px;
max-width:320px;
background-color: #4AB4DC;
font-size:16px;
text-transform: uppercase;
color: #ffffff;
border: none;
font-weight: 600;
}
</style>
<button>
<slot>Boton</slot>
</button>
</template>
class Componente extends HTMLElement {
constructor(referenciaTemplate) {
super();
const template = document.querySelector(referenciaTemplate);
const templateContent = template.content;
this.attachShadow({ mode: "open" })
.appendChild(templateContent.cloneNode(true));
}
}
class BotonTexto extends Componente {
constructor () {
super("#boton-texto");
}
}
class BotonIcono extends Componente {
constructor () {
super("#boton-icono");
}
}
customElements.define("boton-texto", BotonTexto);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment