fix(component): optimize stack notification with different height (#8700)

This commit is contained in:
@@ -4,6 +4,14 @@ import { type CSSProperties, useMemo } from 'react';
|
|||||||
import { Toaster } from 'sonner';
|
import { Toaster } from 'sonner';
|
||||||
|
|
||||||
import type { NotificationCenterProps } from '../types';
|
import type { NotificationCenterProps } from '../types';
|
||||||
|
import { cardWrapper } from './styles.css';
|
||||||
|
|
||||||
|
const toastOptions = {
|
||||||
|
style: {
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
className: cardWrapper,
|
||||||
|
};
|
||||||
|
|
||||||
export function DesktopNotificationCenter({
|
export function DesktopNotificationCenter({
|
||||||
width = 380,
|
width = 380,
|
||||||
@@ -21,15 +29,6 @@ export function DesktopNotificationCenter({
|
|||||||
} satisfies CSSProperties;
|
} satisfies CSSProperties;
|
||||||
}, [width]);
|
}, [width]);
|
||||||
|
|
||||||
const toastOptions = useMemo(
|
|
||||||
() => ({
|
|
||||||
style: {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Toaster
|
<Toaster
|
||||||
className="affine-notification-center"
|
className="affine-notification-center"
|
||||||
|
|||||||
@@ -8,11 +8,16 @@ export const actionTextColor = createVar();
|
|||||||
export const iconColor = createVar();
|
export const iconColor = createVar();
|
||||||
export const closeIconColor = createVar();
|
export const closeIconColor = createVar();
|
||||||
|
|
||||||
export const card = style({
|
export const cardWrapper = style({
|
||||||
borderRadius: 8,
|
borderRadius: 8,
|
||||||
|
boxShadow: cssVar('shadow1'),
|
||||||
|
overflow: 'hidden',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const card = style({
|
||||||
|
borderRadius: 'inherit',
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
borderStyle: 'solid',
|
borderStyle: 'solid',
|
||||||
boxShadow: cssVar('shadow1'),
|
|
||||||
backgroundColor: cardColor,
|
backgroundColor: cardColor,
|
||||||
borderColor: cardBorderColor,
|
borderColor: cardBorderColor,
|
||||||
color: cardForeground,
|
color: cardForeground,
|
||||||
|
|||||||
@@ -241,3 +241,80 @@ export const ZIndexWithModal: StoryFn = () => {
|
|||||||
</Root>
|
</Root>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DifferentSize: StoryFn = () => {
|
||||||
|
const openTiny = () => {
|
||||||
|
notify({ title: 'Tiny' }, { duration: 60000 });
|
||||||
|
};
|
||||||
|
const openNormal = () =>
|
||||||
|
notify(
|
||||||
|
{
|
||||||
|
title: 'Normal Size',
|
||||||
|
message: 'With basic title and one line message',
|
||||||
|
},
|
||||||
|
{ duration: 60000 }
|
||||||
|
);
|
||||||
|
|
||||||
|
const openLarge = () => {
|
||||||
|
notify(
|
||||||
|
{
|
||||||
|
title: 'Large Size',
|
||||||
|
message: (
|
||||||
|
<div>
|
||||||
|
<h1>Large Size</h1>
|
||||||
|
<p>
|
||||||
|
With long title and long message to test the size of the
|
||||||
|
notification; The content may be multiline and the card will be
|
||||||
|
larger.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{ duration: 60000 }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const openWithThumb = () => {
|
||||||
|
notify(
|
||||||
|
{
|
||||||
|
thumb: (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: 100,
|
||||||
|
background: 'rgba(100,100,100,.05)',
|
||||||
|
lineHeight: '100px',
|
||||||
|
textAlign: 'center',
|
||||||
|
borderTopLeftRadius: 'inherit',
|
||||||
|
borderTopRightRadius: 'inherit',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Hack thumb
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
title: 'Card with thumb',
|
||||||
|
message: 'With basic title and one line message',
|
||||||
|
},
|
||||||
|
{ duration: 60000 }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const openWithFooter = () => {
|
||||||
|
notify(
|
||||||
|
{
|
||||||
|
title: 'With footer',
|
||||||
|
message: 'With basic title and one line message',
|
||||||
|
footer: (
|
||||||
|
<Button onClick={() => console.log('clicked')}>Click me</Button>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{ duration: 60000 }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Root style={{ display: 'flex', gap: 8 }}>
|
||||||
|
<Button onClick={openTiny}>Open Tiny</Button>
|
||||||
|
<Button onClick={openNormal}>Open Normal</Button>
|
||||||
|
<Button onClick={openLarge}>Open Large</Button>
|
||||||
|
<Button onClick={openWithThumb}>Open with thumb</Button>
|
||||||
|
<Button onClick={openWithFooter}>Open with footer</Button>
|
||||||
|
</Root>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user