Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/makeColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = function(col) {
// Check for sizes. If no attribute is provided, default to small-12. Divide evenly for large columns
var smallSize = $(col).attr('small') || this.columnCount;
var largeSize = $(col).attr('large') || $(col).attr('small') || Math.floor(this.columnCount / colCount);
var noExpander = $(col).attr('no-expander');

classes.push(format('small-%s', smallSize));
classes.push(format('large-%s', largeSize));
Expand All @@ -38,7 +39,7 @@ module.exports = function(col) {

// If the column contains a nested row, the .expander class should not be used
// 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) {
if (largeSize == this.columnCount && col.find('.row, row').length === 0 && (noExpander == undefined || noExpander == "false") ) {
expander = '\n<th class="expander"></th>';
}

Expand Down
46 changes: 46 additions & 0 deletions test/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,52 @@ describe('Grid', () => {
compare(input, expected);
});

it('creates a single column with first and last classes with no-expander', function () {
var input = '<columns large="12" small="12" no-expander>One</columns>';
var expected = `
<th class="small-12 large-12 columns first last">
<table>
<tr>
<th>One</th>
</tr>
</table>
</th>
`;

compare(input, expected);
});

it('creates a single column with first and last classes with no-expander="false"', function () {
var input = '<columns large="12" small="12" no-expander="false">One</columns>';
var expected = `
<th class="small-12 large-12 columns first last">
<table>
<tr>
<th>One</th>
<th class="expander"></th>
</tr>
</table>
</th>
`;

compare(input, expected);
});

it('creates a single column with first and last classes with no-expander="true"', function () {
var input = '<columns large="12" small="12" no-expander="true">One</columns>';
var expected = `
<th class="small-12 large-12 columns first last">
<table>
<tr>
<th>One</th>
</tr>
</table>
</th>
`;

compare(input, expected);
});

it('creates two columns, one first, one last', function () {
var input = `
<columns large="6" small="12">One</columns>
Expand Down