mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
59ad48476b
* chore: add boime lint * fix lint * use files ignore * revert change * ignore clarity.js * fix some errors * fix some errors * fix some errors * fix some errors * add yml file * Update clarity.js Signed-off-by: afc163 <afc163@gmail.com> * add npm run lint:biome * add npm run lint:biome * fix test case * fix ts errors * fix ts errors * fix lint and add .lintstagedrc * shorten prop name * chore: update package.json * update biome.json * chore: remove stylelint * chore: useOptionalChain * fix lint * biome format * prettier all code * prettier all code * fix site test --------- Signed-off-by: afc163 <afc163@gmail.com>
103 lines
2.7 KiB
TypeScript
103 lines
2.7 KiB
TypeScript
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
|
import { genStyleHooks, mergeToken } from '../../theme/internal';
|
|
import genSpaceCompactStyle from './compact';
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
// biome-ignore lint/suspicious/noEmptyInterface: ComponentToken need to be empty by default
|
|
export interface ComponentToken {}
|
|
|
|
interface SpaceToken extends FullToken<'Space'> {
|
|
spaceGapSmallSize: number;
|
|
spaceGapMiddleSize: number;
|
|
spaceGapLargeSize: number;
|
|
}
|
|
|
|
const genSpaceStyle: GenerateStyle<SpaceToken> = (token) => {
|
|
const { componentCls, antCls } = 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': {
|
|
alignItems: 'baseline',
|
|
},
|
|
},
|
|
[`${componentCls}-item:empty`]: {
|
|
display: 'none',
|
|
},
|
|
// https://github.com/ant-design/ant-design/issues/47875
|
|
[`${componentCls}-item > ${antCls}-badge-not-a-wrapper:only-child`]: {
|
|
display: 'block',
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
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,
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export const prepareComponentToken: GetDefaultToken<'Space'> = () => ({});
|
|
|
|
export default genStyleHooks(
|
|
'Space',
|
|
(token) => {
|
|
const spaceToken = mergeToken<SpaceToken>(token, {
|
|
spaceGapSmallSize: token.paddingXS,
|
|
spaceGapMiddleSize: token.padding,
|
|
spaceGapLargeSize: token.paddingLG,
|
|
});
|
|
return [
|
|
genSpaceStyle(spaceToken),
|
|
genSpaceGapStyle(spaceToken),
|
|
genSpaceCompactStyle(spaceToken),
|
|
];
|
|
},
|
|
() => ({}),
|
|
{
|
|
// Space component don't apply extra font style
|
|
// https://github.com/ant-design/ant-design/issues/40315
|
|
resetStyle: false,
|
|
},
|
|
);
|