Created
September 5, 2020 00:10
-
-
Save joelalejandro/f80af2b410b1e3733d65f7cbf2797825 to your computer and use it in GitHub Desktop.
Tabifit: Web Components: Botón con texto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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