Skip to content
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

refactor: update content to panel #359

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ const PanelContent = React.forwardRef<
ref={ref}
className={classnames(
`${prefixCls}-content`,
customizeClassNames?.content,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

顺序不太对,应该全部都是:

  • section
    • header
      • title
      • extra
    • body
      • content
    • footer

{
[`${prefixCls}-content-active`]: isActive,
[`${prefixCls}-content-inactive`]: !isActive,
},
className,
)}
style={style}
style={{ ...style, ...styles?.content }}
role={role}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface CollapseProps {
items?: ItemType[];
}

export type SemanticName = 'header' | 'title' | 'body' | 'icon';
export type SemanticName = 'header' | 'title' | 'body' | 'icon' | 'content';
export interface CollapsePanelProps extends React.DOMAttributes<HTMLDivElement> {
id?: string;
header?: string | React.ReactNode;
Expand Down
5 changes: 5 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -866,12 +866,14 @@ describe('collapse', () => {
body: { color: 'blue' },
title: { color: 'green' },
icon: { color: 'yellow' },
content: { color: 'purple' },
};
const customClassnames = {
header: 'custom-header',
body: 'custom-body',
title: 'custom-title',
icon: 'custom-icon',
content: 'custom-content',
};

const { container } = render(
Expand All @@ -889,18 +891,21 @@ describe('collapse', () => {
);
const headerElement = container.querySelector('.rc-collapse-header') as HTMLElement;
const bodyElement = container.querySelector('.rc-collapse-body') as HTMLElement;
const contentElement = container.querySelector('.rc-collapse-content') as HTMLElement;
const titleElement = container.querySelector('.rc-collapse-title') as HTMLElement;
const iconElement = container.querySelector('.rc-collapse-expand-icon') as HTMLElement;

// check classNames
expect(headerElement.classList).toContain('custom-header');
expect(bodyElement.classList).toContain('custom-body');
expect(contentElement.classList).toContain('custom-content');
expect(titleElement.classList).toContain('custom-title');
expect(iconElement.classList).toContain('custom-icon');

// check styles
expect(headerElement.style.color).toBe('red');
expect(bodyElement.style.color).toBe('blue');
expect(contentElement.style.color).toBe('purple');
expect(titleElement.style.color).toBe('green');
expect(iconElement.style.color).toBe('yellow');
});
Expand Down
Loading