mirror of
https://github.com/flarum/core.git
synced 2025-08-11 10:55:47 +02:00
update: NotificationsDropdown
This commit is contained in:
committed by
Franz Liedke
parent
d097e7ed4b
commit
20e69e6351
@@ -3,21 +3,21 @@ import icon from '../../common/helpers/icon';
|
|||||||
import NotificationList from './NotificationList';
|
import NotificationList from './NotificationList';
|
||||||
|
|
||||||
export default class NotificationsDropdown extends Dropdown {
|
export default class NotificationsDropdown extends Dropdown {
|
||||||
static initProps(props) {
|
initAttrs(attrs) {
|
||||||
props.className = props.className || 'NotificationsDropdown';
|
attrs.className = attrs.className || 'NotificationsDropdown';
|
||||||
props.buttonClassName = props.buttonClassName || 'Button Button--flat';
|
attrs.buttonClassName = attrs.buttonClassName || 'Button Button--flat';
|
||||||
props.menuClassName = props.menuClassName || 'Dropdown-menu--right';
|
attrs.menuClassName = attrs.menuClassName || 'Dropdown-menu--right';
|
||||||
props.label = props.label || app.translator.trans('core.forum.notifications.tooltip');
|
attrs.label = attrs.label || app.translator.trans('core.forum.notifications.tooltip');
|
||||||
props.icon = props.icon || 'fas fa-bell';
|
attrs.icon = attrs.icon || 'fas fa-bell';
|
||||||
|
|
||||||
super.initProps(props);
|
super.initAttrs(attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
getButton() {
|
getButton() {
|
||||||
const newNotifications = this.getNewCount();
|
const newNotifications = this.getNewCount();
|
||||||
const vdom = super.getButton();
|
const vdom = super.getButton();
|
||||||
|
|
||||||
vdom.attrs.title = this.props.label;
|
vdom.attrs.title = this.attrs.label;
|
||||||
|
|
||||||
vdom.attrs.className += newNotifications ? ' new' : '';
|
vdom.attrs.className += newNotifications ? ' new' : '';
|
||||||
vdom.attrs.onclick = this.onclick.bind(this);
|
vdom.attrs.onclick = this.onclick.bind(this);
|
||||||
@@ -29,16 +29,16 @@ export default class NotificationsDropdown extends Dropdown {
|
|||||||
const unread = this.getUnreadCount();
|
const unread = this.getUnreadCount();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
icon(this.props.icon, { className: 'Button-icon' }),
|
icon(this.attrs.icon, { className: 'Button-icon' }),
|
||||||
unread ? <span className="NotificationsDropdown-unread">{unread}</span> : '',
|
unread ? <span className="NotificationsDropdown-unread">{unread}</span> : '',
|
||||||
<span className="Button-label">{this.props.label}</span>,
|
<span className="Button-label">{this.attrs.label}</span>,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
getMenu() {
|
getMenu() {
|
||||||
return (
|
return (
|
||||||
<div className={'Dropdown-menu ' + this.props.menuClassName} onclick={this.menuClick.bind(this)}>
|
<div className={'Dropdown-menu ' + this.attrs.menuClassName} onclick={this.menuClick.bind(this)}>
|
||||||
{this.showing ? NotificationList.component({ state: this.props.state }) : ''}
|
{this.showing ? NotificationList.component({ state: this.attrs.state }) : ''}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ export default class NotificationsDropdown extends Dropdown {
|
|||||||
if (app.drawer.isOpen()) {
|
if (app.drawer.isOpen()) {
|
||||||
this.goToRoute();
|
this.goToRoute();
|
||||||
} else {
|
} else {
|
||||||
this.props.state.load();
|
this.attrs.state.load();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user