From 36e2484fc0cd49fb8dce85ec2ff30c28ca4b0f7c Mon Sep 17 00:00:00 2001
From: Cody Dumortier <Cody.dumortier.etu@univ-lille.fr>
Date: Tue, 9 Feb 2021 10:39:14 +0100
Subject: [PATCH] =?UTF-8?q?afficher/masquer=20un=20=C3=A9l=C3=A9ment?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 2 +-
src/main.js | 27 +++++++++++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/package.json b/package.json
index c41a110..abdfa61 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --mode=production",
- "watch": "webpack --mode=development --watch"
+ "watch": "webpack --mode=development --watch"
},
"author": "Thomas Fritsch <thomas.fritsch@univ-lille.fr> (https://gitlab.univ-lille.fr/thomas.fritsch)",
"homepage": "https://gitlab.univ-lille.fr/js",
diff --git a/src/main.js b/src/main.js
index 6148d2b..04f78cc 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,13 +1,36 @@
import Router from './Router';
import data from './data';
import PizzaList from './pages/PizzaList';
+import Component from './components/Component';
Router.titleElement = document.querySelector('.pageTitle');
Router.contentElement = document.querySelector('.pageContent');
+document.querySelector('section').setAttribute('style', '');
-const pizzaList = new PizzaList([]);
-Router.routes = [{ path: '/', page: pizzaList, title: 'La carte' }];
+const link = document.querySelector('button'); // sélectionne le premier lien de la page
+
+link.addEventListener('click', event => {
+ event.preventDefault();
+ document.querySelector('section').setAttribute('style', 'display:none');
+ console.log(event);
+});
+
+const pizzaList = new PizzaList([]),
+ aboutPage = new Component('section', null, 'Ce site est génial'),
+ pizzaForm = new Component(
+ 'section',
+ null,
+ 'Ici vous pourrez ajouter une pizza'
+ );
+
+Router.routes = [
+ { path: '/', page: pizzaList, title: 'La carte' },
+ { path: '/a-propos', page: aboutPage, title: 'À propos' },
+ { path: '/ajouter-pizza', page: pizzaForm, title: 'Ajouter une pizza' },
+];
Router.navigate('/'); // affiche une page vide
pizzaList.pizzas = data;
Router.navigate('/'); // affiche la liste des pizzas
+
+Router.menuElement = document.querySelector('.mainMenu');
--
GitLab