/* * Grid Interaction * * Pico.css - https://picocss.com * Copyright 2019-2021 - Licensed under MIT */ export const grid = { // Config buttons: { text: { add: 'Add column', remove: 'Remove column', }, target: '#grids article', }, grid: { current: 4, min: 1, max: 12, gridTarget: '#grids .grid', codeTarget: '#grids pre code', }, // Init init() { this.addButtons(); this.generateGrid(); }, // Add buttons addButtons() { // Insert buttons let buttons = document.createElement('P'); buttons.innerHTML = ` `; document.querySelector(this.buttons.target).before(buttons); // Add button listener document.querySelector('#grids button.add').addEventListener( 'click', function () { this.addColumn(); }.bind(this), false ); // Remove button listener document.querySelector('#grids button.remove').addEventListener( 'click', function () { this.removeColumn(); }.bind(this), false ); }, // Generate grid generateGrid() { // Config let htmlInner = ''; let codeInner = '<div class="grid">\n'; // Build for (let col = 0; col < this.grid.current; col++) { htmlInner += '