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
Matthieu Vannin
TP2 - POO et Modules
Commits
237dcd5a
Commit
237dcd5a
authored
4 years ago
by
Matthieu Vannin
Browse files
Options
Downloads
Patches
Plain Diff
Partie C terminée
parent
7e3bc429
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/Component.js
+15
-1
15 additions, 1 deletion
src/components/Component.js
src/components/PizzaThumbnails.js
+22
-0
22 additions, 0 deletions
src/components/PizzaThumbnails.js
src/main.js
+8
-6
8 additions, 6 deletions
src/main.js
with
45 additions
and
7 deletions
src/components/Component.js
+
15
−
1
View file @
237dcd5a
...
...
@@ -10,9 +10,23 @@ export default class Component {
renderAttribute
()
{
return
`<
${
this
.
tagName
}
${
this
.
attribute
.
name
}
="
${
this
.
attribute
.
value
}
"/>`
;
}
renderChildren
()
{
if
(
this
.
children
instanceof
Array
)
{
let
str
=
''
;
for
(
let
i
=
0
;
i
<
this
.
children
.
length
;
i
++
)
{
if
(
this
.
children
[
i
]
instanceof
Component
)
{
str
=
str
+
this
.
children
[
i
].
render
();
}
else
{
str
=
str
+
this
.
children
[
i
];
}
}
return
`<
${
this
.
tagName
}
>
${
str
}
</
${
this
.
tagName
}
>`
;
}
return
`<
${
this
.
tagName
}
>
${
this
.
children
}
</
${
this
.
tagName
}
>`
;
}
render
()
{
if
(
!
(
this
.
children
==
null
||
this
.
children
==
undefined
))
{
return
`<
${
this
.
tagName
}
>
${
this
.
children
}
</
${
this
.
tagName
}
>`
;
return
this
.
renderChildren
()
;
}
else
{
if
(
!
(
this
.
attribute
==
null
||
this
.
attribute
==
undefined
))
{
return
this
.
renderAttribute
();
...
...
This diff is collapsed.
Click to expand it.
src/components/PizzaThumbnails.js
0 → 100644
+
22
−
0
View file @
237dcd5a
import
Component
from
"
./Component
"
export
default
class
pizzaThumbnail
extends
Component
{
data
constructor
(
data
)
{
this
.
data
=
data
;
}
render
()
{
const
li
=
[
new
Component
(
'
li
'
,
`Prix petit format :
${
data
.
price_small
}
`
),
new
Component
(
'
li
'
,
`Prix grand format :
${
data
.
price_large
}
`
,
];
const
lu
=
new
Component
(
'
ul
'
,
li
);
const
h4
=
new
Component
(
'
h4
'
,
data
.
name
);
const
section
=
new
Component
(
'
section
'
,[
h4
,
ul
]);
const
img
=
new
Img
(
data
.
image
);
const
a
=
new
Component
(
'
a
'
,{
name
:
href
,
value
:
data
.
image
},[
img
,
section
]);
const
article
=
new
Component
(
'
article
'
,
{
name
:
class
,
value
:
"
pizzaThumbnail
"
},
a
);
this
.
data
.
render
();
}
}
This diff is collapsed.
Click to expand it.
src/main.js
+
8
−
6
View file @
237dcd5a
import
data
from
'
./data.js
'
;
import
Component
from
'
./components/Component.js
'
;
const
title
=
new
Component
(
'
h1
'
,
null
,
'
La carte
'
);
const
title
=
new
Component
(
'
h1
'
,
null
,
[
'
La
'
,
'
grosse
'
,
'
carte
'
]);
document
.
querySelector
(
'
.pageTitle
'
).
innerHTML
=
title
.
render
();
import
Img
from
'
./components/Img.js
'
;
const
img
=
new
Img
(
const
c
=
new
Component
(
'
article
'
,
{
name
:
'
class
'
,
value
:
'
pizzaThumbnail
'
},
[
new
Img
(
'
https://images.unsplash.com/photo-1532246420286-127bcd803104?fit=crop&w=500&h=300
'
);
document
.
querySelector
(
'
.pageContent
'
).
innerHTML
=
img
.
render
();
),
'
Regina
'
,
]);
document
.
querySelector
(
'
.pageContent
'
).
innerHTML
=
c
.
render
();
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