ant-design/components/notification/style/placement.ts
MadCcc c5bed69883
feat: notification support stack (#44618)
* feat: notification stack

* feat: notification support stack

* docs: add demo

* fix: message animation

* chore: better imports

* test: fix pure panel

* feat: code optimize

* chore: update snapshot

* chore: update test case

* test: update test

* chore: update deps

* chore: bump rc-notification

* feat: add backdrop filter

* chore

* feat: add token colorBgBlur

* chore: bump

* feat: update colorBgBlur in dark mode

* fix: compatible with safari

---------

Signed-off-by: MadCcc <1075746765@qq.com>
2023-09-13 15:19:18 +08:00

107 lines
2.7 KiB
TypeScript

import type { CSSObject } from '@ant-design/cssinjs';
import { Keyframes } from '@ant-design/cssinjs';
import type { NotificationToken } from '.';
import type { GenerateStyle } from '../../theme/internal';
const genNotificationPlacementStyle: GenerateStyle<NotificationToken, CSSObject> = (token) => {
const { componentCls, notificationMarginEdge } = token;
const noticeCls = `${componentCls}-notice`;
const rightFadeIn = new Keyframes('antNotificationFadeIn', {
'0%': {
transform: `translate3d(100%, 0, 0)`,
opacity: 0,
},
'100%': {
transform: `translate3d(0, 0, 0)`,
opacity: 1,
},
});
const topFadeIn = new Keyframes('antNotificationTopFadeIn', {
'0%': {
top: -token.animationMaxHeight,
opacity: 0,
},
'100%': {
top: 0,
opacity: 1,
},
});
const bottomFadeIn = new Keyframes('antNotificationBottomFadeIn', {
'0%': {
bottom: -token.animationMaxHeight,
opacity: 0,
},
'100%': {
bottom: 0,
opacity: 1,
},
});
const leftFadeIn = new Keyframes('antNotificationLeftFadeIn', {
'0%': {
transform: `translate3d(-100%, 0, 0)`,
opacity: 0,
},
'100%': {
transform: `translate3d(0, 0, 0)`,
opacity: 1,
},
});
return {
[componentCls]: {
[`&${componentCls}-top, &${componentCls}-bottom`]: {
marginInline: 0,
[noticeCls]: {
marginInline: 'auto auto',
},
},
[`&${componentCls}-top`]: {
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
{
animationName: topFadeIn,
},
},
[`&${componentCls}-bottom`]: {
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
{
animationName: bottomFadeIn,
},
},
[`&${componentCls}-topRight, &${componentCls}-bottomRight`]: {
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
{
animationName: rightFadeIn,
},
},
[`&${componentCls}-topLeft, &${componentCls}-bottomLeft`]: {
marginInlineEnd: 0,
marginInlineStart: notificationMarginEdge,
[noticeCls]: {
marginInlineEnd: 'auto',
marginInlineStart: 0,
},
[`${componentCls}-fade-enter${componentCls}-fade-enter-active, ${componentCls}-fade-appear${componentCls}-fade-appear-active`]:
{
animationName: leftFadeIn,
},
},
},
};
};
export default genNotificationPlacementStyle;