diff --git a/restaurant/src/components/carousel.js b/restaurant/src/components/carousel.js index 89b6c13..7ce9a41 100644 --- a/restaurant/src/components/carousel.js +++ b/restaurant/src/components/carousel.js @@ -2,6 +2,31 @@ class Carousel { constructor(items) { this.items = items; }; + + carouselDiv = document.createElement('div'); + createComponent() { + this.carouselDiv.classList.add(['carousel']); + + this.items.forEach(element => { + let div = document.createElement('div'); + div.classList.add(['carousel-item']); + + let heading = document.createElement('h1'); + let desc = document.createElement('p'); + let link = document.createElement('a'); + + heading.textContent = element.heading; + desc.textContent = element.desc; + link.textContent = element.link; + + div.appendChild(heading); + div.appendChild(desc); + div.appendChild(link); + + this.carouselDiv.appendChild(div); + }); + return this.carouselDiv; + }; }; @@ -41,4 +66,9 @@ let carouselItems = [ } ] -carouselItems.forEach(e => new Items(e)); +let items = carouselItems.map(e => new Items(e.heading, e.desc, e.link)); +let carousel = new Carousel(items); + +export { carousel }; + + diff --git a/restaurant/src/menu.js b/restaurant/src/components/navbar.js similarity index 100% rename from restaurant/src/menu.js rename to restaurant/src/components/navbar.js diff --git a/restaurant/src/index.js b/restaurant/src/index.js index eaeb99c..99c6036 100644 --- a/restaurant/src/index.js +++ b/restaurant/src/index.js @@ -1,11 +1,16 @@ -import { menuBar } from "./menu"; +import { carousel } from "./components/carousel" +import { menuBar as navbar } from "./components/navbar"; import './style.css' -function navbar(){ - const element = document.createElement('div'); - let menu = new menuBar(); +function nav(){ + const element = document.createElement('header'); + const brandName = document.createElement('h1'); + let menu = new navbar(); - element.classList.add(['container']); + brandName.style.textAlign = 'center'; + brandName.textContent = 'This Wondrous Coffee'; + + element.appendChild(brandName); element.appendChild(menu); return element; @@ -20,5 +25,6 @@ function content(data) { return content; } - -document.body.appendChild(navbar()); +let carouselComponent = carousel.createComponent(); +document.body.appendChild(nav()); +document.body.appendChild(carouselComponent); diff --git a/restaurant/src/style.css b/restaurant/src/style.css index 0131322..f7ff5dd 100644 --- a/restaurant/src/style.css +++ b/restaurant/src/style.css @@ -13,7 +13,7 @@ .navbar { display: grid; - grid-template-columns: 150px 150px 150px; + grid-template-columns: repeat(3, 100px); gap: 15px; }