mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2024-12-26 22:30:44 -05:00
feat: carousel and components
This commit is contained in:
parent
2b44a5611e
commit
e65acd8723
4 changed files with 45 additions and 9 deletions
|
@ -2,6 +2,31 @@ class Carousel {
|
||||||
constructor(items) {
|
constructor(items) {
|
||||||
this.items = 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 };
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
import { menuBar } from "./menu";
|
import { carousel } from "./components/carousel"
|
||||||
|
import { menuBar as navbar } from "./components/navbar";
|
||||||
import './style.css'
|
import './style.css'
|
||||||
|
|
||||||
function navbar(){
|
function nav(){
|
||||||
const element = document.createElement('div');
|
const element = document.createElement('header');
|
||||||
let menu = new menuBar();
|
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);
|
element.appendChild(menu);
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
|
@ -20,5 +25,6 @@ function content(data) {
|
||||||
return content;
|
return content;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
let carouselComponent = carousel.createComponent();
|
||||||
document.body.appendChild(navbar());
|
document.body.appendChild(nav());
|
||||||
|
document.body.appendChild(carouselComponent);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 150px 150px 150px;
|
grid-template-columns: repeat(3, 100px);
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue