Skip to content

Commit 3e1a2be

Browse files
authored
feat(blockheader): remove hasBottom replace by spaceBottom (#564)
fix #563
1 parent 5a3a465 commit 3e1a2be

File tree

6 files changed

+7
-15
lines changed

6 files changed

+7
-15
lines changed

src/blockHeader/__tests__/__snapshots__/blockHeader.test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`test BlockHeader render should render BlockHeader success render 1`] =
77
<div>
88
<div
99
class="dtc-block-header"
10+
style="margin-bottom: 16px;"
1011
>
1112
<div
1213
class="dtc-block-header__title dtc-block-header__title--middle dtc-block-header__title--background"
@@ -34,6 +35,7 @@ exports[`test BlockHeader render should render BlockHeader success render 1`] =
3435
"container": <div>
3536
<div
3637
class="dtc-block-header"
38+
style="margin-bottom: 16px;"
3739
>
3840
<div
3941
class="dtc-block-header__title dtc-block-header__title--middle dtc-block-header__title--background"

src/blockHeader/__tests__/blockHeader.test.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const props2: IBlockHeaderProps = {
1515
size: 'small' as SizeType,
1616
className: 'test__className',
1717
style: { height: '100px' },
18-
hasBottom: true,
1918
};
2019
const props3: IBlockHeaderProps = {
2120
title: 'hover',
@@ -124,14 +123,14 @@ describe('test BlockHeader render', () => {
124123
});
125124

126125
test('should render BlockHeader correct margin-bottom', () => {
127-
const { container: noStyle } = render(<BlockHeader title="分类级别" addonBefore="" />);
128-
expect(noStyle.querySelector('.dtc-block-header')).not.toHaveAttribute('style');
126+
const { container: haveStyle } = render(<BlockHeader title="分类级别" addonBefore="" />);
127+
expect(haveStyle.querySelector('.dtc-block-header')).toHaveAttribute('style');
129128
const { container: defaultBottom } = render(
130129
<BlockHeader title="分类级别" addonBefore="" />
131130
);
132131
expect(defaultBottom.querySelector('.dtc-block-header')).toHaveStyle({ marginBottom: 16 });
133132
const { container: customizeBottom } = render(
134-
<BlockHeader title="分类级别" addonBefore="" hasBottom spaceBottom={10} />
133+
<BlockHeader title="分类级别" addonBefore="" spaceBottom={10} />
135134
);
136135
expect(customizeBottom.querySelector('.dtc-block-header')).toHaveStyle({
137136
marginBottom: 10,

src/blockHeader/demos/addonBefore.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ export default () => {
66
return (
77
<>
88
<BlockHeader title="分类标题" />
9-
<br />
109
<BlockHeader title="分类标题" addonBefore={''} />
11-
<br />
1210
<BlockHeader title="分类标题" addonBefore={<PieChartOutlined />} />
13-
<br />
1411
<BlockHeader title="分类标题" addonBefore={<PauseCircleOutlined />} />
1512
</>
1613
);

src/blockHeader/demos/basic.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export default () => {
4444
<BlockHeader
4545
size={size}
4646
title="分类标题"
47-
hasBottom
4847
addonBefore={<PieChartOutlined />}
4948
background={showBackground}
5049
tooltip={tooltip ? '这里展示问号提示' : ''}

src/blockHeader/index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ demo:
3838
| background | 是否显示背景 | `boolean` | `true` |
3939
| expand | 当前展开状态 | `boolean` | |
4040
| defaultExpand | 是否默认展开内容 | `boolean` | `true` |
41-
| hasBottom | 是否有默认下边距 16px | `boolean` | `false` |
42-
| spaceBottom | 自定义下边距,优先级高于 hasBottom | `number` | `0` |
41+
| spaceBottom | 自定义下边距,优先级高于 hasBottom | `number` | `16` |
4342
| children | 展开/收起的内容 | `React.ReactNode` | - |
4443
| onExpand | 展开/收起时的回调 | `(expand: boolean) => void` | - |

src/blockHeader/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ export interface IBlockHeaderProps {
3030
* 默认 中标题
3131
*/
3232
size?: SizeType;
33-
/** 是否展示 Bottom,默认 false,Bottom 值 16px */
34-
hasBottom?: boolean;
3533
/** 自定义 Bottom 值 */
3634
spaceBottom?: number;
3735
/** 标题一行的样式类名 */
@@ -59,8 +57,7 @@ const BlockHeader: React.FC<IBlockHeaderProps> = function (props) {
5957
description = '',
6058
tooltip,
6159
size = 'middle',
62-
hasBottom = false,
63-
spaceBottom = 0,
60+
spaceBottom = 16,
6461
className = '',
6562
style = {},
6663
background = true,
@@ -79,7 +76,6 @@ const BlockHeader: React.FC<IBlockHeaderProps> = function (props) {
7976
const tooltipProps = toTooltipProps(tooltip);
8077

8178
let bottomStyle;
82-
if (hasBottom) bottomStyle = { marginBottom: 16 };
8379
if (spaceBottom) bottomStyle = { marginBottom: spaceBottom };
8480

8581
const handleExpand = (expand: boolean) => {

0 commit comments

Comments
 (0)