feat: migrate less to token for Notification (#42079)

* feat: migrate less to token for Notification

* feat: migrate less to token for Notification

* docs: update docs

* docs: update docs

* docs: update docs

* docs: update docs

* docs: update docs
This commit is contained in:
kiner-tang(文辉) 2023-05-04 15:33:16 +08:00 committed by GitHub
parent 4cf6f1b83b
commit 629087833f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 49 additions and 27 deletions

View File

@ -9,18 +9,18 @@ import genNotificationPlacementStyle from './placement';
export interface ComponentToken { export interface ComponentToken {
zIndexPopup: number; zIndexPopup: number;
width: number; width: number;
notificationBg: string;
notificationPadding: string;
notificationPaddingVertical: number;
notificationPaddingHorizontal: number;
notificationIconSize: number;
notificationCloseButtonSize: number;
notificationMarginBottom: number;
notificationMarginEdge: number;
} }
export interface NotificationToken extends FullToken<'Notification'> { export interface NotificationToken extends FullToken<'Notification'> {
notificationBg: string;
notificationPaddingVertical: number;
notificationPaddingHorizontal: number;
notificationPadding: string;
notificationMarginBottom: number;
notificationMarginEdge: number;
animationMaxHeight: number; animationMaxHeight: number;
notificationIconSize: number;
notificationCloseButtonSize: number;
} }
const genNotificationStyle: GenerateStyle<NotificationToken> = (token) => { const genNotificationStyle: GenerateStyle<NotificationToken> = (token) => {
@ -269,27 +269,27 @@ const genNotificationStyle: GenerateStyle<NotificationToken> = (token) => {
export default genComponentStyleHook( export default genComponentStyleHook(
'Notification', 'Notification',
(token) => { (token) => {
const notificationPaddingVertical = token.paddingMD;
const notificationPaddingHorizontal = token.paddingLG;
const notificationToken = mergeToken<NotificationToken>(token, { const notificationToken = mergeToken<NotificationToken>(token, {
// default.less variables
notificationBg: token.colorBgElevated,
notificationPaddingVertical,
notificationPaddingHorizontal,
// index.less variables // index.less variables
notificationPadding: `${token.paddingMD}px ${token.paddingContentHorizontalLG}px`,
notificationMarginBottom: token.margin,
notificationMarginEdge: token.marginLG,
animationMaxHeight: 150, animationMaxHeight: 150,
notificationIconSize: token.fontSizeLG * token.lineHeightLG,
notificationCloseButtonSize: token.controlHeightLG * 0.55,
}); });
return [genNotificationStyle(notificationToken)]; return [genNotificationStyle(notificationToken)];
}, },
(token) => ({ (token) => {
zIndexPopup: token.zIndexPopupBase + 50, const notificationPaddingVertical = token.paddingMD;
width: 384, const notificationPaddingHorizontal = token.paddingLG;
}), return {
zIndexPopup: token.zIndexPopupBase + 50,
width: 384,
notificationBg: token.colorBgElevated,
notificationPaddingVertical,
notificationPaddingHorizontal,
notificationIconSize: token.fontSizeLG * token.lineHeightLG,
notificationCloseButtonSize: token.controlHeightLG * 0.55,
notificationMarginBottom: token.margin,
notificationPadding: `${token.paddingMD}px ${token.paddingContentHorizontalLG}px`,
notificationMarginEdge: token.marginLG,
};
},
); );

View File

@ -91,7 +91,18 @@ This document contains the correspondence between all the less variables related
| `@modal-confirm-title-font-size` | `modalHeaderTitleFontSize` | - | | `@modal-confirm-title-font-size` | `modalHeaderTitleFontSize` | - |
| `@modal-border-radius` | `borderRadiusLG` | - | | `@modal-border-radius` | `borderRadiusLG` | - |
<!-- ### Notification --> ## Notification
<!-- prettier-ignore -->
| Less variables | Component Token | Note |
| --- | --- | --- |
| `@notification-width` | `width` | - |
| `@notification-padding` | `notificationPadding` | - |
| `@notification-padding-vertical` | `notificationPaddingVertical` | - |
| `@notification-padding-horizontal` | `notificationPaddingHorizontal` | - |
| `@notification-margin-bottom` | `notificationMarginBottom` | - |
| `@notification-margin-edge` | `notificationMarginEdge` | - |
| `@notification-bg` | `notificationBg` | - |
<!-- ### Pagination --> <!-- ### Pagination -->
@ -118,7 +129,7 @@ This document contains the correspondence between all the less variables related
## Step ## Step
<!-- prettier-ignore --> <!-- prettier-ignore -->
| less 变量 | Component Token | 备注 | | Less variables | Component Token | Note |
| --- | --- | --- | | --- | --- | --- |
| `@process-tail-color` | `processTailColor` | - | | `@process-tail-color` | `processTailColor` | - |
| `@steps-nav-arrow-color` | `stepsNavArrowColor` | - | | `@steps-nav-arrow-color` | `stepsNavArrowColor` | - |

View File

@ -91,7 +91,18 @@ title: Less 变量迁移 Design Token
| `@modal-confirm-title-font-size` | `modalHeaderTitleFontSize` | - | | `@modal-confirm-title-font-size` | `modalHeaderTitleFontSize` | - |
| `@modal-border-radius` | `borderRadiusLG` | - | | `@modal-border-radius` | `borderRadiusLG` | - |
<!-- ### Notification 通知提醒框 --> ## Notification 通知提醒框
<!-- prettier-ignore -->
| Less 变量 | Component Token | 备注 |
| --- | --- | --- |
| `@notification-width` | `width` | - |
| `@notification-padding` | `notificationPadding` | - |
| `@notification-padding-vertical` | `notificationPaddingVertical` | - |
| `@notification-padding-horizontal` | `notificationPaddingHorizontal` | - |
| `@notification-margin-bottom` | `notificationMarginBottom` | - |
| `@notification-margin-edge` | `notificationMarginEdge` | - |
| `@notification-bg` | `notificationBg` | - |
<!-- ### Pagination 分页 --> <!-- ### Pagination 分页 -->