UNPKG

gd-bs

Version:

Bootstrap JavaScript, TypeScript and Web Components library.

136 lines (135 loc) 5.08 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Jumbotron = exports.JumbotronTypeClassNames = exports.JumbotronSizeClassNames = exports.JumbotronTypes = exports.JumbotronSize = void 0; var base_1 = require("../base"); var classNames_1 = require("../classNames"); var common_1 = require("../common"); var templates_1 = require("./templates"); /** * Jumbotron Size */ var JumbotronSize; (function (JumbotronSize) { JumbotronSize[JumbotronSize["XSmall"] = 1] = "XSmall"; JumbotronSize[JumbotronSize["Small"] = 2] = "Small"; JumbotronSize[JumbotronSize["Medium"] = 3] = "Medium"; JumbotronSize[JumbotronSize["Large"] = 4] = "Large"; JumbotronSize[JumbotronSize["XLarge"] = 5] = "XLarge"; })(JumbotronSize = exports.JumbotronSize || (exports.JumbotronSize = {})); /** * Jumbotron Types */ var JumbotronTypes; (function (JumbotronTypes) { JumbotronTypes[JumbotronTypes["Danger"] = 1] = "Danger"; JumbotronTypes[JumbotronTypes["Dark"] = 2] = "Dark"; JumbotronTypes[JumbotronTypes["Info"] = 3] = "Info"; JumbotronTypes[JumbotronTypes["Light"] = 4] = "Light"; JumbotronTypes[JumbotronTypes["Primary"] = 5] = "Primary"; JumbotronTypes[JumbotronTypes["Secondary"] = 6] = "Secondary"; JumbotronTypes[JumbotronTypes["Success"] = 7] = "Success"; JumbotronTypes[JumbotronTypes["Warning"] = 8] = "Warning"; })(JumbotronTypes = exports.JumbotronTypes || (exports.JumbotronTypes = {})); /** * Jumbotron Classes */ exports.JumbotronSizeClassNames = new classNames_1.ClassNames([ "py-1", "py-2", "py-3", "py-4", "py-5" ]); /** * Jumbotron Classes */ exports.JumbotronTypeClassNames = new classNames_1.ClassNames([ "jumbotron-danger", "jumbotron-dark", "jumbotron-info", "jumbotron-light", "jumbotron-primary", "jumbotron-secondary", "jumbotron-success", "jumbotron-warning" ]); /** * Jumbotron */ var _Jumbotron = /** @class */ (function (_super) { __extends(_Jumbotron, _super); // Constructor function _Jumbotron(props, template) { if (template === void 0) { template = templates_1.HTML; } var _this = _super.call(this, template, props) || this; // Configure the collapse _this.configure(); // Configure the events _this.configureEvents(); // Configure the parent _this.configureParent(); return _this; } // Configure the card group _Jumbotron.prototype.configure = function () { // Set the class names this.props.isFluid ? this.el.classList.add("jumbotron-fluid") : null; // Set the title var title = this.el.querySelector("h1"); if (title) { if (this.props.title) { // Set the title title.innerHTML = this.props.title; } else { // Remove the title this.el.removeChild(title); } } // Set the lead var lead = this.el.querySelector("p"); if (lead) { if (this.props.lead) { // Set the lead lead.innerHTML = this.props.lead; } else { // Remove the lead this.el.removeChild(lead); } } // Set the size var className = exports.JumbotronSizeClassNames.getByType(this.props.size) || exports.JumbotronSizeClassNames.getByType(JumbotronSize.XLarge); this.el.classList.add(className); // Set the type className = exports.JumbotronTypeClassNames.getByType(this.props.type); if (className) { this.el.classList.add(className); } // Append the content (0, common_1.appendContent)(this.el, this.props.content); }; // Configures the events _Jumbotron.prototype.configureEvents = function () { // Call the render event this.props.onRenderContent ? this.props.onRenderContent(this.el) : null; }; return _Jumbotron; }(base_1.Base)); var Jumbotron = function (props, template) { return new _Jumbotron(props, template); }; exports.Jumbotron = Jumbotron;