Skip to content

Commit

Permalink
initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
thivatm committed May 6, 2019
0 parents commit 5bb68ac
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
Binary file added Frame.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions card.html
@@ -0,0 +1,7 @@
<template>
<div class="card">
<p class="card-title"></p>
<img class="gif-view" src=""/>
</div>
</template>
<script src="/UserCard/UserCard.js"></script>
26 changes: 26 additions & 0 deletions card.js
@@ -0,0 +1,26 @@
import { url } from './services';

class CardComponent extends HTMLElement {
constructor (){
super();
}

render(){

}

async fetchFromGiphy (){
const res = await fetch(url);
const json = await res.json()['data'][0];

const gifUrl = json.images['fixed_height_small'].url;
const gifName = json.title;

return {
name: gifName,
url: gifUrl
}
}
}

customElements.define('card-comp', CardComponent);
16 changes: 16 additions & 0 deletions index.html
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Web Component</title>
</head>

<body>

<script src="./main.js" type="module"></script>
</body>

</html>
10 changes: 10 additions & 0 deletions main.js
@@ -0,0 +1,10 @@
import { url } from './services.js';

async function fetchFromGiphy (){
const res = await fetch(url);
const json = await res.json();

console.log(json['data'][0].title);
}

document.addEventListener('DOMContentLoaded', fetchFromGiphy);
4 changes: 4 additions & 0 deletions services.js
@@ -0,0 +1,4 @@
const API_KEY = 'U1VN1X6Jd5b0jKc3aXRaSnj09R3TwNAR';
const url = `http://api.giphy.com/v1/gifs/trending?api_key=` + API_KEY + `&limit=1`;

export {API_KEY, url};

0 comments on commit 5bb68ac

Please sign in to comment.