From: Jeremy Thomas Date: Fri, 13 May 2022 16:00:50 +0000 (+0200) Subject: Add grid interactions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=800fa207c53e6398813bb3e0cdb16e250c165e0b;p=thirdparty%2Fbulma.git Add grid interactions --- diff --git a/docs/_javascript/playground.js b/docs/_javascript/playground.js new file mode 100644 index 000000000..2b5a967ce --- /dev/null +++ b/docs/_javascript/playground.js @@ -0,0 +1,23 @@ +document.addEventListener("DOMContentLoaded", () => { + const $grid = document.getElementById("grid"); + const $columns = document.querySelectorAll(".jsColumns"); + + $columns.forEach(($) => + $.addEventListener( + "input", + (event) => { + const count = event.target.valueAsNumber; + const suffix = event.target.dataset.suffix; + console.log("Column count", count); + $grid.className = `grid has-${count}-cols${suffix}`; + const $columnsCount = getAll("strong", $.parentNode); + $columnsCount.innerHTML = count; + }, + false + ) + ); + + function getAll(selector, parent = document) { + return Array.prototype.slice.call(parent.querySelectorAll(selector), 0); + } +}); diff --git a/docs/cyp/grid/grid.html b/docs/cyp/grid/grid.html index 46c8c6988..b5b38fddd 100644 --- a/docs/cyp/grid/grid.html +++ b/docs/cyp/grid/grid.html @@ -1,27 +1,70 @@ --- layout: cypress title: Grid/Grid +breakpoints: +- name: mobile + visibility: mobile + count: 2 + suffix: '-mobile' +- name: tablet + visibility: tablet-only + count: 4 + suffix: '-tablet' +- name: desktop + visibility: desktop-only + count: 8 + suffix: '-desktop' +- name: widescreen + visibility: widescreen-only + count: 12 + suffix: '-widescreen' +- name: fullhd + visibility: fullhd + count: 16 + suffix: '-fullhd' --- -
-
#1
-
#2
-
#3
-
#4
-
#5
-
#6
-
#7
-
#8
-
#9
-
#10
-
#11
-
#12
-
#13
-
#14
-
#15
-
#16
-
#17
-
#18
-
#19
-
#20
-
\ No newline at end of file + + +
+ {% for breakpoint in page.breakpoints %} + + {% endfor %} + +
+ {% for breakpoint in page.breakpoints %} +
+ +
+

{{ breakpoint.count }} columns on {{ breakpoint.name }}

+ +
+
+ {% endfor %} +
+ +
+
#1
+
#2
+
#3
+
#4
+
#5
+
#6
+
#7
+
#8
+
#9
+
#10
+
#11
+
#12
+
#13
+
#14
+
#15
+
#16
+
#17
+
#18
+
#19
+
#20
+
+
diff --git a/docs/lib/playground.js b/docs/lib/playground.js new file mode 100644 index 000000000..be6f01736 --- /dev/null +++ b/docs/lib/playground.js @@ -0,0 +1,23 @@ +"use strict"; + +document.addEventListener("DOMContentLoaded", function () { + var $grid = document.getElementById("grid"); + var $columns = document.querySelectorAll(".jsColumns"); + + $columns.forEach(function ($) { + return $.addEventListener("input", function (event) { + var count = event.target.valueAsNumber; + var suffix = event.target.dataset.suffix; + console.log("Column count", count); + $grid.className = "grid has-" + count + "-cols" + suffix; + var $columnsCount = getAll("strong", $.parentNode); + $columnsCount.innerHTML = count; + }, false); + }); + + function getAll(selector) { + var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document; + + return Array.prototype.slice.call(parent.querySelectorAll(selector), 0); + } +}); \ No newline at end of file