Skip to content

Commit 789172e

Browse files
authored
🐛 fix: 修复 FieldTitle 样式错误 (#92)
* ⚰️ chore: remove unnecessary props * 📸 chore: update snapshot * 🐛 fix: no extra
1 parent 7634877 commit 789172e

6 files changed

Lines changed: 660 additions & 943 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@
119119
"@emotion/jest": "^11.11.0",
120120
"@testing-library/jest-dom": "^5.17.0",
121121
"@testing-library/react": "^13.4.0",
122-
"@testing-library/user-event": "^14.5.0",
122+
"@testing-library/user-event": "^14.5.1",
123123
"@types/color": "^3.0.4",
124-
"@types/json-schema": "^7.0.12",
124+
"@types/json-schema": "^7.0.13",
125125
"@types/react": "^18.2.21",
126126
"@types/react-dom": "^18.2.7",
127127
"@umijs/lint": "^4.0.81",
@@ -148,7 +148,7 @@
148148
"react": "^18.2.0",
149149
"react-dom": "^18.2.0",
150150
"rxjs-spy": "^8.0.2",
151-
"semantic-release": "^21.1.1",
151+
"semantic-release": "^21.1.2",
152152
"semantic-release-config-gitmoji": "^1.5.3",
153153
"stylelint": "^15.10.3",
154154
"typescript": "~5.1.6",

src/FieldTitle/demos/description.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@ const Demo = () => {
77
<ProCard layout="center" bordered colSpan={24} title="描述" subTitle="描述在标题右边">
88
<FieldTitle type={APIFieldType.bool} title="success" description="成功标识" />
99
</ProCard>
10-
<ProCard layout="center" bordered colSpan={24} title="额外" subTitle="额外内容在字段下面">
11-
<FieldTitle type={APIFieldType.bool} title="success" extra="额外内容" />
12-
</ProCard>
13-
<ProCard
14-
layout="center"
15-
bordered
16-
colSpan={24}
17-
title="可选"
18-
subTitle="可选为false 则额外内容左侧有 padding"
19-
>
20-
<FieldTitle type={APIFieldType.bool} title="success" extra="额外内容" checkable={false} />
21-
</ProCard>
2210
</ProCard>
2311
);
2412
};

src/FieldTitle/index.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ group: 基础组件
2121

2222
## API
2323

24-
| 参数 | 说明 | 类型 | 默认值 |
25-
| :------------ | :----------------------------- | :-------------------------------- | :----- |
26-
| type | 字段类型 | 参考 `FieldIcon` 字段类型类型枚举 | - |
27-
| isParentArray | 父级是否是数组 | boolean | - |
28-
| title | 字段标题 | `React.ReactNode` | - |
29-
| description | 标题右侧描述 | `React.ReactNode` | - |
30-
| extra | 额外内容 | `React.ReactNode` | - |
31-
| checkable | 是否可选,可选会添加 `padding` | `boolean` | true |
24+
| 参数 | 说明 | 类型 | 默认值 |
25+
| :------------ | :------------- | :-------------------------------- | :----- |
26+
| type | 字段类型 | 参考 `FieldIcon` 字段类型类型枚举 | - |
27+
| isParentArray | 父级是否是数组 | boolean | - |
28+
| title | 字段标题 | `React.ReactNode` | - |
29+
| description | 标题右侧描述 | `React.ReactNode` | - |

src/FieldTitle/index.tsx

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ export interface FieldTitleProps {
3333
* 标题右侧描述
3434
*/
3535
description?: React.ReactNode;
36-
/**
37-
* 额外内容
38-
*/
39-
extra?: React.ReactNode;
40-
/**
41-
* 是否可选
42-
*/
43-
checkable?: boolean;
4436
}
4537

4638
const FieldTitle: React.FC<FieldTitleProps> = (props) => {
@@ -52,12 +44,10 @@ const FieldTitle: React.FC<FieldTitleProps> = (props) => {
5244
isParentArray,
5345
title,
5446
description = null,
55-
extra = null,
56-
checkable = true,
5747
} = props;
5848

5949
const prefixCls = getPrefixCls('field-title', customizePrefixCls);
60-
const { styles } = useStyle({ prefixCls, checkable });
50+
const { styles } = useStyle({ prefixCls });
6151

6252
let finalType = type;
6353
if (finalType === 'boolean') {
@@ -67,14 +57,11 @@ const FieldTitle: React.FC<FieldTitleProps> = (props) => {
6757
finalType += 'Array';
6858
}
6959
return (
70-
<div className={classNames(prefixCls, className)} style={style}>
71-
<div className={styles.content}>
72-
{finalType ? <FieldIcon type={finalType} /> : null}
73-
{title ? <span className={styles.title}>{title}</span> : null}
74-
{description ? <span className={styles.description}>{description}</span> : null}
75-
</div>
76-
{extra ? <div className={styles.extra}>{extra}</div> : null}
77-
</div>
60+
<span className={classNames(prefixCls, className, styles.container)} style={style}>
61+
{finalType ? <FieldIcon type={finalType} /> : null}
62+
{title ? <span className={styles.title}>{title}</span> : null}
63+
{description ? <span className={styles.description}>{description}</span> : null}
64+
</span>
7865
);
7966
};
8067

src/FieldTitle/style.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { createStyles } from '../theme';
22

3-
export const useStyle = createStyles(({ token, css, cx }, { prefixCls, checkable }) => {
3+
export const useStyle = createStyles(({ token, css, cx }, { prefixCls }) => {
44
return {
5-
content: cx(
6-
`${prefixCls}-content`,
5+
container: cx(
6+
`${prefixCls}-container`,
77
css({
8-
display: 'flex',
8+
display: 'inline-flex',
99
alignItems: 'center',
1010
fontSize: token.fontSize,
1111
}),
@@ -22,11 +22,5 @@ export const useStyle = createStyles(({ token, css, cx }, { prefixCls, checkable
2222
marginLeft: token.marginXXS,
2323
}),
2424
),
25-
extra: cx(
26-
`${prefixCls}-extra`,
27-
css({
28-
paddingLeft: checkable ? token.paddingLG : undefined,
29-
}),
30-
),
3125
};
3226
});

0 commit comments

Comments
 (0)