mirror of
https://github.com/flarum/core.git
synced 2025-10-11 06:54:26 +02:00
Improve Button component to only show tooltip if textual content is available
This commit is contained in:
13
js/admin/dist/app.js
vendored
13
js/admin/dist/app.js
vendored
@@ -17862,7 +17862,11 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
|
|||||||
|
|
||||||
attrs.className = attrs.className || '';
|
attrs.className = attrs.className || '';
|
||||||
attrs.type = attrs.type || 'button';
|
attrs.type = attrs.type || 'button';
|
||||||
attrs.title = attrs.title || this.getDefaultTitle();
|
|
||||||
|
// If nothing else is provided, we use the textual button content as tooltip
|
||||||
|
if (!attrs.title && this.props.children) {
|
||||||
|
attrs.title = extractText(attrs.title);
|
||||||
|
}
|
||||||
|
|
||||||
var iconName = extract(attrs, 'icon');
|
var iconName = extract(attrs, 'icon');
|
||||||
if (iconName) attrs.className += ' hasIcon';
|
if (iconName) attrs.className += ' hasIcon';
|
||||||
@@ -17879,11 +17883,6 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
|
|||||||
this.getButtonContent()
|
this.getButtonContent()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
key: 'getDefaultTitle',
|
|
||||||
value: function getDefaultTitle() {
|
|
||||||
return extractText(this.props.children);
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getButtonContent',
|
key: 'getButtonContent',
|
||||||
value: function getButtonContent() {
|
value: function getButtonContent() {
|
||||||
@@ -18576,7 +18575,7 @@ System.register('flarum/components/ExtensionsPage', ['flarum/components/Page', '
|
|||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
data: { enabled: !enabled }
|
data: { enabled: !enabled }
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
if (enabled) localStorage.setItem('enabledExtension', id);
|
if (!enabled) localStorage.setItem('enabledExtension', id);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
11
js/forum/dist/app.js
vendored
11
js/forum/dist/app.js
vendored
@@ -19185,7 +19185,11 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
|
|||||||
|
|
||||||
attrs.className = attrs.className || '';
|
attrs.className = attrs.className || '';
|
||||||
attrs.type = attrs.type || 'button';
|
attrs.type = attrs.type || 'button';
|
||||||
attrs.title = attrs.title || this.getDefaultTitle();
|
|
||||||
|
// If nothing else is provided, we use the textual button content as tooltip
|
||||||
|
if (!attrs.title && this.props.children) {
|
||||||
|
attrs.title = extractText(attrs.title);
|
||||||
|
}
|
||||||
|
|
||||||
var iconName = extract(attrs, 'icon');
|
var iconName = extract(attrs, 'icon');
|
||||||
if (iconName) attrs.className += ' hasIcon';
|
if (iconName) attrs.className += ' hasIcon';
|
||||||
@@ -19202,11 +19206,6 @@ System.register('flarum/components/Button', ['flarum/Component', 'flarum/helpers
|
|||||||
this.getButtonContent()
|
this.getButtonContent()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
key: 'getDefaultTitle',
|
|
||||||
value: function getDefaultTitle() {
|
|
||||||
return extractText(this.props.children);
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
key: 'getButtonContent',
|
key: 'getButtonContent',
|
||||||
value: function getButtonContent() {
|
value: function getButtonContent() {
|
||||||
|
@@ -28,7 +28,11 @@ export default class Button extends Component {
|
|||||||
|
|
||||||
attrs.className = attrs.className || '';
|
attrs.className = attrs.className || '';
|
||||||
attrs.type = attrs.type || 'button';
|
attrs.type = attrs.type || 'button';
|
||||||
attrs.title = attrs.title || this.getDefaultTitle();
|
|
||||||
|
// If nothing else is provided, we use the textual button content as tooltip
|
||||||
|
if (!attrs.title && this.props.children) {
|
||||||
|
attrs.title = extractText(attrs.title);
|
||||||
|
}
|
||||||
|
|
||||||
const iconName = extract(attrs, 'icon');
|
const iconName = extract(attrs, 'icon');
|
||||||
if (iconName) attrs.className += ' hasIcon';
|
if (iconName) attrs.className += ' hasIcon';
|
||||||
@@ -42,16 +46,6 @@ export default class Button extends Component {
|
|||||||
return <button {...attrs}>{this.getButtonContent()}</button>;
|
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.
|
* Get the template for the button's content.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user