diff --git a/index.html b/index.html index deabf718ff842d73e25378db9d26090d2f8725bc..b4c5419dffe72fb2c24f8e5805d42fdb26be22f8 100644 --- a/index.html +++ b/index.html @@ -32,10 +32,6 @@ </nav> </header> <section class="newsContainer" style="display:none"> - <article> - <button class="closeButton"></button> - <h1>Bienvenue chez <strong>Pizza<em>Land</em></strong> !</h1> - </article> </section> <section class="pageContainer"> <header class="pageTitle"></header> diff --git a/news.html b/news.html new file mode 100644 index 0000000000000000000000000000000000000000..b799e09bfa00926508dcb828fd33a6d113cfa3d2 --- /dev/null +++ b/news.html @@ -0,0 +1,10 @@ +<article> + <button class="closeButton"></button> + <h1>Bienvenue chez <strong>Pizza<em>Land</em></strong> !</h1> + <p> + Découvrez notre nouvelle pizza + <strong class="spicy">Spicy</strong> + <br/> + aux délicieuses saveurs épicées ! + </p> +</article> \ No newline at end of file diff --git a/pizzaland-jar-with-dependencies.jar b/pizzaland-jar-with-dependencies.jar new file mode 100644 index 0000000000000000000000000000000000000000..4b41ca0cf2dd515961223dac0da64dfa2c85fa58 Binary files /dev/null and b/pizzaland-jar-with-dependencies.jar differ diff --git a/src/data.js b/src/data.js deleted file mode 100644 index 5d735aa051811e759c4807d80608943ceb07b9cf..0000000000000000000000000000000000000000 --- a/src/data.js +++ /dev/null @@ -1,27 +0,0 @@ -const data = [ - { - name: 'Regina', - base: 'tomate', - price_small: 6.5, - price_large: 9.95, - image: - 'https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300', - }, - { - name: 'Napolitaine', - base: 'tomate', - price_small: 6.5, - price_large: 8.95, - image: - 'https://images.unsplash.com/photo-1562707666-0ef112b353e0?&fit=crop&w=500&h=300', - }, - { - name: 'Spicy', - base: 'crème', - price_small: 5.5, - price_large: 8, - image: - 'https://images.unsplash.com/photo-1458642849426-cfb724f15ef7?fit=crop&w=500&h=300', - }, -]; -export default data; diff --git a/src/main.js b/src/main.js index 22c3e464878ca63b33c72c0c9bac94371f1e3748..52b9e8ca5a3c56dc40b8796dae72b88f4c7ed5b9 100644 --- a/src/main.js +++ b/src/main.js @@ -18,7 +18,7 @@ Router.routes = [ ]; // Router.navigate('/'); // affiche une page vide -pizzaList.pizzas = data; +// pizzaList.pizzas = data; // Router.navigate('/'); // affiche la liste des pizzas // B.1. Sélectionner des éléments @@ -40,15 +40,15 @@ document.querySelector( // ); // C.2. Navigation en JS : afficher/masquer un élément -const newsContainer = document.querySelector('.newsContainer'), - closeButton = newsContainer.querySelector('.closeButton'); -// affichage du bandeau de news -newsContainer.style.display = ''; -// gestion du bouton fermer -closeButton.addEventListener('click', event => { - event.preventDefault(); - newsContainer.style.display = 'none'; -}); +// const newsContainer = document.querySelector('.newsContainer'), +// closeButton = newsContainer.querySelector('.closeButton'); +// // affichage du bandeau de news +// newsContainer.style.display = ''; +// // gestion du bouton fermer +// closeButton.addEventListener('click', event => { +// event.preventDefault(); +// newsContainer.style.display = 'none'; +// }); // E.3. Deeplinking // détection des boutons précédent/suivant du navigateur : @@ -57,3 +57,30 @@ window.onpopstate = () => Router.navigate(document.location.pathname, false); // affichage de la page initiale : // même traitement que lors de l'appui sur les boutons précédent/suivant window.onpopstate(); + +// fetch('./news.html') +// .then( response => response.text()) +// .then( responseText => console.log(responseText)) + +// fetch('./news.html') +// .then( response => response.text()) +// .then( responseText => console.log(responseText)) + +function displayNews(html) { + // 1. injectez le contenu du fichier dans la section .newsContainer + const newsContainer = document.querySelector(".newsContainer") + newsContainer.innerHTML = html + const cloButton = newsContainer.querySelector('.closeButton') + // 2. affichez la balise .newsContainer + newsContainer.style.display = '' + + cloButton.addEventListener('click', event => { + event.preventDefault() + console.log("passer par la") + newsContainer.style.display = 'none' + }); +} +fetch('./news.html') + .then( response => response.text()) + .then( displayNews) + diff --git a/src/pages/PizzaList.js b/src/pages/PizzaList.js index de0d07f7b9eadee4fc14eb5e7854192fdae7b227..d4bbfa6bc4f24fdf4e6b1e9dc767c66403bfe866 100644 --- a/src/pages/PizzaList.js +++ b/src/pages/PizzaList.js @@ -13,4 +13,8 @@ export default class PizzaList extends Page { this.#pizzas = value; this.children = this.#pizzas.map(pizza => new PizzaThumbnail(pizza)); } + + mount(pizzas){ + this.pizzas = pizzas + } }