Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 2 additions & 1 deletion src/TourStep/DefaultPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export default function DefaultPanel(props: DefaultPanelProps) {
onClick={onClose}
aria-label="Close"
{...ariaProps}
className={`${prefixCls}-close`}
className={classNames(`${prefixCls}-close`, tourClassNames?.close)}
style={styles?.close}

Choose a reason for hiding this comment

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

medium

While the implementation for applying custom className and style to the close button is correct, this pull request is missing corresponding tests to verify the new functionality. Please add a test case to ensure that tourClassNames.close and styles.close are applied as expected. You could extend the existing 'support custom styles' test in tests/index.test.tsx for this.

>
{closeIcon}
</button>
Expand Down
3 changes: 2 additions & 1 deletion src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export type SemanticName =
| 'header'
| 'title'
| 'description'
| 'mask';
| 'mask'
| 'close';


export type HTMLAriaDataAttributes = React.AriaAttributes & {
Expand Down
7 changes: 7 additions & 0 deletions tests/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,7 @@ describe('Tour', () => {
section: 'custom-section',
footer: 'custom-footer',
description: 'custom-description',
close: 'custom-close',
};
const customStyles = {
mask: { color: 'white' },
Expand All @@ -1136,6 +1137,7 @@ describe('Tour', () => {
section: { padding: '10px' },
footer: { borderTop: '1px solid black' },
description: { fontStyle: 'italic' },
close: { color: 'red' },
};
const Demo = () => {
const btnRef = useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -1178,6 +1180,9 @@ describe('Tour', () => {
const descriptionElement = document.querySelector(
'.rc-tour-description',
) as HTMLElement;
const closeElement = document.querySelector(
'.rc-tour-close',
) as HTMLElement;

// check classNames
expect(maskElement.classList).toContain('custom-mask');
Expand All @@ -1187,6 +1192,7 @@ describe('Tour', () => {
expect(sectionElement.classList).toContain('custom-section');
expect(footerElement.classList).toContain('custom-footer');
expect(descriptionElement.classList).toContain('custom-description');
expect(closeElement.classList).toContain('custom-close');

// check styles
expect(maskElement.style.color).toBe('white');
Expand All @@ -1196,6 +1202,7 @@ describe('Tour', () => {
expect(sectionElement.style.padding).toBe('10px');
expect(footerElement.style.borderTop).toBe('1px solid black');
expect(descriptionElement.style.fontStyle).toBe('italic');
expect(closeElement.style.color).toBe('red');
});

it('inline', async () => {
Expand Down
Loading