Skip to content

Commit

Permalink
Update <button> output to support new expanded button syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
gakimball committed Feb 11, 2016
1 parent 59cb6d2 commit f1ff4e2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
5 changes: 5 additions & 0 deletions lib/componentFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ module.exports = function(element) {
inner = format('<a href="%s">%s</a>', component.attr('href'), inner);
}

// If the button is expanded, it needs a <center> tag around the content
if (component.hasClass('expand')) {
inner = '<center>' + inner + '</center>';
}

// The .button class is always there, along with any others on the <button> element
var classes = ['button'];
if (component.attr('class')) {
Expand Down
5 changes: 2 additions & 3 deletions lib/inky.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var extend = require('util')._extend;
var format = require('util').format;
var values = require('object-values');
var extend = require('util')._extend;
var values = require('object-values');

module.exports = Inky;

Expand Down
27 changes: 25 additions & 2 deletions test/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ describe('Button', () => {

it('creates a button with classes', () => {
var input = `
<button class="small alert expand" href="http://zurb.com">Button</button>
<button class="small alert" href="http://zurb.com">Button</button>
`;
var expected = `
<table class="button small alert expand">
<table class="button small alert">
<tr>
<td>
<table>
Expand All @@ -40,6 +40,29 @@ describe('Button', () => {

compare(input, expected);
});

it('creates a correct expanded button', () => {
var input = `
<button class="expand" href="http://zurb.com">Button</button>
`;
var expected = `
<table class="button expand">
<tr>
<td>
<table>
<tr>
<td>
<center><a href="http://zurb.com">Button</a></center>
</td>
</tr>
</table>
</td>
</tr>
</table>
`;

compare(input, expected);
});
});

describe('Menu', () => {
Expand Down

0 comments on commit f1ff4e2

Please sign in to comment.