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:
thinkasany 2023-07-13 01:46:56 +08:00 committed by GitHub
parent b24360e3f3
commit 82e5555ff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 14 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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',

View File

@ -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;

View File

@ -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,

View File

@ -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,
}); });

View File

@ -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,
}); });