Skip to content

Commit d4307de

Browse files
authored
feat: blockHeader title support ReactNode (#431)
* feat: blockHeader title support ReactNode * ci: without eslint import sort
1 parent a8d98d7 commit d4307de

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"increase-memory-limit": "^1.0.7",
134134
"jest": "^24.9.0",
135135
"jest-environment-jsdom-sixteen": "^2.0.0",
136-
"ko-lint-config": "^2.2.18",
136+
"ko-lint-config": "2.2.19",
137137
"less": "^3.9.0",
138138
"less-loader": "^5.0.0",
139139
"lint-md": "^0.1.1",

src/components/blockHeader/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Tooltip } from 'antd';
44

55
export interface BlockHeaderProps {
66
// 标题
7-
title: string;
7+
title: React.ReactNode;
88
// 标题前的图标,默认是一个色块
99
beforeTitle?: React.ReactNode;
1010
// 标题后的提示图标或文案

src/stories/blockHeader.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ stories.addDecorator(withKnobs);
1010
const propDefinitions = [
1111
{
1212
property: 'title',
13-
propType: 'string',
13+
propType: 'React.ReactNode',
1414
required: true,
1515
description: '标题',
1616
defaultValue: '-',
@@ -136,6 +136,10 @@ stories.add(
136136
<BlockHeader title="分类标题" onChange={(expand) => console.log(expand)}>
137137
Hello World!
138138
</BlockHeader>
139+
<p style={style}>7、标题超长</p>
140+
<BlockHeader title={<EllipsisText maxWidth={400} value="标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长" />} />
141+
<br />
142+
139143
<h3>大标题 + 无背景</h3>
140144
<p style={style}>1、默认</p>
141145
<BlockHeader title="分类标题" showBackground={false} />
@@ -159,6 +163,7 @@ stories.add(
159163
>
160164
Hello World!
161165
</BlockHeader>
166+
162167
<h2>小标题</h2>
163168
<h3>小标题 + 有背景</h3>
164169
<p style={style}>1、默认</p>
@@ -183,6 +188,8 @@ stories.add(
183188
>
184189
Hello World!
185190
</BlockHeader>
191+
<br />
192+
186193
<h3>小标题 + 无背景</h3>
187194
<p style={style}>1、默认</p>
188195
<BlockHeader title="分类标题" showBackground={false} isSmall />

src/stories/components/blockHeader/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { PieChartOutlined } from '@ant-design/icons';
33
import BlockHeader from '../../../components/blockHeader';
4+
import EllipsisText from '../../../components/ellipsisText';
45

56
export default function BlockHeaderRender() {
67
const style = {
@@ -28,6 +29,10 @@ export default function BlockHeaderRender() {
2829
<BlockHeader title="分类标题" onChange={(expand) => console.log(expand)}>
2930
Hello World!
3031
</BlockHeader>
32+
<p style={style}>7、标题超长</p>
33+
<BlockHeader title={<EllipsisText maxWidth={400} value="标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长标题超长" />} />
34+
<br />
35+
3136
<h3>大标题 + 无背景</h3>
3237
<p style={style}>1、默认</p>
3338
<BlockHeader title="分类标题" showBackground={false} />
@@ -51,6 +56,7 @@ export default function BlockHeaderRender() {
5156
>
5257
Hello World!
5358
</BlockHeader>
59+
5460
<h2>小标题</h2>
5561
<h3>小标题 + 有背景</h3>
5662
<p style={style}>1、默认</p>
@@ -71,6 +77,8 @@ export default function BlockHeaderRender() {
7177
<BlockHeader title="分类标题" isSmall onChange={(expand) => console.log(expand)}>
7278
Hello World!
7379
</BlockHeader>
80+
<br />
81+
7482
<h3>小标题 + 无背景</h3>
7583
<p style={style}>1、默认</p>
7684
<BlockHeader title="分类标题" showBackground={false} isSmall />

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12820,10 +12820,10 @@ known-css-properties@^0.25.0:
1282012820
resolved "https://registry.yarnpkg.com/known-css-properties/-/known-css-properties-0.25.0.tgz#6ebc4d4b412f602e5cfbeb4086bd544e34c0a776"
1282112821
integrity sha512-b0/9J1O9Jcyik1GC6KC42hJ41jKwdO/Mq8Mdo5sYN+IuRTXs2YFHZC3kZSx6ueusqa95x3wLYe/ytKjbAfGixA==
1282212822

12823-
ko-lint-config@^2.2.18:
12824-
version "2.2.18"
12825-
resolved "https://registry.yarnpkg.com/ko-lint-config/-/ko-lint-config-2.2.18.tgz#ea61ef0a89a4e23b478b0390e69a715cdf08280a"
12826-
integrity sha512-ls5jymX9GjE8atROtwyoIpsOvjYSlXvHwoHH1sZqvJfrS5xHiy+zBe2KP67O1VNudRnIGyJb9J2QqkRdZyCSXA==
12823+
12824+
version "2.2.19"
12825+
resolved "https://registry.npmmirror.com/ko-lint-config/-/ko-lint-config-2.2.19.tgz#23141b8d8bbbb155b4f6113f894df5e5ea9a0741"
12826+
integrity sha512-EMdRaxNXXFe90Q2JQNIJeHSRMn1y5LKNrrGVTwRVWvk/jnP3UQ411K4petpATbgkjU36YEDBa6Y3LVXk8asB+Q==
1282712827
dependencies:
1282812828
"@typescript-eslint/eslint-plugin" "5.30.0"
1282912829
"@typescript-eslint/parser" "5.30.0"

0 commit comments

Comments
 (0)