From a9ba54a92e20c18924214e076692693b083a2af5 Mon Sep 17 00:00:00 2001 From: EYHN Date: Thu, 3 Apr 2025 10:59:37 +0000 Subject: [PATCH] feat(core): adjust notification style (#11455) --- .../components/notification/list.style.css.ts | 2 +- .../sidebar-header/sidebar-switch.css.ts | 31 +++++++++++++++++++ .../views/sidebar-header/sidebar-switch.tsx | 15 ++++++++- 3 files changed, 46 insertions(+), 2 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 01b6f600b7..b934cddf19 100644 --- a/packages/frontend/core/src/components/notification/list.style.css.ts +++ b/packages/frontend/core/src/components/notification/list.style.css.ts @@ -3,7 +3,7 @@ import { cssVarV2 } from '@toeverything/theme/v2'; import { keyframes, style } from '@vanilla-extract/css'; export const containerScrollViewport = style({ - maxHeight: '272px', + maxHeight: '448px', width: '360px', }); diff --git a/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.css.ts b/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.css.ts index 4b78a0e657..832d034e4a 100644 --- a/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.css.ts +++ b/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.css.ts @@ -1,6 +1,8 @@ +import { cssVarV2 } from '@toeverything/theme/v2'; import { style } from '@vanilla-extract/css'; export const sidebarSwitchClip = style({ + position: 'relative', flexShrink: 0, overflow: 'hidden', transition: @@ -14,5 +16,34 @@ export const sidebarSwitchClip = style({ opacity: 0, maxWidth: 0, }, + '&[data-notification=true]:after': { + transform: 'scale(1)', + }, + }, + ':after': { + content: '""', + position: 'absolute', + left: '19.75px', + top: '6.25px', + zIndex: 2, + width: '6px', + height: '6px', + borderRadius: '50%', + transform: 'scale(0)', + transition: 'transform 0.3s ease', + backgroundColor: cssVarV2('button/primary'), + }, +}); + +export const switchIcon = style({ + transition: 'clip-path 0.3s ease', + clipPath: + 'path(evenodd, "M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 M19 4.25C19 4.38807 19.1119 4.5 19.25 4.5C19.3881 4.5 19.5 4.38807 19.5 4.25C19.5 4.11193 19.3881 4 19.25 4C19.1119 4 19 4.11193 19 4.25Z")', + + selectors: { + '&[data-notification=true]': { + clipPath: + 'path(evenodd, "M 0 0 L 24 0 L 24 24 L 0 24 L 0 0 M23 5.25C23 7.59721 21.0972 9.5 18.75 9.5C16.4028 9.5 14.5 7.59721 14.5 5.25C14.5 2.90279 16.4028 1 18.75 1C21.0972 1 23 2.90279 23 5.25Z")', + }, }, }); diff --git a/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx b/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx index 353e63c7ba..fba6c7e3c7 100644 --- a/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx +++ b/packages/frontend/core/src/modules/app-sidebar/views/sidebar-header/sidebar-switch.tsx @@ -1,7 +1,9 @@ import { IconButton } from '@affine/component'; +import { NotificationCountService } from '@affine/core/modules/notification'; import { track } from '@affine/track'; import { SidebarIcon } from '@blocksuite/icons/rc'; import { useLiveData, useService } from '@toeverything/infra'; +import clsx from 'clsx'; import { useCallback, useRef } from 'react'; import { AppSidebarService } from '../../services/app-sidebar'; @@ -14,6 +16,11 @@ export const SidebarSwitch = ({ show: boolean; className?: string; }) => { + const notificationCountService = useService(NotificationCountService); + const hasNotification = useLiveData( + notificationCountService.count$.selector(count => count > 0) + ); + const appSidebarService = useService(AppSidebarService).sidebar; const open = useLiveData(appSidebarService.open$); const preventHovering = useLiveData(appSidebarService.preventHovering$); @@ -44,6 +51,8 @@ export const SidebarSwitch = ({ appSidebarService.toggleSidebar(); }, [appSidebarService, open]); + const showNotificationDot = hasNotification && !open; + return (
- +
);