@@ -43,7 +43,7 @@ export default class NotificationList extends Component {
// Get the discussion that this notification is related to. If it's not
// directly related to a discussion, it may be related to a post or
// other entity which is related to a discussion.
- let discussion = false;
+ let discussion = null;
if (subject instanceof Discussion) discussion = subject;
else if (subject && subject.discussion) discussion = subject.discussion();
@@ -65,8 +65,8 @@ export default class NotificationList extends Component {
{group.discussion ? (
- {badges && badges.length ?
: ''}
- {group.discussion.title()}
+ {badges && badges.length &&
}
+
{group.discussion.title()}
) : (
{app.forum.attribute('title')}
diff --git a/framework/core/js/src/forum/components/NotificationsDropdown.js b/framework/core/js/src/forum/components/NotificationsDropdown.js
index 7099ab66f..860189808 100644
--- a/framework/core/js/src/forum/components/NotificationsDropdown.js
+++ b/framework/core/js/src/forum/components/NotificationsDropdown.js
@@ -1,5 +1,6 @@
import Dropdown from '../../common/components/Dropdown';
import icon from '../../common/helpers/icon';
+import classList from '../../common/utils/classList';
import NotificationList from './NotificationList';
export default class NotificationsDropdown extends Dropdown {
@@ -9,6 +10,7 @@ export default class NotificationsDropdown extends Dropdown {
attrs.menuClassName = attrs.menuClassName || 'Dropdown-menu--right';
attrs.label = attrs.label || app.translator.trans('core.forum.notifications.tooltip');
attrs.icon = attrs.icon || 'fas fa-bell';
+
// For best a11y support, both `title` and `aria-label` should be used
attrs.accessibleToggleLabel = attrs.accessibleToggleLabel || app.translator.trans('core.forum.notifications.toggle_dropdown_accessible_label');
@@ -21,7 +23,7 @@ export default class NotificationsDropdown extends Dropdown {
vdom.attrs.title = this.attrs.label;
- vdom.attrs.className += newNotifications ? ' new' : '';
+ vdom.attrs.className = classList(vdom.attrs.className, [newNotifications && 'new']);
vdom.attrs.onclick = this.onclick.bind(this);
return vdom;
@@ -32,15 +34,15 @@ export default class NotificationsDropdown extends Dropdown {
return [
icon(this.attrs.icon, { className: 'Button-icon' }),
- unread ?
{unread} : '',
+ unread !== 0 &&
{unread},
{this.attrs.label},
];
}
getMenu() {
return (
-
- {this.showing ? NotificationList.component({ state: this.attrs.state }) : ''}
+
+ {this.showing && NotificationList.component({ state: this.attrs.state })}
);
}
diff --git a/framework/core/less/forum/NotificationList.less b/framework/core/less/forum/NotificationList.less
index 4b4ee2e77..5e7a4d901 100644
--- a/framework/core/less/forum/NotificationList.less
+++ b/framework/core/less/forum/NotificationList.less
@@ -1,48 +1,60 @@
-
.NotificationList {
overflow: hidden;
- & .loading-indicator {
- height: 100px;
- }
-}
-.NotificationList-header {
- @media @tablet-up {
- padding: 12px 15px;
- border-bottom: 1px solid @control-bg;
+ &-header {
+ @media @tablet-up {
+ padding: 12px 15px;
+ border-bottom: 1px solid @control-bg;
- h4 {
- font-size: 12px;
- text-transform: uppercase;
- font-weight: bold;
- margin: 0;
- color: @muted-color;
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ h4 {
+ font-size: 12px;
+ text-transform: uppercase;
+ font-weight: bold;
+ margin: 0;
+ color: @muted-color;
+ }
}
- }
- .Button {
- float: right;
- margin-top: -11px;
- margin-right: -11px;
- // The NotificationList may be displayed inside of the drawer as a
- // dropdown menu – but the drawer may have .light-contents() applied to
- // it. In this case we will need to reset the button's styles back to
- // normal.
- & when (@config-colored-header = true) {
- .Button--color(@control-color, @control-bg);
+ // Mark all as read button
+ .Button {
+ padding: 0;
+ text-decoration: none;
- &:hover {
- color: @link-color;
+ // The NotificationList may be displayed inside of the drawer as a
+ // dropdown menu – but the drawer may have .light-contents() applied to
+ // it. In this case we will need to reset the button's styles back to
+ // normal.
+ & when (@config-colored-header = true) {
+ color: @control-color;
+
+ &:hover,
+ &:focus {
+ color: @link-color;
+ }
+ }
+
+ .add-keyboard-focus-ring();
+ .add-keyboard-focus-ring-offset(4px);
+
+ .icon {
+ margin-right: 0;
}
}
}
+
+ // Message displayed when notifications are empty
+ &-empty {
+ color: @muted-color;
+ text-align: center;
+ padding: 50px 0;
+ font-size: 16px;
+ }
}
-.NotificationList-empty {
- color: @muted-color;
- text-align: center;
- padding: 50px 0;
- font-size: 16px;
-}
+
.NotificationGroup {
border-top: 1px solid @control-bg;
margin-top: -1px;
@@ -50,99 +62,143 @@
&:not(:last-child) {
margin-bottom: 20px;
}
-}
-.NotificationGroup-header {
- font-weight: bold;
- color: @heading-color !important;
- padding: 6px 15px;
- display: block;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
-}
-.NotificationGroup-badges {
- margin-left: -2px;
- margin-right: 18px;
- vertical-align: 1px;
- .Badge {
- margin-right: -13px;
- position: relative;
- .Badge--size(21px);
+ &-header {
+ font-weight: bold;
+ color: @heading-color !important;
+ padding: 8px 16px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+
+ display: flex;
+ align-items: center;
+
+ // Prevent outline overflowing parent
+ .add-keyboard-focus-ring-offset(-1px);
+ }
+
+ &-badges {
+ @overlap: 13px;
+
+ margin-right: 8px;
+ padding-right: @overlap;
+
+ .Badge {
+ margin-right: -@overlap;
+ position: relative;
+ .Badge--size(21px);
+ }
+ }
+
+ &-content {
+ list-style: none;
+ margin: 0;
+ padding: 0;
}
}
-.NotificationGroup-content {
- list-style: none;
- margin: 0;
- padding: 0;
-}
+
.Notification {
- display: block;
- padding: 8px 15px 8px 70px;
+ padding: 8px 16px;
color: @muted-color !important; // required to override .light-contents applied to header
overflow: hidden;
- .unread& {
+ display: grid;
+ grid-template-columns: auto auto 1fr auto;
+
+ grid-template-areas:
+ "avatar icon title button"
+ "x x excerpt excerpt";
+
+ align-items: baseline;
+ row-gap: 1px;
+ column-gap: 6px;
+
+ // Prevent outline overflowing parent
+ .add-keyboard-focus-ring-offset(-1px);
+
+ &.unread {
background: @control-bg;
}
- &:hover {
+
+ &:hover,
+ &:focus,
+ &:focus-within {
text-decoration: none;
background: @control-bg;
-
+
.Notification-action {
- display: block;
+ opacity: 1;
}
}
+
.Avatar {
.Avatar--size(24px);
- float: left;
- margin: -2px 0 -2px -55px;
+ grid-area: avatar;
}
+
+ &-icon {
+ font-size: 14px;
+ grid-area: icon;
+ }
+
+ &-title {
+ grid-area: title;
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ align-items: baseline;
+ }
+
+ &-content {
+ line-height: 19px;
+ margin-right: 8px;
+
+ .username {
+ font-weight: bold;
+ }
+ }
+
time {
+ line-height: inherit;
font-size: 11px;
+ line-height: 19px;
font-weight: bold;
text-transform: uppercase;
}
- .Notification-action {
- float: right;
- display: none;
- margin-top: -7px;
- margin-right: -10px;
+ &-action {
line-height: inherit;
- padding: 5px 0;
+ padding: 0;
+ opacity: 0;
- & when (@config-colored-header = true) {
- .Button--color(@control-color, @control-bg);
+ .add-keyboard-focus-ring();
+ .add-keyboard-focus-ring-offset(4px);
- &:hover {
+ grid-area: button;
+
+ // Needs more specificity to fix hover/focus styles not applying in dropdown
+ .Notification & when (@config-colored-header = true) {
+ color: @control-color;
+
+ &:hover,
+ &:focus {
color: @link-color;
}
}
.icon {
- font-size: 12px;
+ font-size: 13px;
+ margin-right: 0;
}
}
-}
-.Notification-icon {
- float: left;
- margin-left: -23px;
- font-size: 14px;
- margin-top: 2px;
-}
-.Notification-content {
- margin-right: 5px;
- .username {
- font-weight: bold;
+ &-excerpt {
+ grid-area: excerpt;
+ color: @muted-more-color;
+ font-size: 11px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
}
}
-.Notification-excerpt {
- color: @muted-more-color;
- font-size: 11px;
- margin-top: 3px;
- white-space: nowrap;
- text-overflow: ellipsis;
- overflow: hidden;
-}