import { AeroElement } from "./AeroElement.js"; import { WebPage } from "./WebPage.js"; import { LoadHandler } from "./aero.js"; import { AeroUtilities } from "./AeroUtilities.js"; /* Turn this: { _type: "aero-slide-prime", theme: "dark", title: `The power of tomorrow`, subtitle: "Hi There", paragraph: `this is a very long text indeed that spread on multiple lines`, background : { _type : "pic", source : "assets/truc0002.jpg" } }, into this:

Say Hello to OCTOFAN

The world's first H2-powered multirole heavy duty drone with switchable nacelles

*/ export class Grid extends AeroElement { /** @type {HTMLElement } */ sectionNode; type; props; /** @type {HTMLDivElement} */ deckNode; /** @type{boolean} */ hasBackgroundImage = false; /** @type{boolean} */ isBackgroundImageLoaded = false; /** @type{string} */ backgroundImagePath; constructor(type, props) { super(); this.type = type; this.props = props; } /** * * @param {WebPage} page * @param {*} state * @returns */ build(page) { /* CSS requirements */ page.css_requireStylesheet("/aero/Grid.css"); /* build nodes */ this.sectionNode = document.createElement("section"); this.sectionNode.classList.add("aero-grid"); this.setType(this.type); this.setTheme(this.props.theme ? this.props.theme : "light"); /* */ if (this.props.backgroundImage) { this.sectionNode.classList.add("background-pic"); AeroUtilities.loadBackgroundImage(this.sectionNode, this.props.backgroundImage); } else if (this.props.backgroundColor) { this.sectionNode.classList.add("background-colo"); this.sectionNode.style.backgroundColor = this.props.backgroundColor; } /* */ /* */ this.deckNode = document.createElement("div"); this.deckNode.classList.add("aero-grid-deck"); this.props.cards.forEach(card => this.deckNode.appendChild(card.build(page))); this.sectionNode.appendChild(this.deckNode); /* */ return this.sectionNode; } setType(type) { this.sectionNode.setAttribute("type", type); } setTheme(theme) { this.sectionNode.setAttribute("theme", theme); } render(state) { if (!this.isInitialized) { this.draw(); this.isInitialized = true; } } draw() { } } export class GridCard extends AeroElement { /** @type {HTMLDivElement } */ cardNode; type; props; /** @type {HTMLDivElement} */ assetNode; /** @type{boolean} */ hasBackgroundImage = false; /** @type{boolean} */ isBackgroundImageLoaded = false; /** @type{string} */ backgroundImagePath; constructor(type, props) { super(); this.type = type; this.props = props; } /** * * @param {LoadHandler} handler * @param {*} state * @returns */ build(page) { this.cardNode = document.createElement("div"); this.cardNode.classList.add("aero-grid-card"); /* */ if (this.props.backgroundImage) { this.cardNode.classList.add("background-pic"); AeroUtilities.loadBackgroundImage(this.cardNode, this.props.backgroundImage); } else if (this.props.backgroundColor) { this.cardNode.classList.add("background-color"); this.cardNode.style.backgroundColor = this.props.backgroundColor; } /* */ this.setType(this.type); this.setTheme(this.props.theme ? this.props.theme : "light"); return this.cardNode; } setType(type) { this.cardNode.setAttribute("type", type); } setTheme(theme) { this.cardNode.setAttribute("theme", theme); } }