Skip to content

Commit f082c49

Browse files
committed
feat(styles): enhance DualScrollSyncContentSection to support custom className and style props
1 parent 94c4bbf commit f082c49

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

lib/components/DualScrollSync/DualScrollSyncContentSection/DualScrollSyncContentSection.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,21 @@ describe('DualScrollSyncContentSection', () => {
2020
expect(contentSection).toBeInTheDocument();
2121
expect(getByText('Test Content')).toBeInTheDocument();
2222
});
23+
24+
it('should apply custom className and style', () => {
25+
const { getByTestId } = render(
26+
<DualScrollSyncContentSection
27+
sectionKey="styled-section"
28+
className="custom-class"
29+
style={{ borderWidth: '1px' }}
30+
>
31+
<div>Styled Content</div>
32+
</DualScrollSyncContentSection>
33+
);
34+
35+
const contentSection = getByTestId('test-content-id-section-styled-section');
36+
37+
expect(contentSection).toHaveClass('custom-class');
38+
expect(contentSection).toHaveStyle({ borderWidth: '1px' });
39+
});
2340
});

lib/components/DualScrollSync/DualScrollSyncContentSection/DualScrollSyncContentSection.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import clsx from 'clsx';
12
import type { FC } from 'react';
23

34
import { useDualScrollSyncContext } from '@/hooks';
@@ -6,23 +7,26 @@ import styles from './DualScrollSyncContentSection.module.scss';
67
import type { DualScrollSyncContentSectionProps } from './DualScrollSyncContentSection.types';
78

89
export const DualScrollSyncContentSection: FC<DualScrollSyncContentSectionProps> = ({
10+
children,
11+
className,
912
sectionKey,
10-
children
13+
style = {}
1114
}) => {
1215
const { contentId, sectionRefs } = useDualScrollSyncContext();
1316

1417
const contentSectionId = `${contentId}-section-${sectionKey}`;
1518

1619
return (
1720
<article
18-
className={styles.scrollSyncContentSection}
21+
className={clsx(styles.scrollSyncContentSection, className)}
1922
data-section={sectionKey}
2023
data-testid={contentSectionId}
2124
id={contentSectionId}
2225
ref={(contentRef) => {
2326
if (!contentRef) return;
2427
sectionRefs.current[sectionKey] = contentRef;
2528
}}
29+
style={style}
2630
>
2731
{children}
2832
</article>

0 commit comments

Comments
 (0)