From 8bf3618e2e7202f24490d6225548fbd016473139 Mon Sep 17 00:00:00 2001 From: Geoff Kimball Date: Mon, 21 Mar 2016 13:00:01 -0700 Subject: [PATCH] Update grid to only print an expander if the column's width is equal to the total column count --- lib/makeColumn.js | 15 +++++++++------ test/grid.js | 10 ---------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/makeColumn.js b/lib/makeColumn.js index 4e87b77..25ce424 100644 --- a/lib/makeColumn.js +++ b/lib/makeColumn.js @@ -23,8 +23,11 @@ module.exports = function(col) { } // Check for sizes. If no attribute is provided, default to small-12. Divide evenly for large columns - classes.push(format('small-%s', $(col).attr('small') || this.columnCount)); - classes.push(format('large-%s', $(col).attr('large') || $(col).attr('small') || Math.floor(this.columnCount/colCount))); + var smallSize = $(col).attr('small') || this.columnCount; + var largeSize = $(col).attr('large') || $(col).attr('small') || Math.floor(this.columnCount / colCount); + + classes.push(format('small-%s', smallSize)); + classes.push(format('large-%s', largeSize)); // Add the basic "columns" class also classes.push('columns'); @@ -34,8 +37,9 @@ module.exports = function(col) { if (!$(col).next(this.components.columns).length) classes.push('last'); // If the column contains a nested row, the .expander class should not be used - if (!col.find('.row, row').length) { - expander = ''; + // The == on the first check is because we're comparing a string pulled from $.attr() to a number + if (largeSize == this.columnCount && col.find('.row, row').length === 0) { + expander = '\n'; } // Final HTML output @@ -43,8 +47,7 @@ module.exports = function(col) { - - %s + %s
%s%s
diff --git a/test/grid.js b/test/grid.js index 2cc87f0..af1f831 100644 --- a/test/grid.js +++ b/test/grid.js @@ -85,7 +85,6 @@ describe('Grid', () => { -
One
@@ -93,7 +92,6 @@ describe('Grid', () => { -
Two
@@ -113,7 +111,6 @@ describe('Grid', () => { -
One
@@ -121,7 +118,6 @@ describe('Grid', () => { -
Two
@@ -129,7 +125,6 @@ describe('Grid', () => { -
Three
@@ -165,7 +160,6 @@ describe('Grid', () => { -
One
@@ -173,7 +167,6 @@ describe('Grid', () => { -
Two
@@ -192,7 +185,6 @@ describe('Grid', () => { -
One
@@ -200,7 +192,6 @@ describe('Grid', () => { -
Two
@@ -225,7 +216,6 @@ describe('Grid', () => { -