From 613597e642b7b526f28d018584c0eb8503b8ea38 Mon Sep 17 00:00:00 2001 From: L-Sun Date: Tue, 15 Jul 2025 15:45:37 +0800 Subject: [PATCH] feat(core): notification entry for mobile (#13214) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### PR Dependency Tree * **PR #13214** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **New Features** * Added a notification icon with a live badge displaying the notification count in the mobile home header. The badge dynamically adjusts and caps the count at "99+". * Introduced a notification menu in the mobile header, allowing users to view their notifications directly. * **Style** * Improved notification list responsiveness on mobile by making it full width. * Enhanced the appearance of the notification badge for better visibility. * Updated the app fallback UI to display skeleton placeholders for both notification and settings icons. --- .../components/notification/list.style.css.ts | 6 +++++ .../core/src/components/notification/list.tsx | 5 +++- .../mobile/components/app-fallback/index.tsx | 18 +++++++++++--- .../src/mobile/views/home-header/index.tsx | 24 +++++++++++++++++-- .../mobile/views/home-header/styles.css.ts | 14 +++++++++++ 5 files changed, 61 insertions(+), 6 deletions(-) diff --git a/packages/frontend/core/src/components/notification/list.style.css.ts b/packages/frontend/core/src/components/notification/list.style.css.ts index e46b70dee3..80e179d262 100644 --- a/packages/frontend/core/src/components/notification/list.style.css.ts +++ b/packages/frontend/core/src/components/notification/list.style.css.ts @@ -7,6 +7,12 @@ export const container = style({ width: '360px', display: 'flex', flexDirection: 'column', + + selectors: { + '&[data-mobile]': { + width: '100%', + }, + }, }); export const header = style({ diff --git a/packages/frontend/core/src/components/notification/list.tsx b/packages/frontend/core/src/components/notification/list.tsx index 566b51dfd5..58690ba3c3 100644 --- a/packages/frontend/core/src/components/notification/list.tsx +++ b/packages/frontend/core/src/components/notification/list.tsx @@ -90,7 +90,10 @@ export const NotificationList = () => { }, [notificationListService]); return ( -
+
{t['com.affine.rootAppSidebar.notifications']()} {notifications.length > 0 && ( diff --git a/packages/frontend/core/src/mobile/components/app-fallback/index.tsx b/packages/frontend/core/src/mobile/components/app-fallback/index.tsx index 273115aac3..66690b23d1 100644 --- a/packages/frontend/core/src/mobile/components/app-fallback/index.tsx +++ b/packages/frontend/core/src/mobile/components/app-fallback/index.tsx @@ -52,11 +52,23 @@ const Section = () => { export const AppFallback = () => { return ( - {/* setting */} -
+ {/* notification and setting */} +
+
{/* workspace card */} diff --git a/packages/frontend/core/src/mobile/views/home-header/index.tsx b/packages/frontend/core/src/mobile/views/home-header/index.tsx index 20a3065ed7..6a79a9e03e 100644 --- a/packages/frontend/core/src/mobile/views/home-header/index.tsx +++ b/packages/frontend/core/src/mobile/views/home-header/index.tsx @@ -1,13 +1,16 @@ import { IconButton, + Menu, SafeArea, startScopedViewTransition, } from '@affine/component'; +import { NotificationList } from '@affine/core/components/notification/list'; import { WorkspaceDialogService } from '@affine/core/modules/dialogs'; +import { NotificationCountService } from '@affine/core/modules/notification'; import { WorkbenchService } from '@affine/core/modules/workbench'; import { useI18n } from '@affine/i18n'; -import { SettingsIcon } from '@blocksuite/icons/rc'; -import { useService } from '@toeverything/infra'; +import { NotificationIcon, SettingsIcon } from '@blocksuite/icons/rc'; +import { useLiveData, useService } from '@toeverything/infra'; import clsx from 'clsx'; import { useCallback, useRef, useState } from 'react'; @@ -29,6 +32,8 @@ export const HomeHeader = () => { const floatWorkspaceCardRef = useRef(null); const t = useI18n(); const workbench = useService(WorkbenchService).workbench; + const notificationCountService = useService(NotificationCountService); + const notificationCount = useLiveData(notificationCountService.count$); const navSearch = useCallback(() => { startScopedViewTransition(searchVTScope, () => { @@ -70,6 +75,21 @@ export const HomeHeader = () => { className={styles.floatWsSelector} ref={floatWorkspaceCardRef} /> + }> +
+ + {notificationCount > 0 && ( +
99 ? '8px' : '12px', + }} + > + {notificationCount > 99 ? '99+' : notificationCount} +
+ )} +
+