Skip to content

Commit a6ebfdb

Browse files
committed
feat(styles): add support for custom className and style in DualScrollSyncBase component
1 parent ce3f9c0 commit a6ebfdb

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

lib/components/DualScrollSync/DualScrollSync.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,17 @@ describe('DualScrollSync', () => {
4949
expect(getByTestId('test')).toBeInTheDocument();
5050
expect(getByText('Child Heading')).toBeInTheDocument();
5151
});
52+
53+
it('should apply custom className and style', () => {
54+
const { getByTestId } = render(
55+
<DualScrollSyncBase id="test" className="custom-class" style={{ borderWidth: '1px' }}>
56+
Styled Nav
57+
</DualScrollSyncBase>
58+
);
59+
60+
const label = getByTestId('test');
61+
62+
expect(label).toHaveClass('custom-class');
63+
expect(label).toHaveStyle('border-width: 1px');
64+
});
5265
});

lib/components/DualScrollSync/DualScrollSync.tsx

Lines changed: 10 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
import { useMemo } from 'react';
34

@@ -15,9 +16,11 @@ import { DualScrollSyncNavItem } from './DualScrollSyncNavItem';
1516

1617
export const DualScrollSyncBase: FC<DualScrollSyncProps> = ({
1718
children,
19+
className,
1820
id,
1921
items,
20-
onItemClick
22+
onItemClick,
23+
style = {}
2124
}) => {
2225
const baseId = id ?? 'dual-scroll-sync';
2326
const navId = `${baseId}-nav`;
@@ -57,7 +60,12 @@ export const DualScrollSyncBase: FC<DualScrollSyncProps> = ({
5760

5861
return (
5962
<DualScrollSyncContext.Provider value={value}>
60-
<section id={baseId} data-testid={baseId} className={styles.scrollSync}>
63+
<section
64+
className={clsx(styles.scrollSync, className)}
65+
data-testid={baseId}
66+
id={baseId}
67+
style={style}
68+
>
6169
{items ? (
6270
<>
6371
<DualScrollSyncNav>

0 commit comments

Comments
 (0)