Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TP2 - POO et Modules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mathis Verleene
TP2 - POO et Modules
Commits
8aac0ad7
Commit
8aac0ad7
authored
4 years ago
by
Mathis Verleene
Browse files
Options
Downloads
Patches
Plain Diff
D.4
parent
3f9283fe
Branches
master
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Pages/PizzaList.js
+15
-0
15 additions, 0 deletions
src/Pages/PizzaList.js
src/Router.js
+15
-6
15 additions, 6 deletions
src/Router.js
src/components/PizzaList.js
+0
-14
0 additions, 14 deletions
src/components/PizzaList.js
src/main.js
+11
-5
11 additions, 5 deletions
src/main.js
with
41 additions
and
25 deletions
src/Pages/PizzaList.js
0 → 100644
+
15
−
0
View file @
8aac0ad7
import
Component
from
'
../components/Component.js
'
;
import
Img
from
'
../components/Img.js
'
;
import
PizzaThumbnail
from
'
../components/PizzaThumbnail.js
'
;
export
default
class
PizzaList
extends
Component
{
#pizzas
;
set
pizzas
(
value
)
{
this
.
#pizzas
=
value
;
this
.
children
=
this
.
#pizzas
.
map
(
pizza
=>
new
PizzaThumbnail
(
pizza
));
}
constructor
(
pizzas
)
{
super
(
'
section
'
,
{
name
:
'
class
'
,
value
:
'
pizzaList
'
});
this
.
pizzas
=
pizzas
;
}
}
This diff is collapsed.
Click to expand it.
src/Router.js
+
15
−
6
View file @
8aac0ad7
class
Router
{
import
Component
from
'
./components/Component.js
'
;
export
default
class
Router
{
static
titleElement
;
static
contentElement
;
static
routes
;
static
naviagte
(
path
)
{}
static
navigate
(
path
)
{
this
.
routes
.
forEach
(
e
=>
{
if
(
e
.
path
==
path
)
{
const
title
=
new
Component
(
'
h1
'
,
null
,
e
.
title
);
Router
.
titleElement
.
innerHTML
=
title
.
render
();
Router
.
contentElement
.
innerHTML
=
e
.
page
.
render
();
}
});
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/components/PizzaList.js
deleted
100644 → 0
+
0
−
14
View file @
3f9283fe
import
Component
from
'
./Component.js
'
;
import
Img
from
'
./Img.js
'
;
import
PizzaThumbnail
from
'
./PizzaThumbnail.js
'
;
export
default
class
PizzaList
extends
Component
{
constructor
(
data
)
{
let
idx
=
0
;
let
tabPiz
=
[];
data
.
forEach
(
e
=>
{
tabPiz
.
push
(
new
PizzaThumbnail
(
e
));
idx
++
;
});
super
(
'
section
'
,
{
name
:
'
class
'
,
value
:
'
pizzaList
'
},
tabPiz
);
}
}
This diff is collapsed.
Click to expand it.
src/main.js
+
11
−
5
View file @
8aac0ad7
...
...
@@ -2,13 +2,19 @@ import Component from './components/Component.js';
import
data
from
'
./data.js
'
;
import
Img
from
'
./components/Img.js
'
;
import
PizzaThumbnail
from
'
./components/PizzaThumbnail.js
'
;
import
PizzaList
from
'
./components/PizzaList.js
'
;
const
title
=
new
Component
(
'
h1
'
,
null
,
[
'
La
'
,
'
'
,
'
carte
'
]);
document
.
querySelector
(
'
.pageTitle
'
).
innerHTML
=
title
.
render
();
import
PizzaList
from
'
./Pages/PizzaList.js
'
;
import
Router
from
'
./Router.js
'
;
// const title = new Component('h1', null, ['La', ' ', 'carte']);
// document.querySelector('.pageTitle').innerHTML = title.render();
const
pizzaList
=
new
PizzaList
(
data
);
document
.
querySelector
(
'
.pageContent
'
).
innerHTML
=
pizzaList
.
render
();
// document.querySelector('.pageContent').innerHTML = pizzaList.render();
Router
.
titleElement
=
document
.
querySelector
(
'
.pageTitle
'
);
Router
.
contentElement
=
document
.
querySelector
(
'
.pageContent
'
);
const
pizzaList
=
new
PizzaList
([]);
Router
.
routes
=
[{
path
:
'
/
'
,
page
:
pizzaList
,
title
:
'
La carte
'
}];
Router
.
navigate
(
'
/
'
);
// affiche une page vide
pizzaList
.
pizzas
=
data
;
Router
.
navigate
(
'
/
'
);
// affiche la liste des pizzas
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment