First version of cat img with placeholder

This commit is contained in:
Julien Lengrand-Lambert
2017-12-08 12:23:31 +01:00
parent 57be71cac3
commit 62f4ff3161
4 changed files with 24 additions and 2 deletions

View File

@@ -9,10 +9,8 @@ This repo was created to support [a workshop](https://www.meetup.com/Coffee-Code
## TODO
* Firefox support
* First component
* Extension component
* Testing component
* Shadow DOM
* Stencil ?
* Auto update?
* Naming - , or uppercase?

View File

@@ -11,6 +11,9 @@
<hello-world-with-params name="Meetup"></hello-world-with-params>
<div>
<cat-img></cat-img>
</div>
<div>
<cat-img-fast></cat-img-fast>
</div>
<div>
<button onclick="removeHelloWorld()">Click me to remove Hello World</button>
@@ -23,6 +26,7 @@
<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 src="src/components/cat-img-fast.js"></script>
<script>
function removeHelloWorld(){
console.log("Called!");

View File

@@ -0,0 +1,20 @@
class CatImgFastElement extends CatImgElement {
constructor(){
super();
}
render(){
console.log(`rendering with ${this.imgtype} ${this.xsize} ${this.ysize}`);
this.innerHTML = `
<h1>Here comes a better image</h1>
<img height=${this.ysize} width=${this.xsize}
src="http://lorempixel.com/${this.xsize}/${this.ysize}/${this.imgtype}"
style="background: url('src/img/cat-loading.gif'); background-size: cover;"
</img>`;
}
}
window.customElements.define(
'cat-img-fast',
CatImgFastElement);

BIN
src/img/cat-loading.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB