mirror of
https://github.com/ant-design/ant-design.git
synced 2025-07-31 03:46:28 +08:00
refactor: alert full token (#35702)
* refactor: alert full token * chore: bump bundle size * fix: miss token
This commit is contained in:
parent
9f2b08c700
commit
8d558202cb
@ -1,4 +1,5 @@
|
|||||||
import type * as React from 'react';
|
import type * as React from 'react';
|
||||||
|
import type { ComponentToken as AlertComponentToken } from '../../alert/style';
|
||||||
import type { ComponentToken as AnchorComponentToken } from '../../anchor/style';
|
import type { ComponentToken as AnchorComponentToken } from '../../anchor/style';
|
||||||
import type { ComponentToken as BackTopComponentToken } from '../../back-top/style';
|
import type { ComponentToken as BackTopComponentToken } from '../../back-top/style';
|
||||||
import type { ComponentToken as ButtonComponentToken } from '../../button/style';
|
import type { ComponentToken as ButtonComponentToken } from '../../button/style';
|
||||||
@ -15,8 +16,8 @@ import type { ComponentToken as LayoutComponentToken } from '../../layout/style'
|
|||||||
import type { ComponentToken as ListComponentToken } from '../../list/style';
|
import type { ComponentToken as ListComponentToken } from '../../list/style';
|
||||||
import type { ComponentToken as MentionsComponentToken } from '../../mentions/style';
|
import type { ComponentToken as MentionsComponentToken } from '../../mentions/style';
|
||||||
import type { ComponentToken as MenuComponentToken } from '../../menu/style';
|
import type { ComponentToken as MenuComponentToken } from '../../menu/style';
|
||||||
import type { ComponentToken as ModalComponentToken } from '../../modal/style';
|
|
||||||
import type { ComponentToken as MessageComponentToken } from '../../message/style';
|
import type { ComponentToken as MessageComponentToken } from '../../message/style';
|
||||||
|
import type { ComponentToken as ModalComponentToken } from '../../modal/style';
|
||||||
import type { ComponentToken as NotificationComponentToken } from '../../notification/style';
|
import type { ComponentToken as NotificationComponentToken } from '../../notification/style';
|
||||||
import type { ComponentToken as PopconfirmComponentToken } from '../../popconfirm/style';
|
import type { ComponentToken as PopconfirmComponentToken } from '../../popconfirm/style';
|
||||||
import type { ComponentToken as ProgressComponentToken } from '../../progress/style';
|
import type { ComponentToken as ProgressComponentToken } from '../../progress/style';
|
||||||
@ -28,8 +29,6 @@ import type { ComponentToken as TimelineComponentToken } from '../../timeline/st
|
|||||||
import type { ComponentToken as TypographyComponentToken } from '../../typography/style';
|
import type { ComponentToken as TypographyComponentToken } from '../../typography/style';
|
||||||
import type { ComponentToken as UploadComponentToken } from '../../upload/style';
|
import type { ComponentToken as UploadComponentToken } from '../../upload/style';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const PresetColors = [
|
export const PresetColors = [
|
||||||
'blue',
|
'blue',
|
||||||
'purple',
|
'purple',
|
||||||
@ -61,7 +60,7 @@ export interface OverrideToken {
|
|||||||
|
|
||||||
// Customize component
|
// Customize component
|
||||||
Affix?: {};
|
Affix?: {};
|
||||||
Alert?: {};
|
Alert?: AlertComponentToken;
|
||||||
Anchor?: AnchorComponentToken;
|
Anchor?: AnchorComponentToken;
|
||||||
Avatar?: {};
|
Avatar?: {};
|
||||||
BackTop?: BackTopComponentToken;
|
BackTop?: BackTopComponentToken;
|
||||||
|
@ -1,20 +1,14 @@
|
|||||||
// import '../../style/index.less';
|
|
||||||
// import './index.less';
|
|
||||||
|
|
||||||
// deps-lint-skip-all
|
// deps-lint-skip-all
|
||||||
import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
|
import type { CSSInterpolation, CSSObject } from '@ant-design/cssinjs';
|
||||||
|
import type { FullToken, GenerateStyle } from '../../_util/theme';
|
||||||
|
import { genComponentStyleHook, mergeToken, resetComponent } from '../../_util/theme';
|
||||||
|
|
||||||
import type { GenerateStyle, FullToken } from '../../_util/theme';
|
export interface ComponentToken {}
|
||||||
import { resetComponent, genComponentStyleHook, mergeToken } from '../../_util/theme';
|
|
||||||
|
|
||||||
// FIXME: missing token
|
|
||||||
type AlertToken = FullToken<'Alert'> & {
|
type AlertToken = FullToken<'Alert'> & {
|
||||||
alertMessageColor: string;
|
alertIconSizeLG: number;
|
||||||
alertCloseColor: string;
|
alertPadding: number;
|
||||||
alertCloseHoverColor: string;
|
alertPaddingLG: number;
|
||||||
alertWithDescriptionIconSize: number;
|
|
||||||
alertWithDescriptionPaddingVertical: number;
|
|
||||||
alertWithDescriptionNoIconPaddingVertical: number;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const genAlertTypeStyle = (
|
const genAlertTypeStyle = (
|
||||||
@ -38,12 +32,14 @@ export const genBaseStyle: GenerateStyle<AlertToken> = (token: AlertToken): CSSO
|
|||||||
marginXS,
|
marginXS,
|
||||||
fontSize,
|
fontSize,
|
||||||
fontSizeLG,
|
fontSizeLG,
|
||||||
|
lineHeight,
|
||||||
controlRadius: borderRadius,
|
controlRadius: borderRadius,
|
||||||
motionEaseInOutCirc,
|
motionEaseInOutCirc,
|
||||||
alertMessageColor,
|
alertIconSizeLG,
|
||||||
alertWithDescriptionIconSize,
|
colorText,
|
||||||
alertWithDescriptionPaddingVertical,
|
alertPadding,
|
||||||
alertWithDescriptionNoIconPaddingVertical,
|
alertPaddingLG,
|
||||||
|
marginXXS,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -52,7 +48,7 @@ export const genBaseStyle: GenerateStyle<AlertToken> = (token: AlertToken): CSSO
|
|||||||
position: 'relative',
|
position: 'relative',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
padding: '8px 15px',
|
padding: `${alertPadding}px ${alertPaddingLG}px`,
|
||||||
wordWrap: 'break-word',
|
wordWrap: 'break-word',
|
||||||
borderRadius,
|
borderRadius,
|
||||||
|
|
||||||
@ -72,11 +68,11 @@ export const genBaseStyle: GenerateStyle<AlertToken> = (token: AlertToken): CSSO
|
|||||||
[`&-description`]: {
|
[`&-description`]: {
|
||||||
display: 'none',
|
display: 'none',
|
||||||
fontSize,
|
fontSize,
|
||||||
lineHeight: `${fontSize + 8}px`,
|
lineHeight,
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-message': {
|
'&-message': {
|
||||||
color: alertMessageColor,
|
color: colorText,
|
||||||
},
|
},
|
||||||
|
|
||||||
'&&-motion-leave': {
|
'&&-motion-leave': {
|
||||||
@ -98,23 +94,19 @@ export const genBaseStyle: GenerateStyle<AlertToken> = (token: AlertToken): CSSO
|
|||||||
|
|
||||||
[`${componentCls}-with-description`]: {
|
[`${componentCls}-with-description`]: {
|
||||||
alignItems: 'flex-start',
|
alignItems: 'flex-start',
|
||||||
paddingInlineStart: alertWithDescriptionIconSize,
|
paddingInline: alertPaddingLG,
|
||||||
paddingInlineEnd: alertWithDescriptionPaddingVertical,
|
paddingBlock: alertPaddingLG,
|
||||||
paddingBlock: alertWithDescriptionPaddingVertical,
|
|
||||||
|
|
||||||
[`&${componentCls}-no-icon`]: {
|
|
||||||
padding: `${alertWithDescriptionNoIconPaddingVertical}px 15px`,
|
|
||||||
},
|
|
||||||
|
|
||||||
[`${componentCls}-icon`]: {
|
[`${componentCls}-icon`]: {
|
||||||
marginInlineEnd: alertWithDescriptionPaddingVertical,
|
marginInlineStart: alertPadding,
|
||||||
fontSize: alertWithDescriptionIconSize,
|
marginInlineEnd: alertPaddingLG,
|
||||||
|
fontSize: alertIconSizeLG,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-message`]: {
|
[`${componentCls}-message`]: {
|
||||||
display: 'block',
|
display: 'block',
|
||||||
marginBottom: '4px',
|
marginBottom: marginXXS,
|
||||||
color: alertMessageColor,
|
color: colorText,
|
||||||
fontSize: fontSizeLG,
|
fontSize: fontSizeLG,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -187,8 +179,8 @@ export const genActionStyle: GenerateStyle<AlertToken> = (token: AlertToken): CS
|
|||||||
motionDurationSlow: duration,
|
motionDurationSlow: duration,
|
||||||
marginXS,
|
marginXS,
|
||||||
fontSizeIcon,
|
fontSizeIcon,
|
||||||
alertCloseColor,
|
colorAction,
|
||||||
alertCloseHoverColor,
|
colorActionHover,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -209,19 +201,19 @@ export const genActionStyle: GenerateStyle<AlertToken> = (token: AlertToken): CS
|
|||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
|
||||||
[`${iconCls}-close`]: {
|
[`${iconCls}-close`]: {
|
||||||
color: alertCloseColor,
|
color: colorAction,
|
||||||
transition: `color ${duration}`,
|
transition: `color ${duration}`,
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
color: alertCloseHoverColor,
|
color: colorActionHover,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-close-text': {
|
'&-close-text': {
|
||||||
color: alertCloseColor,
|
color: colorAction,
|
||||||
transition: `color ${duration}`,
|
transition: `color ${duration}`,
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
color: alertCloseHoverColor,
|
color: colorActionHover,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -235,21 +227,12 @@ export const genAlertStyle: GenerateStyle<AlertToken> = (token: AlertToken): CSS
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default genComponentStyleHook('Alert', token => {
|
export default genComponentStyleHook('Alert', token => {
|
||||||
const alertMessageColor = token.colorTextHeading;
|
const { fontSizeHeading3, paddingXS, padding } = token;
|
||||||
const alertCloseColor = token.colorAction;
|
|
||||||
const alertCloseHoverColor = token.colorActionHover;
|
|
||||||
// FIXME
|
|
||||||
const alertWithDescriptionIconSize = 24;
|
|
||||||
const alertWithDescriptionPaddingVertical = token.padding - 1;
|
|
||||||
const alertWithDescriptionNoIconPaddingVertical = token.padding - 1;
|
|
||||||
|
|
||||||
const alertToken = mergeToken<AlertToken>(token, {
|
const alertToken = mergeToken<AlertToken>(token, {
|
||||||
alertMessageColor,
|
alertIconSizeLG: fontSizeHeading3,
|
||||||
alertCloseColor,
|
alertPadding: paddingXS,
|
||||||
alertCloseHoverColor,
|
alertPaddingLG: padding,
|
||||||
alertWithDescriptionIconSize,
|
|
||||||
alertWithDescriptionPaddingVertical,
|
|
||||||
alertWithDescriptionNoIconPaddingVertical,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return [genAlertStyle(alertToken)];
|
return [genAlertStyle(alertToken)];
|
||||||
|
@ -310,7 +310,7 @@
|
|||||||
"bundlesize": [
|
"bundlesize": [
|
||||||
{
|
{
|
||||||
"path": "./dist/antd.min.js",
|
"path": "./dist/antd.min.js",
|
||||||
"maxSize": "360 kB"
|
"maxSize": "370 kB"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "./dist/antd.min.css",
|
"path": "./dist/antd.min.css",
|
||||||
|
Loading…
Reference in New Issue
Block a user