Skip to content

Commit

Permalink
feat: Modifying the DOM structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wanpan11 committed Aug 22, 2024
1 parent ff91951 commit 6f1011d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
10 changes: 5 additions & 5 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@
&-content {
overflow: hidden;
color: @text-color;
padding: 0 16px;
padding: 16px;
background-color: #fff;

& > &-box {
margin-top: 16px;
margin-bottom: 16px;
}
// & > &-box {
// margin-top: 16px;
// margin-bottom: 16px;
// }

// &-inactive {
// display: none;
Expand Down
11 changes: 4 additions & 7 deletions src/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,18 @@ const PanelContent = React.forwardRef<
ref={ref}
className={classnames(
`${prefixCls}-content`,
`${prefixCls}-content-box`,
{
[`${prefixCls}-content-active`]: isActive,
[`${prefixCls}-content-inactive`]: !isActive,
},
className,
customizeClassNames?.body,
)}
style={style}
style={{ ...style, ...styles?.body }}
role={role}
>
<div
className={classnames(`${prefixCls}-content-box`, customizeClassNames?.body)}
style={styles?.body}
>
{children}
</div>
{children}
</div>
);
});
Expand Down
10 changes: 5 additions & 5 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('collapse', () => {
fireEvent.click(header);
jest.runAllTimers();
expect(collapse.container.querySelector('.rc-collapse-content-inactive')?.innerHTML).toBe(
'<div class="rc-collapse-content-box">second</div>',
'second',
);
expect(collapse.container.querySelectorAll('.rc-collapse-content-active').length).toBeFalsy();
});
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('collapse', () => {
const { container } = render(element);
const header = container.querySelector('.rc-collapse-header');

expect(header.classList.contains('custom-class')).toBeTruthy();
expect(header?.classList.contains('custom-class')).toBeTruthy();
});
});

Expand Down Expand Up @@ -778,7 +778,7 @@ describe('collapse', () => {
]}
/>,
);
fireEvent.click(container.querySelector('.rc-collapse-header'));
fireEvent.click(container.querySelector('.rc-collapse-header')!);
expect(onItemClick).toHaveBeenCalled();
expect(onItemClick).lastCalledWith('0');
});
Expand All @@ -800,11 +800,11 @@ describe('collapse', () => {
/>,
);

fireEvent.click(container.querySelector('.rc-collapse-header'));
fireEvent.click(container.querySelector('.rc-collapse-header')!);
expect(onItemClick).not.toHaveBeenCalled();

fireEvent.click(
container.querySelector('.rc-collapse-item:nth-child(2) .rc-collapse-expand-icon'),
container.querySelector('.rc-collapse-item:nth-child(2) .rc-collapse-expand-icon')!,
);
expect(onItemClick).toHaveBeenCalled();
expect(onChangeFn).toBeCalledTimes(1);
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@
"rc-collapse": ["src/index.tsx"]
}
},
"include": [".dumirc.ts", "./src/**/*.ts", "./src/**/*.tsx", "./docs/**/*.tsx"]
"include": [
".dumirc.ts",
"./src/**/*.ts",
"./src/**/*.tsx",
"./tests/**/*.ts",
"./tests/**/*.tsx",
"./docs/**/*.tsx"
]
}

0 comments on commit 6f1011d

Please sign in to comment.