Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5bb68ac
Showing
6 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}; |