mirror of
https://github.com/ant-design/ant-design.git
synced 2025-07-26 08:47:29 +08:00
refactor: refactor Popover wireframe token (#45891)
This commit is contained in:
parent
038323441c
commit
93dcadbae1
@ -18,13 +18,13 @@ export interface ComponentToken extends ArrowToken, ArrowOffsetToken {
|
|||||||
* @desc 气泡卡片宽度
|
* @desc 气泡卡片宽度
|
||||||
* @descEN Width of Popover
|
* @descEN Width of Popover
|
||||||
*/
|
*/
|
||||||
width: number;
|
width?: number;
|
||||||
/**
|
/**
|
||||||
* @deprecated Please use `titleMinWidth` instead
|
* @deprecated Please use `titleMinWidth` instead
|
||||||
* @desc 气泡卡片最小宽度
|
* @desc 气泡卡片最小宽度
|
||||||
* @descEN Min width of Popover
|
* @descEN Min width of Popover
|
||||||
*/
|
*/
|
||||||
minWidth: number;
|
minWidth?: number;
|
||||||
/**
|
/**
|
||||||
* @desc 气泡卡片标题最小宽度
|
* @desc 气泡卡片标题最小宽度
|
||||||
* @descEN Min width of Popover title
|
* @descEN Min width of Popover title
|
||||||
@ -35,12 +35,21 @@ export interface ComponentToken extends ArrowToken, ArrowOffsetToken {
|
|||||||
* @descEN z-index of Popover
|
* @descEN z-index of Popover
|
||||||
*/
|
*/
|
||||||
zIndexPopup: number;
|
zIndexPopup: number;
|
||||||
|
/** @internal */
|
||||||
|
innerPadding: number;
|
||||||
|
/** @internal */
|
||||||
|
titlePadding: number | string;
|
||||||
|
/** @internal */
|
||||||
|
titleMarginBottom: number;
|
||||||
|
/** @internal */
|
||||||
|
titleBorderBottom: string;
|
||||||
|
/** @internal */
|
||||||
|
innerContentPadding: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PopoverToken = FullToken<'Popover'> & {
|
export type PopoverToken = FullToken<'Popover'> & {
|
||||||
popoverBg: string;
|
popoverBg: string;
|
||||||
popoverColor: string;
|
popoverColor: string;
|
||||||
popoverPadding: number | string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const genBaseStyle: GenerateStyle<PopoverToken> = (token) => {
|
const genBaseStyle: GenerateStyle<PopoverToken> = (token) => {
|
||||||
@ -49,14 +58,17 @@ const genBaseStyle: GenerateStyle<PopoverToken> = (token) => {
|
|||||||
popoverColor,
|
popoverColor,
|
||||||
titleMinWidth,
|
titleMinWidth,
|
||||||
fontWeightStrong,
|
fontWeightStrong,
|
||||||
popoverPadding,
|
innerPadding,
|
||||||
boxShadowSecondary,
|
boxShadowSecondary,
|
||||||
colorTextHeading,
|
colorTextHeading,
|
||||||
borderRadiusLG: borderRadius,
|
borderRadiusLG,
|
||||||
zIndexPopup,
|
zIndexPopup,
|
||||||
marginXS,
|
titleMarginBottom,
|
||||||
colorBgElevated,
|
colorBgElevated,
|
||||||
popoverBg,
|
popoverBg,
|
||||||
|
titleBorderBottom,
|
||||||
|
innerContentPadding,
|
||||||
|
titlePadding,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -94,20 +106,23 @@ const genBaseStyle: GenerateStyle<PopoverToken> = (token) => {
|
|||||||
[`${componentCls}-inner`]: {
|
[`${componentCls}-inner`]: {
|
||||||
backgroundColor: popoverBg,
|
backgroundColor: popoverBg,
|
||||||
backgroundClip: 'padding-box',
|
backgroundClip: 'padding-box',
|
||||||
borderRadius,
|
borderRadius: borderRadiusLG,
|
||||||
boxShadow: boxShadowSecondary,
|
boxShadow: boxShadowSecondary,
|
||||||
padding: popoverPadding,
|
padding: innerPadding,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-title`]: {
|
[`${componentCls}-title`]: {
|
||||||
minWidth: titleMinWidth,
|
minWidth: titleMinWidth,
|
||||||
marginBottom: marginXS,
|
marginBottom: titleMarginBottom,
|
||||||
color: colorTextHeading,
|
color: colorTextHeading,
|
||||||
fontWeight: fontWeightStrong,
|
fontWeight: fontWeightStrong,
|
||||||
|
borderBottom: titleBorderBottom,
|
||||||
|
padding: titlePadding,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-inner-content`]: {
|
[`${componentCls}-inner-content`]: {
|
||||||
color: popoverColor,
|
color: popoverColor,
|
||||||
|
padding: innerContentPadding,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -152,62 +167,52 @@ const genColorStyle: GenerateStyle<PopoverToken> = (token) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const genWireframeStyle: GenerateStyle<PopoverToken> = (token) => {
|
export const prepareComponentToken: GetDefaultToken<'Popover'> = (token) => {
|
||||||
const {
|
const {
|
||||||
componentCls,
|
|
||||||
lineWidth,
|
lineWidth,
|
||||||
|
controlHeight,
|
||||||
|
fontHeight,
|
||||||
|
padding,
|
||||||
|
wireframe,
|
||||||
|
zIndexPopupBase,
|
||||||
|
borderRadiusLG,
|
||||||
|
marginXS,
|
||||||
lineType,
|
lineType,
|
||||||
colorSplit,
|
colorSplit,
|
||||||
paddingSM,
|
paddingSM,
|
||||||
controlHeight,
|
|
||||||
fontSize,
|
|
||||||
lineHeight,
|
|
||||||
padding,
|
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
const titlePaddingBlockDist = controlHeight - Math.round(fontSize * lineHeight);
|
const titlePaddingBlockDist = controlHeight - fontHeight;
|
||||||
const popoverTitlePaddingBlockTop = titlePaddingBlockDist / 2;
|
const popoverTitlePaddingBlockTop = titlePaddingBlockDist / 2;
|
||||||
const popoverTitlePaddingBlockBottom = titlePaddingBlockDist / 2 - lineWidth;
|
const popoverTitlePaddingBlockBottom = titlePaddingBlockDist / 2 - lineWidth;
|
||||||
const popoverPaddingHorizontal = padding;
|
const popoverPaddingHorizontal = padding;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[componentCls]: {
|
titleMinWidth: 177,
|
||||||
[`${componentCls}-inner`]: {
|
zIndexPopup: zIndexPopupBase + 30,
|
||||||
padding: 0,
|
...getArrowToken(token),
|
||||||
},
|
...getArrowOffsetToken({
|
||||||
|
contentRadius: borderRadiusLG,
|
||||||
|
limitVerticalRadius: true,
|
||||||
|
}),
|
||||||
|
|
||||||
[`${componentCls}-title`]: {
|
// internal
|
||||||
margin: 0,
|
innerPadding: wireframe ? 0 : 12,
|
||||||
padding: `${popoverTitlePaddingBlockTop}px ${popoverPaddingHorizontal}px ${popoverTitlePaddingBlockBottom}px`,
|
titleMarginBottom: wireframe ? 0 : marginXS,
|
||||||
borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
|
titlePadding: wireframe
|
||||||
},
|
? `${popoverTitlePaddingBlockTop}px ${popoverPaddingHorizontal}px ${popoverTitlePaddingBlockBottom}px`
|
||||||
|
: 0,
|
||||||
[`${componentCls}-inner-content`]: {
|
titleBorderBottom: wireframe ? `${lineWidth}px ${lineType} ${colorSplit}` : 'none',
|
||||||
padding: `${paddingSM}px ${popoverPaddingHorizontal}px`,
|
innerContentPadding: wireframe ? `${paddingSM}px ${popoverPaddingHorizontal}px` : 0,
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const prepareComponentToken: GetDefaultToken<'Popover'> = (token) => ({
|
|
||||||
width: 177,
|
|
||||||
minWidth: 177,
|
|
||||||
titleMinWidth: 177,
|
|
||||||
zIndexPopup: token.zIndexPopupBase + 30,
|
|
||||||
...getArrowToken(token),
|
|
||||||
...getArrowOffsetToken({
|
|
||||||
contentRadius: token.borderRadiusLG,
|
|
||||||
limitVerticalRadius: true,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default genComponentStyleHook(
|
export default genComponentStyleHook(
|
||||||
'Popover',
|
'Popover',
|
||||||
(token) => {
|
(token) => {
|
||||||
const { colorBgElevated, colorText, wireframe } = token;
|
const { colorBgElevated, colorText } = token;
|
||||||
|
|
||||||
const popoverToken = mergeToken<PopoverToken>(token, {
|
const popoverToken = mergeToken<PopoverToken>(token, {
|
||||||
popoverPadding: 12, // Fixed Value
|
|
||||||
popoverBg: colorBgElevated,
|
popoverBg: colorBgElevated,
|
||||||
popoverColor: colorText,
|
popoverColor: colorText,
|
||||||
});
|
});
|
||||||
@ -215,7 +220,6 @@ export default genComponentStyleHook(
|
|||||||
return [
|
return [
|
||||||
genBaseStyle(popoverToken),
|
genBaseStyle(popoverToken),
|
||||||
genColorStyle(popoverToken),
|
genColorStyle(popoverToken),
|
||||||
wireframe && genWireframeStyle(popoverToken),
|
|
||||||
initZoomMotion(popoverToken, 'zoom-big'),
|
initZoomMotion(popoverToken, 'zoom-big'),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user