mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
9619c8c37e
* refactor: simplify code * style: fix Space font style * demo: fix Select demo
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
|
import { genComponentStyleHook } from '../../theme/internal';
|
|
import genSpaceCompactStyle from './compact';
|
|
|
|
/** Component only token. Which will handle additional calculation of alias token */
|
|
export interface ComponentToken {
|
|
// Component token here
|
|
}
|
|
|
|
interface SpaceToken extends FullToken<'Space'> {
|
|
// Custom token here
|
|
}
|
|
|
|
const genSpaceStyle: GenerateStyle<SpaceToken> = (token) => {
|
|
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': {
|
|
alignItems: 'baseline',
|
|
},
|
|
},
|
|
[`${componentCls}-item:empty`]: {
|
|
display: 'none',
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
// ============================== Export ==============================
|
|
export default genComponentStyleHook(
|
|
'Space',
|
|
(token) => [genSpaceStyle(token), genSpaceCompactStyle(token)],
|
|
() => ({}),
|
|
{
|
|
// Space component don't apply extra font style
|
|
// https://github.com/ant-design/ant-design/issues/40315
|
|
resetStyle: false,
|
|
},
|
|
);
|