mirror of
https://github.com/flarum/core.git
synced 2025-08-11 10:55:47 +02:00
update: common/components/Badge
This commit is contained in:
committed by
Franz Liedke
parent
2c2a42030a
commit
0fe635d32c
@@ -6,18 +6,18 @@ import extract from '../utils/extract';
|
|||||||
* The `Badge` component represents a user/discussion badge, indicating some
|
* The `Badge` component represents a user/discussion badge, indicating some
|
||||||
* status (e.g. a discussion is stickied, a user is an admin).
|
* status (e.g. a discussion is stickied, a user is an admin).
|
||||||
*
|
*
|
||||||
* A badge may have the following special props:
|
* A badge may have the following special attrs:
|
||||||
*
|
*
|
||||||
* - `type` The type of badge this is. This will be used to give the badge a
|
* - `type` The type of badge this is. This will be used to give the badge a
|
||||||
* class name of `Badge--{type}`.
|
* class name of `Badge--{type}`.
|
||||||
* - `icon` The name of an icon to show inside the badge.
|
* - `icon` The name of an icon to show inside the badge.
|
||||||
* - `label`
|
* - `label`
|
||||||
*
|
*
|
||||||
* All other props will be assigned as attributes on the badge element.
|
* All other attrs will be assigned as attributes on the badge element.
|
||||||
*/
|
*/
|
||||||
export default class Badge extends Component {
|
export default class Badge extends Component {
|
||||||
view() {
|
view() {
|
||||||
const attrs = Object.assign({}, this.props);
|
const attrs = Object.assign({}, this.attrs);
|
||||||
const type = extract(attrs, 'type');
|
const type = extract(attrs, 'type');
|
||||||
const iconName = extract(attrs, 'icon');
|
const iconName = extract(attrs, 'icon');
|
||||||
|
|
||||||
@@ -27,9 +27,9 @@ export default class Badge extends Component {
|
|||||||
return <span {...attrs}>{iconName ? icon(iconName, { className: 'Badge-icon' }) : m.trust(' ')}</span>;
|
return <span {...attrs}>{iconName ? icon(iconName, { className: 'Badge-icon' }) : m.trust(' ')}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
config(isInitialized) {
|
oncreate(vnode) {
|
||||||
if (isInitialized) return;
|
super.oncreate(vnode);
|
||||||
|
|
||||||
if (this.props.label) this.$().tooltip();
|
if (this.attrs.label) this.$().tooltip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user