Skip to content

fix(blockheader): change some review comment and different font-size #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/blockHeader/__tests__/blockHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
test('should render BlockHeader props default in BlockHeader', () => {
const { container } = render(<BlockHeader title="测试" background />);
const wrap = container.firstChild;
expect(wrap!.firstChild!.firstChild!.firstChild).toHaveClass('title__addon-before');

Check warning on line 48 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion

Check warning on line 48 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion

Check warning on line 48 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
fireEvent.click(document.getElementsByClassName(`${prefixCls}__title`)[0]);
});
test('should render BlockHeader test click event', () => {
Expand Down Expand Up @@ -79,16 +79,19 @@
expect(getByText('说明文字')).toHaveClass('title__description');
expect(getByText('Icon')).toBeTruthy();
});
test('should render BlockHeader background success', () => {
test('should render BlockHeader background false success', () => {
const props = { title: '测试1', background: false };
const { container } = render(<BlockHeader {...props} />);
const wrap = container.firstChild;
expect(wrap!.firstChild).not.toHaveClass(`background`);
expect(wrap!.firstChild).not.toHaveClass(`dtc-block-header__title--background`);

Check warning on line 86 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
});
test('should render BlockHeader className when isSmall is small', () => {
test('should render BlockHeader className when size is small', () => {
const { container, getByText } = render(<BlockHeader {...props2} />);
const wrap = container.firstChild!;

Check warning on line 90 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
expect(wrap).toHaveClass(`${prefixCls} test__className`);
expect(wrap.firstChild).toHaveClass(
`dtc-block-header__title dtc-block-header__title--small dtc-block-header__title--background`
);
expect(getByText('标题2')).toHaveClass('title__text');
expect(getByText('说明文字')).toHaveClass('title__description');
expect(getByText('Icon')).toBeTruthy();
Expand All @@ -96,17 +99,18 @@

test('should render BlockHeader tooltip success', () => {
const { container } = render(<BlockHeader {...props3} />);
const wrap = container.firstChild!;

Check warning on line 102 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
const afterTitleWrap = wrap.firstChild!.firstChild!.lastChild;
expect(afterTitleWrap!.firstChild).toHaveClass('anticon-question-circle');
const tooltipWrap = wrap.firstChild!.firstChild!.lastChild;

Check warning on line 103 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion

Check warning on line 103 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
expect(tooltipWrap!.firstChild).toHaveClass('anticon-question-circle');

Check warning on line 104 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
});

test('should render BlockHeader tooltip and desc success', () => {
test('should render BlockHeader description success', () => {
const { container } = render(<BlockHeader {...props4} />);
const wrap = container.firstChild!;

Check warning on line 109 in src/blockHeader/__tests__/blockHeader.test.tsx

View workflow job for this annotation

GitHub Actions / setup

Forbidden non-null assertion
const afterTitleWrap = wrap.firstChild!.firstChild!.lastChild;
expect(afterTitleWrap).toHaveTextContent('说明文字');
const description = wrap.firstChild!.firstChild!.lastChild;
expect(description).toHaveTextContent('说明文字');
});

test('should render BlockHeader correct dom length', () => {
const { container } = render(<BlockHeader title="分类级别" addonBefore="" />);
const titleBoxWrap = container.firstChild!.firstChild!.firstChild;
Expand All @@ -118,6 +122,7 @@
const titleBoxWrap1 = container1.firstChild!.firstChild!.firstChild;
expect(titleBoxWrap1!.childNodes.length).toEqual(3);
});

test('should render BlockHeader correct margin-bottom', () => {
const { container: noStyle } = render(<BlockHeader title="分类级别" addonBefore="" />);
expect(noStyle.querySelector('.dtc-block-header')).not.toHaveAttribute('style');
Expand Down
4 changes: 2 additions & 2 deletions src/blockHeader/demos/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default () => {
size={size}
title="分类标题"
background={showBackground}
tooltip={tooltip && '这里展示问号提示'}
description={description && '提示说明文字'}
tooltip={tooltip ? '这里展示问号提示' : ''}
description={description ? '提示说明文字' : ''}
/>
</div>
);
Expand Down
12 changes: 6 additions & 6 deletions src/blockHeader/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ $card_prefix: "dtc-block-header";
align-items: center;
justify-content: space-between;
&--large {
.#{$card_prefix}-title-box {
.title__box {
line-height: 24px;
.#{$card_prefix}-title {
.title__text {
font-size: 16px;
}
}
}
&--middle {
.#{$card_prefix}-title-box {
.title__box {
line-height: 22px;
.#{$card_prefix}-title {
.title__text {
font-size: 14px;
}
}
}
&--small {
.#{$card_prefix}-title-box {
.title__box {
line-height: 20px;
.#{$card_prefix}-title {
.title__text {
font-size: 12px;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/copy/demos/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default () => {
<p>{text}</p>
</div>
<div>
<BlockHeader title={`使用 ()=>React.ReactNode`} background={false} size="small" />
<Copy text={text} tooltip={() => `使用 ()=>React.ReactNode,复制该文本`} />
<BlockHeader title={`使用 () => React.ReactNode`} background={false} size="small" />
<Copy text={text} tooltip={() => `使用 () => React.ReactNode,复制该文本`} />
<p>{text}</p>
</div>
</Space>
Expand Down
Loading