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
import type { Config } from "tailwindcss"; | |
const config: Config = { | |
content: [ | |
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}", | |
"./src/components/**/*.{js,ts,jsx,tsx,mdx}", | |
"./src/app/**/*.{js,ts,jsx,tsx,mdx}", | |
], | |
theme: { | |
extend: { |
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
// verwende die document.getELementById, um das eingabefeld und den Button zu finden. Denkt daran, die passenden ID's aus unserem HTML dokument zu verwenden | |
const pokemonInput = document.getElementById("pokemonInput"); | |
const fetchBtn = document.getElementById("fetchPokemon"); | |
// fugt das "document" objekt einen EventListener hinzu | |
// der EventListener muss mit DOMContentLoaded ausgelost werden | |
// Diese Listener soll aus das erignis DOMContentLoaded reagieren | |
document.addEventListener("DOMContentLoaded", () => { | |
fetchBtn.addEventListener('click', () => { | |
// gebe den Geschriebenen Pokemon namen aus dem Eingabefeld fur die function weiter |
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
// src/app/page.tsx | |
import { shopifyExtension, shopifyProduct } from "@/types"; | |
import Image from "next/image"; | |
import { gql } from "@/utils/gql"; | |
type GraphQLResponse = { | |
data: { | |
products: { |
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
// Event Listener starting the request to fetch for pokemon the second the page is visited | |
document.addEventListener('DOMContentLoaded', () => { | |
const pokemonInput = document.getElementById('pokemonInput'); | |
const fetchBtn = document.getElementById('fetchPokemon'); | |
fetchBtn.addEventListener('click', () => { | |
fetchThePoke(pokemonInput.value); | |
}) | |
}) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- Including Bootstrap Support --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" | |
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | |
<!-- End of Bootstrap Link --> |
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
// Event Listener starting the request to fetch for pokemon the second the page is visited | |
document.addEventListener('DOMContentLoaded', () => { | |
const pokemonInput = document.getElementById('pokemonInput'); | |
const fetchBtn = document.getElementById('fetchPokemon'); | |
fetchBtn.addEventListener('click', () => { | |
fetchThePoke(pokemonInput.value) | |
}) | |
}) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<!-- Including Bootstrap Support --> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" | |
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | |
<!-- End of Bootstrap Link --> |
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
// Event Listener starting the request to fetch for pokemon the second the page is visited | |
document.addEventListener('DOMContentLoaded', () => { | |
const pokemonInput = document.getElementById('pokemonInput'); | |
const fetchBtn = document.getElementById('fetchPokemon'); | |
fetchBtn.addEventListener('click', () => { | |
fetchThePoke(pokemonInput.value) | |
}) | |
}) |
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
// function to display the pokemon | |
function displayPokemon(pokemon) { | |
const display = document.getElementById('pokemon-display') | |
display.innerHTML = ` | |
<div class = "text-center"> | |
<img src = ${pokemon.sprites.front_default}> | |
<h3>${pokemon.name.toUpperCase()}</h3> | |
</div | |
` | |
} |
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
function fetchThePoke(valueOfInputField) { | |
fetch(`https://pokeapi.co/api/v2/pokemon/${valueOfInputField.toLowerCase()}`) | |
.then(response => response.json()) | |
.then(data => displayPokemon(data)) | |
.catch(error => { | |
console.error('Pokemon Not Found:', error) | |
alert('Pokemon does not Exist!', error) | |
}) | |
} |
NewerOlder