Skip to content

Commit

Permalink
Merge pull request foundation#61 from yvmarques/patch-1
Browse files Browse the repository at this point in the history
Allow to add attributes to buttons and spacers
  • Loading branch information
rafibomb authored Sep 30, 2016
2 parents 39a43c3 + 0b5affa commit 0b402cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions lib/componentFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(element) {

// If we have the href attribute we can create an anchor for the inner of the button;
if (element.attr('href')) {
inner = format('<a href="%s"%s>%s</a>', element.attr('href'), target, inner);
inner = format('<a %s href="%s"%s>%s</a>', attrs, element.attr('href'), target, inner);
}

// If the button is expanded, it needs a <center> tag around the content
Expand Down Expand Up @@ -131,15 +131,15 @@ module.exports = function(element) {
if (element.attr('size-sm') || element.attr('size-lg')) {
if (element.attr('size-sm')) {
size = (element.attr('size-sm'));
html += '<table class="%s hide-for-large"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>';
html += format('<table %s class="%s hide-for-large"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>', attrs);
}
if (element.attr('size-lg')) {
size = (element.attr('size-lg'));
html += '<table class="%s show-for-large"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>';
html += format('<table %s class="%s show-for-large"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>', attrs);
}
} else {
size = (element.attr('size')) || 16;
html += '<table class="%s"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>';
html += format('<table %s class="%s"><tbody><tr><td height="'+size+'px" style="font-size:'+size+'px;line-height:'+size+'px;">&#xA0;</td></tr></tbody></table>', attrs);
}

if( element.attr('size-sm') && element.attr('size-lg') ) {
Expand Down
4 changes: 2 additions & 2 deletions lib/util/getAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// @returns {string} attributes pulled from inky objects
module.exports = function(el) {
var attrs = el.attr();
var ignoredAttributes = ['class', 'id', 'href', 'size', 'large', 'no-expander', 'small', 'target'];
var ignoredAttributes = ['class', 'id', 'href', 'size', 'size-sm', 'size-lg', 'large', 'no-expander', 'small', 'target'];
var result = '';

for (var key in attrs) {
if (ignoredAttributes.indexOf(key) == -1) result += (' ' + key + '=' + '"' + attrs[key] + '"');
}
return result;
}
}

0 comments on commit 0b402cc

Please sign in to comment.