Refactor NotificationBadge to shared MVVM (#33843)
* Refactor NotificationBadge to shared MVVM * Added snapshot images * Replace legacy NotificationBadge with adapter * Fix Eslint * Use regular NotificationBadge prop names * Remove legacy NotificationBadge selectors * Update TAC badge Playwright selectors * Rename NotificationBadgeAdapter to NotificationBadge Addresses review feedback: the component is the app-facing badge, not an adapter, so name it NotificationBadge. * Make NotificationBadgeView isClickable a required boolean Addresses review feedback: there is no semantic difference between `isClickable: false` and `isClickable: undefined` (both render the non-interactive variant), so the field should be a plain boolean. The view model always provides it. * Drop redundant comparison guards in NotificationBadge view model setters Addresses review feedback: Snapshot.merge already compares each field with Object.is and only emits when something actually changed, so the manual equality guards in each setter were redundant. Recompute the snapshot unconditionally and let merge dedupe. * Resolve notification badge labels inside NotificationBadgeView Addresses review feedback: static UI labels belong in the view, not the snapshot. The view now resolves the knock and unsent-message strings via useI18n, and the snapshot exposes a showUnsentTooltip boolean instead of a prebuilt tooltipLabel (and drops knockLabel entirely). Adds the room|knock_sent and notifications|message_didnt_send keys to the shared-components i18n catalogue so they resolve in tests and storybook. * Remove unused translation because of shared components movement * Fix typescript issue * Fix lint issue * Remove unused notification badge count setting * Pass notification badge class names explicitly
This commit is contained in:
@@ -66,7 +66,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
background-color: $presence-busy;
|
||||
}
|
||||
|
||||
.mx_NotificationBadge,
|
||||
.mx_DecoratedRoomAvatar_notificationBadge,
|
||||
.mx_RoomTile_badgeContainer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
||||
@@ -141,7 +141,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
color: $accent;
|
||||
}
|
||||
|
||||
.mx_NotificationBadge {
|
||||
.mx_ForwardDialog_notificationBadge {
|
||||
/* Match the failed to send indicator's color with the disabled button */
|
||||
background-color: $button-danger-disabled-fg-color;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
}
|
||||
}
|
||||
|
||||
.mx_NotificationBadge {
|
||||
.mx_SpotlightDialog_notificationBadge {
|
||||
margin-left: var(--cpd-space-2x);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
Copyright 2024 New Vector Ltd.
|
||||
Copyright 2020 The Matrix.org Foundation C.I.C.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
.mx_NotificationBadge {
|
||||
&:not(.mx_NotificationBadge_visible) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Badges are structured a bit weirdly to work around issues with non-monospace */
|
||||
/* font styles. The badge pill is actually a background div and the count floats */
|
||||
/* within that. For example: */
|
||||
/* ( 99+ ) <-- Rounded pill is a _bg class. */
|
||||
/* ^- The count is an element floating within that. */
|
||||
|
||||
&.mx_NotificationBadge_visible {
|
||||
background-color: var(--cpd-color-icon-secondary);
|
||||
/* For enhanced visibility under contrast control */
|
||||
outline: 1px solid transparent;
|
||||
|
||||
/* Create a flexbox to order the count a bit easier */
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
/* These are the 3 background types */
|
||||
|
||||
&.mx_NotificationBadge_dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 8px;
|
||||
background-color: var(--cpd-color-icon-primary);
|
||||
|
||||
.mx_NotificationBadge_count {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Redundant sounding name, but a notification badge that indicates there is a regular,
|
||||
* non-highlight notification
|
||||
* The green colour only applies for notification dot: badges indicating the same notification
|
||||
* level are the standard grey.
|
||||
*/
|
||||
&.mx_NotificationBadge_level_notification {
|
||||
background-color: var(--cpd-color-icon-success-primary);
|
||||
}
|
||||
}
|
||||
|
||||
/* Badges for highlight notifications. Style for notification level
|
||||
* badges is in _EventTile.scss because it applies only to notification
|
||||
* dots, not badges.
|
||||
*/
|
||||
&.mx_NotificationBadge_level_highlight {
|
||||
background-color: var(--cpd-color-icon-critical-primary);
|
||||
}
|
||||
|
||||
& > svg {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
&.mx_NotificationBadge_2char {
|
||||
width: $font-16px;
|
||||
height: $font-16px;
|
||||
border-radius: $font-16px;
|
||||
}
|
||||
|
||||
&.mx_NotificationBadge_3char {
|
||||
width: $font-26px;
|
||||
height: $font-16px;
|
||||
border-radius: $font-16px;
|
||||
}
|
||||
|
||||
/* The following is the floating badge */
|
||||
|
||||
.mx_NotificationBadge_count {
|
||||
font-size: $font-10px;
|
||||
line-height: $font-14px;
|
||||
font-weight: var(--cpd-font-weight-semibold);
|
||||
color: var(--cpd-color-text-on-solid-primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
margin-bottom: 20px;
|
||||
|
||||
.mx_SettingsSubsection_text {
|
||||
.mx_NotificationBadge {
|
||||
.mx_NotificationSettings2_notificationBadge {
|
||||
vertical-align: baseline;
|
||||
display: inline-flex;
|
||||
margin: 0 2px;
|
||||
|
||||
Reference in New Issue
Block a user