Skip to content

Commit d338ecc

Browse files
committed
refactor: rename DualScrollSync to DualScrollSyncBase and update exports for clarity
1 parent bf0b6be commit d338ecc

3 files changed

Lines changed: 25 additions & 27 deletions

File tree

lib/components/DualScrollSync/DualScrollSync.test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { render } from '@testing-library/react';
22

3-
import { DualScrollSync } from './DualScrollSync';
3+
import { DualScrollSyncBase } from './DualScrollSync';
44

55
describe('DualScrollSync', () => {
66
it('should render children correctly', () => {
77
const { getByTestId } = render(
8-
<DualScrollSync>
8+
<DualScrollSyncBase>
99
<div>Test Content</div>
10-
</DualScrollSync>
10+
</DualScrollSyncBase>
1111
);
1212

1313
expect(getByTestId('dual-scroll-sync')).toBeInTheDocument();
1414
});
1515

1616
it('should render with provided id', () => {
1717
const { getByTestId } = render(
18-
<DualScrollSync id="custom-id">
18+
<DualScrollSyncBase id="custom-id">
1919
<div>Test Content</div>
20-
</DualScrollSync>
20+
</DualScrollSyncBase>
2121
);
2222

2323
expect(getByTestId('custom-id')).toBeInTheDocument();
@@ -29,7 +29,7 @@ describe('DualScrollSync', () => {
2929
{ label: 'Item 2', sectionKey: 's2' }
3030
];
3131

32-
const { getByTestId } = render(<DualScrollSync items={items} id="test" />);
32+
const { getByTestId } = render(<DualScrollSyncBase items={items} id="test" />);
3333

3434
expect(getByTestId('test-nav-id')).toBeInTheDocument();
3535
expect(getByTestId('test-nav-id-item-s1')).toBeInTheDocument();
@@ -41,9 +41,9 @@ describe('DualScrollSync', () => {
4141

4242
it('should render children when items prop is not provided', () => {
4343
const { getByTestId, getByText } = render(
44-
<DualScrollSync id="test">
44+
<DualScrollSyncBase id="test">
4545
<h1 data-testid="child-heading">Child Heading</h1>
46-
</DualScrollSync>
46+
</DualScrollSyncBase>
4747
);
4848

4949
expect(getByTestId('test')).toBeInTheDocument();

lib/components/DualScrollSync/DualScrollSync.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@ import { DualScrollSyncContext } from '@/contexts';
66
import { useScrollSyncObserver, useValidateChildren } from '@/hooks';
77

88
import styles from './DualScrollSync.module.scss';
9-
import type { DualScrollSyncProps } from './DualScrollSync.types';
9+
import type { DualScrollSyncProps, DualScrollSyncType } from './DualScrollSync.types';
1010
import { DualScrollSyncContent } from './DualScrollSyncContent';
1111
import { DualScrollSyncContentSection } from './DualScrollSyncContentSection/DualScrollSyncContentSection';
1212
import { DualScrollSyncLabel } from './DualScrollSyncLabel/DualScrollSyncLabel';
1313
import { DualScrollSyncNav } from './DualScrollSyncNav';
1414
import { DualScrollSyncNavItem } from './DualScrollSyncNavItem';
1515

16-
export const DualScrollSync: FC<DualScrollSyncProps> = ({ children, id, items, onItemClick }) => {
16+
export const DualScrollSyncBase: FC<DualScrollSyncProps> = ({
17+
children,
18+
id,
19+
items,
20+
onItemClick
21+
}) => {
1722
const baseId = id ?? 'dual-scroll-sync';
1823
const navId = `${baseId}-nav`;
1924
const contentId = `${baseId}-content`;
@@ -80,4 +85,12 @@ export const DualScrollSync: FC<DualScrollSyncProps> = ({ children, id, items, o
8085
);
8186
};
8287

83-
DualScrollSync.displayName = 'DualScrollSync';
88+
DualScrollSyncBase.displayName = 'DualScrollSync';
89+
90+
export const DualScrollSync: DualScrollSyncType = Object.assign(DualScrollSyncBase, {
91+
Nav: DualScrollSyncNav,
92+
NavItem: DualScrollSyncNavItem,
93+
Content: DualScrollSyncContent,
94+
ContentSection: DualScrollSyncContentSection,
95+
Label: DualScrollSyncLabel
96+
});
Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
1-
import { DualScrollSync as DualScrollSyncBase } from './DualScrollSync';
2-
import type { DualScrollSyncType } from './DualScrollSync.types';
3-
import { DualScrollSyncContent } from './DualScrollSyncContent';
4-
import { DualScrollSyncContentSection } from './DualScrollSyncContentSection/DualScrollSyncContentSection';
5-
import { DualScrollSyncLabel } from './DualScrollSyncLabel';
6-
import { DualScrollSyncNav } from './DualScrollSyncNav';
7-
import { DualScrollSyncNavItem } from './DualScrollSyncNavItem';
8-
1+
export { DualScrollSync } from './DualScrollSync';
92
export type { DualScrollSyncItem, DualScrollSyncProps } from './DualScrollSync.types';
103
export type * from './DualScrollSyncContent';
114
export type * from './DualScrollSyncContentSection';
125
export type * from './DualScrollSyncNav';
136
export type * from './DualScrollSyncNavItem';
14-
15-
export const DualScrollSync: DualScrollSyncType = Object.assign(DualScrollSyncBase, {
16-
Nav: DualScrollSyncNav,
17-
NavItem: DualScrollSyncNavItem,
18-
Content: DualScrollSyncContent,
19-
ContentSection: DualScrollSyncContentSection,
20-
Label: DualScrollSyncLabel
21-
});

0 commit comments

Comments
 (0)