2022-04-01 10:23:34 +08:00
|
|
|
// deps-lint-skip-all
|
2022-05-09 22:20:07 +08:00
|
|
|
import type { CSSObject } from '@ant-design/cssinjs';
|
2022-04-01 10:23:34 +08:00
|
|
|
import { TinyColor } from '@ctrl/tinycolor';
|
2022-05-09 22:20:07 +08:00
|
|
|
import type { GenerateStyle, FullToken, DerivativeToken } from '../../_util/theme';
|
|
|
|
import { resetComponent, genComponentStyleHook, mergeToken } from '../../_util/theme';
|
2022-04-08 17:43:44 +08:00
|
|
|
|
|
|
|
interface ListToken extends FullToken<'List'> {
|
2022-04-01 10:23:34 +08:00
|
|
|
minHeight: number;
|
|
|
|
fontSizeSm: number;
|
|
|
|
antPrefix: string;
|
|
|
|
listBorderedCls: string;
|
|
|
|
minWidth: number;
|
|
|
|
marginSM: number;
|
|
|
|
lineHeightBase: number;
|
|
|
|
fontSizeLg: number;
|
|
|
|
height4: number;
|
|
|
|
height14: number;
|
|
|
|
height7: number;
|
|
|
|
height48: number;
|
|
|
|
disabledColor: string;
|
|
|
|
listItemPaddingLg: string;
|
|
|
|
listItemPaddingSm: string;
|
|
|
|
listItemPadding: string;
|
|
|
|
borderColorSplit: string;
|
|
|
|
borderColorBase: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
const genBorderedStyle = (token: ListToken): CSSObject => {
|
|
|
|
const {
|
|
|
|
listBorderedCls,
|
2022-04-08 17:43:44 +08:00
|
|
|
componentCls,
|
2022-04-01 10:23:34 +08:00
|
|
|
paddingLG,
|
|
|
|
margin,
|
|
|
|
padding,
|
|
|
|
listItemPaddingSm,
|
|
|
|
marginLG,
|
|
|
|
borderColorBase,
|
|
|
|
radiusBase,
|
|
|
|
} = token;
|
|
|
|
return {
|
|
|
|
[`${listBorderedCls}`]: {
|
|
|
|
border: `1px solid ${borderColorBase}`,
|
|
|
|
borderRadius: radiusBase,
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-header,${componentCls}-footer,${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
paddingInline: paddingLG,
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-pagination`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
margin: `${margin}px ${marginLG}px`,
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${listBorderedCls}${componentCls}-sm`]: {
|
|
|
|
[`${componentCls}-item,${componentCls}-header,${componentCls}-footer`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
padding: listItemPaddingSm,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${listBorderedCls}${componentCls}-lg`]: {
|
|
|
|
[`${componentCls}-item,${componentCls}-header,${componentCls}-footer`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
padding: `${padding}px ${paddingLG}px`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const genResponsiveStyle = (token: ListToken): CSSObject => {
|
2022-04-08 17:43:44 +08:00
|
|
|
const { minWidth, componentCls, screenSM, screenMD, marginLG, marginSM, margin } = token;
|
2022-04-01 10:23:34 +08:00
|
|
|
return {
|
|
|
|
[`@media screen and (max-width:${screenMD})`]: {
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
[`${componentCls}-item-action`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginInlineStart: marginLG,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-vertical`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
|
|
|
[`${componentCls}-item-extra`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginInlineStart: marginLG,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
[`@media screen and (max-width: ${screenSM})`]: {
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
flexWrap: 'wrap',
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-action`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginInlineStart: marginSM,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-vertical`]: {
|
|
|
|
[`${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
flexWrap: 'wrap-reverse',
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-main`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
minWidth,
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-extra`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
margin: `auto auto ${margin}px`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// =============================== Base ===============================
|
|
|
|
const genBaseStyle: GenerateStyle<ListToken> = token => {
|
|
|
|
const {
|
2022-04-08 17:43:44 +08:00
|
|
|
componentCls,
|
2022-04-01 10:23:34 +08:00
|
|
|
antPrefix,
|
|
|
|
controlHeight,
|
|
|
|
minHeight,
|
|
|
|
height48,
|
|
|
|
fontSizeSm,
|
|
|
|
paddingSM,
|
|
|
|
marginLG,
|
|
|
|
marginSM,
|
|
|
|
padding,
|
|
|
|
disabledColor,
|
|
|
|
lineHeightBase,
|
|
|
|
fontSizeBase,
|
|
|
|
listItemPadding,
|
|
|
|
colorPrimary,
|
|
|
|
borderColorSplit,
|
|
|
|
listItemPaddingSm,
|
|
|
|
listItemPaddingLg,
|
|
|
|
paddingXS,
|
|
|
|
fontSize,
|
|
|
|
fontSizeLg,
|
|
|
|
margin,
|
|
|
|
colorText,
|
|
|
|
colorTextSecondary,
|
|
|
|
lineHeight,
|
|
|
|
height4,
|
|
|
|
motionDurationSlow,
|
|
|
|
lineWidth,
|
|
|
|
height14,
|
|
|
|
height7,
|
|
|
|
} = token;
|
|
|
|
|
|
|
|
return {
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}`]: {
|
2022-04-11 16:04:00 +08:00
|
|
|
...resetComponent(
|
|
|
|
mergeToken<DerivativeToken>(token, {
|
|
|
|
colorText,
|
|
|
|
fontSize: fontSizeBase,
|
|
|
|
lineHeight: lineHeightBase,
|
|
|
|
}),
|
|
|
|
),
|
2022-04-01 10:23:34 +08:00
|
|
|
position: 'relative',
|
|
|
|
'*': {
|
|
|
|
outline: 'none',
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-header, ${componentCls}-footer`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
background: 'transparent',
|
|
|
|
paddingBlock: paddingSM,
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-pagination`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginBlockStart: marginLG,
|
|
|
|
textAlign: 'end',
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/20037
|
|
|
|
[`${antPrefix}-pagination-options`]: {
|
|
|
|
textAlign: 'start',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-more`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginBlockStart: marginSM,
|
|
|
|
textAlign: 'center',
|
|
|
|
button: {
|
|
|
|
paddingInline: `${controlHeight}px`,
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-spin`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
minHeight,
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-items`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
margin: 0,
|
|
|
|
padding: 0,
|
|
|
|
listStyle: 'none',
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
padding: listItemPadding,
|
|
|
|
color: colorText,
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
display: 'flex',
|
|
|
|
flex: 1,
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
maxWidth: '100%',
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta-avatar`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginInlineEnd: padding,
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta-content`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
flex: '1 0',
|
|
|
|
width: 0,
|
|
|
|
color: colorText,
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta-title`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginBlockEnd: height4,
|
|
|
|
color: colorText,
|
|
|
|
fontSize,
|
|
|
|
lineHeight: lineHeightBase,
|
|
|
|
|
|
|
|
'> a': {
|
|
|
|
color: colorText,
|
|
|
|
transition: `all ${motionDurationSlow}`,
|
|
|
|
|
|
|
|
[`&:hover`]: {
|
|
|
|
color: colorPrimary,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta-description`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
color: colorTextSecondary,
|
|
|
|
fontSize: fontSizeBase,
|
|
|
|
lineHeight: lineHeightBase,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-action`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
flex: '0 0 auto',
|
|
|
|
marginInlineStart: height48,
|
|
|
|
padding: 0,
|
|
|
|
fontSize: 0,
|
|
|
|
listStyle: 'none',
|
|
|
|
|
|
|
|
[`& > li`]: {
|
|
|
|
position: 'relative',
|
|
|
|
display: 'inline-block',
|
|
|
|
padding: `0 ${paddingXS}px`,
|
|
|
|
color: colorTextSecondary,
|
|
|
|
fontSize: fontSizeBase,
|
|
|
|
lineHeight: lineHeightBase,
|
|
|
|
textAlign: 'center',
|
|
|
|
|
|
|
|
[`&:first-child`]: {
|
|
|
|
paddingInlineStart: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-action-split`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
position: 'absolute',
|
|
|
|
insetBlockStart: '50%',
|
|
|
|
insetInlineEnd: 0,
|
|
|
|
width: lineWidth,
|
|
|
|
height: height14,
|
|
|
|
marginBlockStart: -height7,
|
|
|
|
backgroundColor: borderColorSplit,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-empty`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
padding: `${padding}px 0`,
|
|
|
|
color: colorTextSecondary,
|
|
|
|
fontSize: fontSizeSm,
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-empty-text`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
padding,
|
|
|
|
color: disabledColor,
|
|
|
|
fontSize: fontSizeBase,
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
|
|
|
|
// ============================ without flex ============================
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-no-flex`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
display: 'block',
|
|
|
|
},
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-grid ${antPrefix}-col > ${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
display: 'block',
|
|
|
|
maxWidth: '100%',
|
|
|
|
marginBlockEnd: margin,
|
|
|
|
paddingBlock: 0,
|
|
|
|
borderBlockEnd: 'none',
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-vertical ${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
alignItems: 'initial',
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-main`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
display: 'block',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-extra`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginInlineStart: marginLG,
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginBlockEnd: padding,
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-meta-title`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginBlockEnd: paddingSM,
|
|
|
|
color: colorText,
|
|
|
|
fontSize: fontSizeLg,
|
|
|
|
lineHeight,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-item-action`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
marginBlockStart: padding,
|
|
|
|
marginInlineStart: 'auto',
|
|
|
|
|
|
|
|
'> li': {
|
|
|
|
padding: `0 ${padding}px`,
|
|
|
|
|
|
|
|
[`&:first-child`]: {
|
|
|
|
paddingInlineStart: 0,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-split ${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
borderBlockEnd: `1px solid ${borderColorSplit}`,
|
|
|
|
|
|
|
|
[`&:last-child`]: {
|
|
|
|
borderBlockEnd: 'none',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-split ${componentCls}-header`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
borderBlockEnd: `1px solid ${borderColorSplit}`,
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-split${componentCls}-empty ${componentCls}-footer`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
borderTop: `1px solid ${borderColorSplit}`,
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-loading ${componentCls}-spin-nested-loading`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
minHeight: controlHeight,
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-split${componentCls}-something-after-last-item ${antPrefix}-spin-container > ${componentCls}-items > ${componentCls}-item:last-child`]:
|
2022-04-01 10:23:34 +08:00
|
|
|
{
|
|
|
|
borderBlockEnd: `1px solid ${borderColorSplit}`,
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-lg ${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
padding: listItemPaddingLg,
|
|
|
|
},
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}-sm ${componentCls}-item`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
padding: listItemPaddingSm,
|
|
|
|
},
|
|
|
|
// Horizontal
|
2022-04-08 17:43:44 +08:00
|
|
|
[`${componentCls}:not(${componentCls}-vertical)`]: {
|
|
|
|
[`${componentCls}-item-no-flex`]: {
|
|
|
|
[`${componentCls}-item-action`]: {
|
2022-04-01 10:23:34 +08:00
|
|
|
float: 'right',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// ============================== Export ==============================
|
2022-04-21 02:06:22 +08:00
|
|
|
export default genComponentStyleHook('List', token => {
|
2022-04-11 16:04:00 +08:00
|
|
|
const listToken = mergeToken<ListToken>(token, {
|
2022-04-08 17:43:44 +08:00
|
|
|
listBorderedCls: `${token.componentCls}-bordered`,
|
2022-04-01 10:23:34 +08:00
|
|
|
antPrefix: '.ant', // FIXME: hard code in v4
|
|
|
|
minHeight: 40, // FIXME: hard code in v4,
|
|
|
|
colorTextSecondary: new TinyColor('#000').setAlpha(0.45).toRgbString(), // FIXME: hard code in v4,
|
|
|
|
borderColorSplit: new TinyColor({ h: 0, s: 0, v: 94 }).toHexString(), // FIXME: hard code in v4,
|
|
|
|
borderColorBase: new TinyColor({ h: 0, s: 0, v: 85 }).toHexString(), // FIXME: hard code in v4,
|
|
|
|
disabledColor: new TinyColor('#000').setAlpha(0.25).toRgbString(), // FIXME: hard code in v4,
|
|
|
|
minWidth: 220, // FIXME: hard code in v4,
|
|
|
|
|
|
|
|
height4: 4, // FIXME: hard code in v4,
|
|
|
|
height14: 14, // FIXME: hard code in v4,
|
|
|
|
height7: 7, // FIXME: hard code in v4,
|
|
|
|
height48: 48, // FIXME: hard code in v4,
|
|
|
|
|
|
|
|
fontSizeSm: 12, // FIXME: hard code in v4,
|
|
|
|
fontSize: 14, // FIXME: hard code in v4,
|
|
|
|
fontSizeLg: 16, // FIXME: hard code in v4,
|
|
|
|
|
|
|
|
listItemPadding: '12px 0', // FIXME: hard code in v4,
|
|
|
|
listItemPaddingSm: '8px 16px', // FIXME: hard code in v4,
|
|
|
|
listItemPaddingLg: '16px 24px', // FIXME: hard code in v4,
|
|
|
|
|
|
|
|
lineHeightBase: 1.5715, // FIXME: hard code in v4,
|
|
|
|
lineHeight: 1.5,
|
2022-04-11 16:04:00 +08:00
|
|
|
});
|
2022-04-01 10:23:34 +08:00
|
|
|
|
2022-04-21 02:06:22 +08:00
|
|
|
return [genBaseStyle(listToken), genBorderedStyle(listToken), genResponsiveStyle(listToken)];
|
2022-04-08 17:43:44 +08:00
|
|
|
});
|