diff --git a/docs/_includes/components/spacing-table.html b/docs/_includes/components/spacing-table.html
new file mode 100644
index 00000000..dcc5b937
--- /dev/null
+++ b/docs/_includes/components/spacing-table.html
@@ -0,0 +1,54 @@
+
+
+ Because every developer has their own preferences, and to satisfy Bulma's customization features, it's possible to specify your own class name shortcuts as well as the spacing values.
+
+
+ For example, if you wanted:
+
+
+ -
+ margin to be abbreviated to
mg
+
+ -
+ padding to be totally excluded
+
+ -
+ horizontal to be abbreviated to
h
as shortcut
+
+ -
+ vertical to be ommited
+
+ -
+ to only have 3 values: "small" at
10px
, "medium" at 30px
, and "large" at 60px
+
+
+
+ You can simplify the CSS output by customizing these SCSS variables:
+
+
+
+{% highlight scss %}{{ custom }}{% endhighlight %}
+
+{% include
+ components/spacing-table.html
+ values=page.customValues
+ shortcuts=page.customShortcuts
+ directions=page.directions
+ horizontal=page.customHorizontal
+%}
+
+
+ By customizing the output, you've narrowed down the list of spacing helpers from 84 to only 15.
+
diff --git a/docs/lib/main.js b/docs/lib/main.js
index 5b47259a..bb41995c 100644
--- a/docs/lib/main.js
+++ b/docs/lib/main.js
@@ -351,36 +351,38 @@ document.addEventListener('DOMContentLoaded', function () {
// Spacing table
- var spacingEl = document.getElementById('spacingTable');
- var spacingRows = getAll('tbody tr', spacingEl);
- var spacingCells = getAll('tbody td', spacingEl);
- var spacingValues = getAll('tfoot th', spacingEl);
+ var spacingTables = getAll('.bd-spacing-table');
- spacingEl.addEventListener('mouseleave', function () {
- resetTable();
- });
+ spacingTables.forEach(function (spacingEl) {
+ var spacingRows = getAll('tbody tr', spacingEl);
+ var spacingCells = getAll('tbody td', spacingEl);
+ var spacingValues = getAll('tfoot th', spacingEl);
- spacingCells.forEach(function (el) {
- el.addEventListener('mouseenter', function () {
- resetTable();
- var row = Array.prototype.indexOf.call(el.parentNode.parentNode.children, el.parentNode);
- var column = Array.prototype.indexOf.call(el.parentNode.children, el);
- highlightRowAndColumn(row, column);
+ spacingEl.addEventListener('mouseleave', function () {
+ resetTable(spacingCells, spacingValues);
+ });
+
+ spacingCells.forEach(function (el) {
+ el.addEventListener('mouseenter', function () {
+ resetTable(spacingCells, spacingValues);
+ var row = Array.prototype.indexOf.call(el.parentNode.parentNode.children, el.parentNode);
+ var column = Array.prototype.indexOf.call(el.parentNode.children, el);
+ highlightRowAndColumn(row, column, spacingRows, spacingValues);
+ });
});
});
- function resetTable() {
- // spacingRows.forEach(el => el.classList.remove('bd-current-row'));
- spacingCells.forEach(function (el) {
+ function resetTable(cells, values) {
+ cells.forEach(function (el) {
return el.classList.remove('bd-current-row', 'bd-current-column');
});
- spacingValues.forEach(function (el) {
+ values.forEach(function (el) {
return el.classList.remove('bd-current-value');
});
}
- function highlightRowAndColumn(rowIndex, columnIndex) {
- var row = spacingRows[rowIndex];
+ function highlightRowAndColumn(rowIndex, columnIndex, rows, values) {
+ var row = rows[rowIndex];
var i = columnIndex;
while (i > -1) {
@@ -388,7 +390,7 @@ document.addEventListener('DOMContentLoaded', function () {
i--;
}
- var nextRows = spacingRows.slice(rowIndex);
+ var nextRows = rows.slice(rowIndex);
nextRows.forEach(function (r) {
r.children[columnIndex].classList.add('bd-current-column');
});
@@ -396,7 +398,7 @@ document.addEventListener('DOMContentLoaded', function () {
if (columnIndex < 2) {
return;
}
- spacingValues[columnIndex - 1].classList.add('bd-current-value');
+ values[columnIndex - 1].classList.add('bd-current-value');
}
// Scroll