From 6f1011d4a0e13a98afb03bd728aa918b991934d7 Mon Sep 17 00:00:00 2001 From: Wanpan Date: Thu, 22 Aug 2024 10:47:40 +0800 Subject: [PATCH] feat: Modifying the DOM structure --- assets/index.less | 10 +++++----- src/PanelContent.tsx | 11 ++++------- tests/index.spec.tsx | 10 +++++----- tsconfig.json | 9 ++++++++- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/assets/index.less b/assets/index.less index 69f97a8..a8d4245 100644 --- a/assets/index.less +++ b/assets/index.less @@ -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; diff --git a/src/PanelContent.tsx b/src/PanelContent.tsx index 37bb031..ce0ed83 100644 --- a/src/PanelContent.tsx +++ b/src/PanelContent.tsx @@ -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} > -
- {children} -
+ {children} ); }); diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index 7304b98..7fa0e77 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -86,7 +86,7 @@ describe('collapse', () => { fireEvent.click(header); jest.runAllTimers(); expect(collapse.container.querySelector('.rc-collapse-content-inactive')?.innerHTML).toBe( - '
second
', + 'second', ); expect(collapse.container.querySelectorAll('.rc-collapse-content-active').length).toBeFalsy(); }); @@ -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(); }); }); @@ -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'); }); @@ -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); diff --git a/tsconfig.json b/tsconfig.json index bbd8b8b..bc68db4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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" + ] }