mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 17:19:11 +08:00
1e0c3b8c58
* feat: new component Flex * feat: new component Flex * fix: fix * test: add test case * fix: fix * update size-limit * test: update snap * fix: fix * test: update snap * chore: add use client * fix: lint * test: update snap * fix * docs: add docs * fix: fix demo * clear * demo: update demo * update demos * fix: fix * fix: fix * fix: fix * fix: fix * test: update snap * fix: fix * fix: fix * demo: update demo * feat: CP * fix: use token * fix: fix * fix: fix test case * test: update snap * Update components/flex/style/index.ts Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * Update components/flex/demo/align.tsx Co-authored-by: MadCcc <1075746765@qq.com> Signed-off-by: lijianan <574980606@qq.com> * demo: update demo * fix: fix * docs * update cover * fix: fix * test: update case * fix: rerun CI * fix: fix * fix: fix * fix: fix * fix: fix * demo: update demo * fix: fix lint * fix: fix * fix: fix * fix: fix * fix: fix * fix: fix test case * fix: fix * docs: update docs * fix: fix * chore: fix * chore: fix * docs: update docs * docs: update * fix: fix demo * type: update type * add debug demo --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: 栗嘉男 <mac@macdeMacBook-Pro.local> Co-authored-by: MadCcc <1075746765@qq.com>
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import classNames from 'classnames';
|
|
|
|
import type { FlexProps } from './interface';
|
|
|
|
export const flexWrapValues = ['wrap', 'nowrap', 'wrap-reverse'] as const;
|
|
|
|
export const justifyContentValues = [
|
|
'flex-start',
|
|
'flex-end',
|
|
'start',
|
|
'end',
|
|
'center',
|
|
'space-between',
|
|
'space-around',
|
|
'space-evenly',
|
|
'stretch',
|
|
'normal',
|
|
'left',
|
|
'right',
|
|
] as const;
|
|
|
|
export const alignItemsValues = [
|
|
'center',
|
|
'start',
|
|
'end',
|
|
'flex-start',
|
|
'flex-end',
|
|
'self-start',
|
|
'self-end',
|
|
'baseline',
|
|
'normal',
|
|
'stretch',
|
|
] as const;
|
|
|
|
const genClsWrap = (prefixCls: string, props: FlexProps) => {
|
|
const wrapCls: Record<PropertyKey, boolean> = {};
|
|
flexWrapValues.forEach((cssKey) => {
|
|
wrapCls[`${prefixCls}-wrap-${cssKey}`] = props.wrap === cssKey;
|
|
});
|
|
return wrapCls;
|
|
};
|
|
|
|
const genClsAlign = (prefixCls: string, props: FlexProps) => {
|
|
const alignCls: Record<PropertyKey, boolean> = {};
|
|
alignItemsValues.forEach((cssKey) => {
|
|
alignCls[`${prefixCls}-align-${cssKey}`] = props.align === cssKey;
|
|
});
|
|
alignCls[`${prefixCls}-align-stretch`] = !props.align && !!props.vertical;
|
|
return alignCls;
|
|
};
|
|
|
|
const genClsJustify = (prefixCls: string, props: FlexProps) => {
|
|
const justifyCls: Record<PropertyKey, boolean> = {};
|
|
justifyContentValues.forEach((cssKey) => {
|
|
justifyCls[`${prefixCls}-justify-${cssKey}`] = props.justify === cssKey;
|
|
});
|
|
return justifyCls;
|
|
};
|
|
|
|
function createFlexClassNames(prefixCls: string, props: FlexProps) {
|
|
return classNames({
|
|
...genClsWrap(prefixCls, props),
|
|
...genClsAlign(prefixCls, props),
|
|
...genClsJustify(prefixCls, props),
|
|
});
|
|
}
|
|
|
|
export default createFlexClassNames;
|