mirror of
https://github.com/picocss/pico.git
synced 2025-04-20 16:46:14 -04:00
refactor: lint
This commit is contained in:
parent
672b67896c
commit
7487498805
53 changed files with 1789 additions and 1078 deletions
|
@ -6,33 +6,32 @@
|
|||
*/
|
||||
|
||||
const grid = {
|
||||
|
||||
// Config
|
||||
buttons: {
|
||||
text: {
|
||||
add: 'Add column',
|
||||
remove: 'Remove column',
|
||||
add: "Add column",
|
||||
remove: "Remove column",
|
||||
},
|
||||
target: '#grid article',
|
||||
target: "#grid article",
|
||||
},
|
||||
grid: {
|
||||
current: 4,
|
||||
min: 1,
|
||||
max: 12,
|
||||
gridTarget: '#grid .grid',
|
||||
codeTarget: '#grid pre code',
|
||||
gridTarget: "#grid .grid",
|
||||
codeTarget: "#grid pre code",
|
||||
},
|
||||
|
||||
// Init
|
||||
init() {
|
||||
this.addButtons();
|
||||
this.generateGrid();
|
||||
this.addButtons()
|
||||
this.generateGrid()
|
||||
},
|
||||
|
||||
// Add buttons
|
||||
addButtons() {
|
||||
// Insert buttons
|
||||
let buttons = document.createElement('P');
|
||||
let buttons = document.createElement("P")
|
||||
buttons.innerHTML = `
|
||||
<button class="secondary add">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
|
||||
|
@ -47,54 +46,62 @@ const grid = {
|
|||
<line x1="5" y1="12" x2="19" y2="12"></line>
|
||||
</svg>
|
||||
${this.buttons.text.remove}
|
||||
</button>`;
|
||||
document.querySelector(this.buttons.target).before(buttons);
|
||||
</button>`
|
||||
document.querySelector(this.buttons.target).before(buttons)
|
||||
|
||||
// Add button listener
|
||||
document.querySelector('#grid button.add').addEventListener('click', () => {
|
||||
this.addColumn();
|
||||
}, false);
|
||||
document.querySelector("#grid button.add").addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
this.addColumn()
|
||||
},
|
||||
false
|
||||
)
|
||||
|
||||
// Remove button listener
|
||||
document.querySelector('#grid button.remove').addEventListener('click', () => {
|
||||
this.removeColumn();
|
||||
}, false);
|
||||
document.querySelector("#grid button.remove").addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
this.removeColumn()
|
||||
},
|
||||
false
|
||||
)
|
||||
},
|
||||
|
||||
// Generate grid
|
||||
generateGrid() {
|
||||
// Config
|
||||
let htmlInner = '';
|
||||
let codeInner = '<<b>div</b> <i>class</i>=<u>"grid"</u>>\n';
|
||||
let htmlInner = ""
|
||||
let codeInner = '<<b>div</b> <i>class</i>=<u>"grid"</u>>\n'
|
||||
|
||||
// Build
|
||||
for (let col = 0; col < this.grid.current; col++) {
|
||||
htmlInner += '<div>' + (col + 1) + '</div>';
|
||||
codeInner += ' <<b>div</b>>' + (col + 1) + '</<b>div</b>>\n';
|
||||
htmlInner += "<div>" + (col + 1) + "</div>"
|
||||
codeInner += " <<b>div</b>>" + (col + 1) + "</<b>div</b>>\n"
|
||||
}
|
||||
|
||||
// Display
|
||||
codeInner += '</<b>div</b>>';
|
||||
document.querySelector(this.grid.gridTarget).innerHTML = htmlInner;
|
||||
document.querySelector(this.grid.codeTarget).innerHTML = codeInner;
|
||||
codeInner += "</<b>div</b>>"
|
||||
document.querySelector(this.grid.gridTarget).innerHTML = htmlInner
|
||||
document.querySelector(this.grid.codeTarget).innerHTML = codeInner
|
||||
},
|
||||
|
||||
// Add column
|
||||
addColumn() {
|
||||
if (this.grid.current < this.grid.max) {
|
||||
this.grid.current++;
|
||||
this.generateGrid();
|
||||
this.grid.current++
|
||||
this.generateGrid()
|
||||
}
|
||||
},
|
||||
|
||||
// Remove column
|
||||
removeColumn() {
|
||||
if (this.grid.current > this.grid.min) {
|
||||
this.grid.current--;
|
||||
this.generateGrid();
|
||||
this.grid.current--
|
||||
this.generateGrid()
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// Init
|
||||
grid.init();
|
||||
grid.init()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue