2022-11-23 20:22:38 +08:00
|
|
|
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
2023-09-04 19:59:02 +08:00
|
|
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
2022-10-28 16:09:38 +08:00
|
|
|
import genSpaceCompactStyle from './compact';
|
2022-05-04 22:00:39 +08:00
|
|
|
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
|
|
export interface ComponentToken {
|
|
|
|
// Component token here
|
|
|
|
}
|
|
|
|
|
|
|
|
interface SpaceToken extends FullToken<'Space'> {
|
2023-09-04 19:59:02 +08:00
|
|
|
spaceGapSmallSize: number;
|
|
|
|
spaceGapMiddleSize: number;
|
|
|
|
spaceGapLargeSize: number;
|
2022-05-04 22:00:39 +08:00
|
|
|
}
|
|
|
|
|
2022-11-19 13:47:33 +08:00
|
|
|
const genSpaceStyle: GenerateStyle<SpaceToken> = (token) => {
|
2022-05-04 22:00:39 +08:00
|
|
|
const { componentCls } = token;
|
|
|
|
|
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
display: 'inline-flex',
|
|
|
|
'&-rtl': {
|
|
|
|
direction: 'rtl',
|
|
|
|
},
|
|
|
|
'&-vertical': {
|
|
|
|
flexDirection: 'column',
|
|
|
|
},
|
|
|
|
'&-align': {
|
|
|
|
flexDirection: 'column',
|
|
|
|
'&-center': {
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
'&-start': {
|
|
|
|
alignItems: 'flex-start',
|
|
|
|
},
|
|
|
|
'&-end': {
|
|
|
|
alignItems: 'flex-end',
|
|
|
|
},
|
|
|
|
'&-baseline': {
|
2022-12-23 10:47:26 +08:00
|
|
|
alignItems: 'baseline',
|
2022-05-04 22:00:39 +08:00
|
|
|
},
|
|
|
|
},
|
2023-04-10 10:29:26 +08:00
|
|
|
[`${componentCls}-item:empty`]: {
|
|
|
|
display: 'none',
|
2022-05-04 22:00:39 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-04 19:59:02 +08:00
|
|
|
const genSpaceGapStyle: GenerateStyle<SpaceToken> = (token) => {
|
|
|
|
const { componentCls } = token;
|
|
|
|
return {
|
|
|
|
[componentCls]: {
|
|
|
|
'&-gap-row-small': {
|
|
|
|
rowGap: token.spaceGapSmallSize,
|
|
|
|
},
|
|
|
|
'&-gap-row-middle': {
|
|
|
|
rowGap: token.spaceGapMiddleSize,
|
|
|
|
},
|
|
|
|
'&-gap-row-large': {
|
|
|
|
rowGap: token.spaceGapLargeSize,
|
|
|
|
},
|
|
|
|
'&-gap-col-small': {
|
|
|
|
columnGap: token.spaceGapSmallSize,
|
|
|
|
},
|
|
|
|
'&-gap-col-middle': {
|
|
|
|
columnGap: token.spaceGapMiddleSize,
|
|
|
|
},
|
|
|
|
'&-gap-col-large': {
|
|
|
|
columnGap: token.spaceGapLargeSize,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-04 22:00:39 +08:00
|
|
|
// ============================== Export ==============================
|
2023-04-10 10:29:26 +08:00
|
|
|
export default genComponentStyleHook(
|
|
|
|
'Space',
|
2023-09-04 19:59:02 +08:00
|
|
|
(token) => {
|
|
|
|
const spaceToken = mergeToken<SpaceToken>(token, {
|
|
|
|
spaceGapSmallSize: token.paddingXS,
|
|
|
|
spaceGapMiddleSize: token.padding,
|
|
|
|
spaceGapLargeSize: token.paddingLG,
|
|
|
|
});
|
|
|
|
return [
|
|
|
|
genSpaceStyle(spaceToken),
|
|
|
|
genSpaceGapStyle(spaceToken),
|
|
|
|
genSpaceCompactStyle(spaceToken),
|
|
|
|
];
|
|
|
|
},
|
2023-04-10 10:29:26 +08:00
|
|
|
() => ({}),
|
|
|
|
{
|
|
|
|
// Space component don't apply extra font style
|
|
|
|
// https://github.com/ant-design/ant-design/issues/40315
|
|
|
|
resetStyle: false,
|
|
|
|
},
|
|
|
|
);
|