Skip to content

Commit f4e502d

Browse files
authored
fix(notifications): more visible (#790)
1 parent 1251a11 commit f4e502d

File tree

6 files changed

+61
-5
lines changed

6 files changed

+61
-5
lines changed

.changeset/twelve-phones-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Make toasts and notifications more visible with a colorful border.

src/components/overlays/NewNotifications/Bar/FloatingNotification.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type FloatingNotificationProps = {
2222
const NotificationContainer = tasty({
2323
styles: {
2424
overflow: 'hidden',
25-
radius: true,
25+
radius: '1cr',
2626
boxShadow: '0 0.5x 2x #shadow',
2727
pointerEvents: 'auto',
2828
},
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { createContext, ReactNode, useContext } from 'react';
2+
3+
export interface NotificationsDialogContextValue {
4+
insideNotificationsDialog: boolean;
5+
}
6+
7+
export const NotificationsDialogContext =
8+
createContext<NotificationsDialogContextValue | null>(null);
9+
10+
export function NotificationsDialogProvider({
11+
children,
12+
}: {
13+
children: ReactNode;
14+
}) {
15+
return (
16+
<NotificationsDialogContext.Provider
17+
value={{ insideNotificationsDialog: true }}
18+
>
19+
{children}
20+
</NotificationsDialogContext.Provider>
21+
);
22+
}
23+
24+
export function useNotificationsDialogContext() {
25+
const context = useContext(NotificationsDialogContext);
26+
return context?.insideNotificationsDialog ?? false;
27+
}

src/components/overlays/NewNotifications/Dialog/NotificationsDialogTrigger.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
import { useNotificationsObserver } from '../hooks';
1515
import { CubeNotifyApiPropsWithID } from '../types';
1616

17+
import { NotificationsDialogProvider } from './NotificationsDialogContext';
18+
1719
export type NotificationsDialogTriggerProps = Omit<
1820
CubeDialogTriggerProps,
1921
'type'
@@ -56,7 +58,9 @@ export function NotificationsDialog(props: NotificationsDialogProps) {
5658
</VisuallyHidden>
5759

5860
<StyledDialogContent>
59-
<ClearSlots>{children}</ClearSlots>
61+
<NotificationsDialogProvider>
62+
<ClearSlots>{children}</ClearSlots>
63+
</NotificationsDialogProvider>
6064
</StyledDialogContent>
6165
</StyledDialog>
6266
);

src/components/overlays/NewNotifications/NotificationView/NotificationFooter.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ const FooterArea = tasty(ButtonGroup, {
1717
gridArea: 'footer',
1818
gap: '1x 2x',
1919
flow: 'row wrap',
20-
'&:not(:empty)': {
21-
margin: { '': '0.5x top', 'has-description': '1x top' },
20+
margin: {
21+
'': '0.5x top',
22+
'has-description': '1x top',
23+
':empty': '0',
2224
},
2325
},
2426
});

src/components/overlays/NewNotifications/NotificationView/NotificationView.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEvent, useTimer } from '../../../../_internal';
55
import { tasty } from '../../../../tasty';
66
import { ClearSlots, mergeProps } from '../../../../utils/react';
77
import { useId } from '../../../../utils/react/useId';
8+
import { useNotificationsDialogContext } from '../Dialog/NotificationsDialogContext';
89

910
import { NotificationCloseButton } from './NotificationCloseButton';
1011
import { NotificationDescription } from './NotificationDescription';
@@ -36,6 +37,15 @@ const NotificationContainer = tasty({
3637
'': '0 0 0 4bw #purple-04.0 inset',
3738
focused: '0 0 0 4bw #purple-04 inset',
3839
},
40+
outline: 0,
41+
border: {
42+
'': '#border',
43+
'[data-type="success"]': '#success.4',
44+
'[data-type="danger"]': '#danger.4',
45+
'[data-type="attention"]': '#border',
46+
// Clear border when inside dialog
47+
'inside-dialog': false,
48+
},
3949
},
4050
});
4151

@@ -66,6 +76,9 @@ export const NotificationView = forwardRef(function NotificationView(
6676
const labelID = useId();
6777
const descriptionID = useId();
6878

79+
// Detect if we're inside a NotificationsDialog specifically
80+
const insideNotificationsDialog = useNotificationsDialogContext();
81+
6982
const onCloseEvent = useEvent(() => {
7083
onClose?.();
7184
});
@@ -95,9 +108,14 @@ export const NotificationView = forwardRef(function NotificationView(
95108
styles={styles}
96109
data-id={id}
97110
data-qa={qa}
111+
data-type={type}
98112
aria-labelledby={labelID}
99113
aria-describedby={descriptionID}
100-
mods={{ focused: isFocusVisible, 'is-dismissible': isDismissible }}
114+
mods={{
115+
focused: isFocusVisible,
116+
'is-dismissible': isDismissible,
117+
'inside-dialog': insideNotificationsDialog,
118+
}}
101119
>
102120
<NotificationIcon icon={icon} type={type} />
103121

0 commit comments

Comments
 (0)