mirror of
https://github.com/flarum/framework.git
synced 2025-05-23 07:09:57 +08:00
@ -1,6 +1,7 @@
|
||||
import Component from 'flarum/Component';
|
||||
import icon from 'flarum/helpers/icon';
|
||||
import extract from 'flarum/utils/extract';
|
||||
import extractText from 'flarum/utils/extractText';
|
||||
import LoadingIndicator from 'flarum/components/LoadingIndicator';
|
||||
|
||||
/**
|
||||
@ -27,6 +28,7 @@ export default class Button extends Component {
|
||||
|
||||
attrs.className = attrs.className || '';
|
||||
attrs.type = attrs.type || 'button';
|
||||
attrs.title = attrs.title || this.getDefaultTitle();
|
||||
|
||||
const iconName = extract(attrs, 'icon');
|
||||
if (iconName) attrs.className += ' hasIcon';
|
||||
@ -40,6 +42,16 @@ export default class Button extends Component {
|
||||
return <button {...attrs}>{this.getButtonContent()}</button>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default value for the title attribute.
|
||||
*
|
||||
* @return string
|
||||
* @protected
|
||||
*/
|
||||
getDefaultTitle() {
|
||||
return extractText(this.props.children);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the template for the button's content.
|
||||
*
|
||||
|
Reference in New Issue
Block a user