Skip to content
Snippets Groups Projects
Commit 237dcd5a authored by Matthieu Vannin's avatar Matthieu Vannin
Browse files

Partie C terminée

parent 7e3bc429
Branches
No related tags found
No related merge requests found
......@@ -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();
......
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();
}
}
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();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment