framework/js/lib/components/action-button.js

22 lines
531 B
JavaScript
Raw Normal View History

2015-04-25 20:58:39 +08:00
import Component from 'flarum/component';
import icon from 'flarum/helpers/icon';
export default class ActionButton extends Component {
view() {
var attrs = {};
for (var i in this.props) { attrs[i] = this.props[i]; }
var iconName = attrs.icon;
delete attrs.icon;
var label = attrs.label;
delete attrs.label;
attrs.href = attrs.href || 'javascript:;';
return m('a'+(iconName ? '.has-icon' : ''), attrs, [
iconName ? icon(iconName+' icon') : '',
2015-04-25 20:58:39 +08:00
m('span.label', label)
]);
}
}