mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
chore: code style optimization (#43497)
* chore: code style optimization * revert: 直接解构, 不用 props * chore: fix classNames useless boolean * fix: remove classname useless boolean * fix: revert delete progress classnames boolean
This commit is contained in:
parent
b24360e3f3
commit
82e5555ff3
@ -113,8 +113,8 @@ const InternalCheckbox: React.ForwardRefRenderFunction<CheckboxRef, CheckboxProp
|
|||||||
checkboxProps.checked = checkboxGroup.value.includes(restProps.value);
|
checkboxProps.checked = checkboxGroup.value.includes(restProps.value);
|
||||||
}
|
}
|
||||||
const classString = classNames(
|
const classString = classNames(
|
||||||
|
`${prefixCls}-wrapper`,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-wrapper`]: true,
|
|
||||||
[`${prefixCls}-rtl`]: direction === 'rtl',
|
[`${prefixCls}-rtl`]: direction === 'rtl',
|
||||||
[`${prefixCls}-wrapper-checked`]: checkboxProps.checked,
|
[`${prefixCls}-wrapper-checked`]: checkboxProps.checked,
|
||||||
[`${prefixCls}-wrapper-disabled`]: mergedDisabled,
|
[`${prefixCls}-wrapper-disabled`]: mergedDisabled,
|
||||||
|
@ -101,8 +101,8 @@ const InternalForm: React.ForwardRefRenderFunction<FormInstance, FormProps> = (p
|
|||||||
|
|
||||||
const formClassName = classNames(
|
const formClassName = classNames(
|
||||||
prefixCls,
|
prefixCls,
|
||||||
|
`${prefixCls}-${layout}`,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-${layout}`]: true,
|
|
||||||
[`${prefixCls}-hide-required-mark`]: mergedRequiredMark === false,
|
[`${prefixCls}-hide-required-mark`]: mergedRequiredMark === false,
|
||||||
[`${prefixCls}-rtl`]: direction === 'rtl',
|
[`${prefixCls}-rtl`]: direction === 'rtl',
|
||||||
[`${prefixCls}-${mergedSize}`]: mergedSize,
|
[`${prefixCls}-${mergedSize}`]: mergedSize,
|
||||||
|
@ -30,8 +30,7 @@ export const useCompactItemContext = (prefixCls: string, direction: DirectionTyp
|
|||||||
const { compactDirection, isFirstItem, isLastItem } = compactItemContext;
|
const { compactDirection, isFirstItem, isLastItem } = compactItemContext;
|
||||||
const separator = compactDirection === 'vertical' ? '-vertical-' : '-';
|
const separator = compactDirection === 'vertical' ? '-vertical-' : '-';
|
||||||
|
|
||||||
return classNames({
|
return classNames(`${prefixCls}-compact${separator}item`, {
|
||||||
[`${prefixCls}-compact${separator}item`]: true,
|
|
||||||
[`${prefixCls}-compact${separator}first-item`]: isFirstItem,
|
[`${prefixCls}-compact${separator}first-item`]: isFirstItem,
|
||||||
[`${prefixCls}-compact${separator}last-item`]: isLastItem,
|
[`${prefixCls}-compact${separator}last-item`]: isLastItem,
|
||||||
[`${prefixCls}-compact${separator}item-rtl`]: direction === 'rtl',
|
[`${prefixCls}-compact${separator}item-rtl`]: direction === 'rtl',
|
||||||
|
@ -12,7 +12,7 @@ export interface ItemProps {
|
|||||||
style?: React.CSSProperties;
|
style?: React.CSSProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Item({
|
const Item: React.FC<ItemProps> = ({
|
||||||
className,
|
className,
|
||||||
direction,
|
direction,
|
||||||
index,
|
index,
|
||||||
@ -21,7 +21,7 @@ export default function Item({
|
|||||||
split,
|
split,
|
||||||
wrap,
|
wrap,
|
||||||
style: customStyle,
|
style: customStyle,
|
||||||
}: ItemProps) {
|
}) => {
|
||||||
const { horizontalSize, verticalSize, latestIndex, supportFlexGap } =
|
const { horizontalSize, verticalSize, latestIndex, supportFlexGap } =
|
||||||
React.useContext(SpaceContext);
|
React.useContext(SpaceContext);
|
||||||
|
|
||||||
@ -56,4 +56,6 @@ export default function Item({
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export default Item;
|
||||||
|
@ -40,8 +40,8 @@ const CheckableTag: React.FC<CheckableTagProps> = (props) => {
|
|||||||
|
|
||||||
const cls = classNames(
|
const cls = classNames(
|
||||||
prefixCls,
|
prefixCls,
|
||||||
|
`${prefixCls}-checkable`,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-checkable`]: true,
|
|
||||||
[`${prefixCls}-checkable-checked`]: checked,
|
[`${prefixCls}-checkable-checked`]: checked,
|
||||||
},
|
},
|
||||||
className,
|
className,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ConfigContext } from '../config-provider';
|
|
||||||
import type { LiteralUnion } from '../_util/type';
|
import type { LiteralUnion } from '../_util/type';
|
||||||
|
import { ConfigContext } from '../config-provider';
|
||||||
|
|
||||||
type Color = 'blue' | 'red' | 'green' | 'gray';
|
type Color = 'blue' | 'red' | 'green' | 'gray';
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ const TimelineItem: React.FC<TimelineItemProps> = ({
|
|||||||
|
|
||||||
const prefixCls = getPrefixCls('timeline', customizePrefixCls);
|
const prefixCls = getPrefixCls('timeline', customizePrefixCls);
|
||||||
const itemClassName = classNames(
|
const itemClassName = classNames(
|
||||||
|
`${prefixCls}-item`,
|
||||||
{
|
{
|
||||||
[`${prefixCls}-item`]: true,
|
|
||||||
[`${prefixCls}-item-pending`]: pending,
|
[`${prefixCls}-item-pending`]: pending,
|
||||||
},
|
},
|
||||||
className,
|
className,
|
||||||
@ -48,8 +48,7 @@ const TimelineItem: React.FC<TimelineItemProps> = ({
|
|||||||
|
|
||||||
const customColor = /blue|red|green|gray/.test(color || '') ? undefined : color;
|
const customColor = /blue|red|green|gray/.test(color || '') ? undefined : color;
|
||||||
|
|
||||||
const dotClassName = classNames({
|
const dotClassName = classNames(`${prefixCls}-item-head`, {
|
||||||
[`${prefixCls}-item-head`]: true,
|
|
||||||
[`${prefixCls}-item-head-custom`]: !!dot,
|
[`${prefixCls}-item-head-custom`]: !!dot,
|
||||||
[`${prefixCls}-item-head-${color}`]: !customColor,
|
[`${prefixCls}-item-head-${color}`]: !customColor,
|
||||||
});
|
});
|
||||||
|
@ -165,8 +165,7 @@ const InternalUploadList: React.ForwardRefRenderFunction<UploadListRef, UploadLi
|
|||||||
const prefixCls = getPrefixCls('upload', customizePrefixCls);
|
const prefixCls = getPrefixCls('upload', customizePrefixCls);
|
||||||
const rootPrefixCls = getPrefixCls();
|
const rootPrefixCls = getPrefixCls();
|
||||||
|
|
||||||
const listClassNames = classNames({
|
const listClassNames = classNames(`${prefixCls}-list`, {
|
||||||
[`${prefixCls}-list`]: true,
|
|
||||||
[`${prefixCls}-list-${listType}`]: true,
|
[`${prefixCls}-list-${listType}`]: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user