Creates first version of cat image component

This commit is contained in:
Julien Lengrand-Lambert
2017-12-08 10:46:32 +01:00
parent 6211fa3797
commit 76affd8ec6
3 changed files with 39 additions and 2 deletions

View File

@@ -4,4 +4,13 @@ This repo was created to support [a workshop](https://www.meetup.com/Coffee-Code
## Slides and Work Material
[Slides are here](https://docs.google.com/presentation/d/1h_wp7a_xbjJxeNLu6_Dd8Q4fBy2zA6jc1AjZrNqSEjo/edit?usp=sharing)
[Slides are here](https://docs.google.com/presentation/d/1h_wp7a_xbjJxeNLu6_Dd8Q4fBy2zA6jc1AjZrNqSEjo/edit?usp=sharing)
## TODO
* Firefox support
* First component
* Extension component
* Testing component
* Shadow DOM
* Stencil ?

View File

@@ -9,7 +9,9 @@
<hello-world></hello-world>
<hello-world-with-params name="Meetup"></hello-world-with-params>
<div>
<cat-img></cat-img>
</div>
<div>
<button onclick="removeHelloWorld()">Click me to remove Hello World</button>
</div>
@@ -18,8 +20,10 @@
<button onclick="changeHelloWorldParam()">Click me to change Hello World's parameter</button>
</div>
<script src="src/components/hello-world.js"></script>
<script src="src/components/hello-world-with-params.js"></script>
<script src="src/components/cat-img.js"></script>
<script>
function removeHelloWorld(){
console.log("Called!");

24
src/components/cat-img.js Normal file
View File

@@ -0,0 +1,24 @@
class CatImgElement extends HTMLElement {
constructor(){
super()
this.innerHTML = `
<h1>Here comes a kitty image</h1>
<img src="http://lorempixel.com/400/200/cats"</img>`;
}
connectedCallback(){
}
disconnectedCallback(){
}
attributeChangedCallback(attributeName, oldValue, newValue, namespace){
}
}
window.customElements.define(
'cat-img',
CatImgElement);