Skip to content

Commit 32b1efb

Browse files
committed
fix: issues
1 parent 6fc02ef commit 32b1efb

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

src/components/ExpandableContributorList/LazyExpandableContributorsList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type Props = Omit<
1111
'cacheKey' | 'getComponent' | 'getComponentProps' | 'loader'
1212
>;
1313

14+
import './ExpandableContributorList.scss';
15+
1416
const b = block('expandable-contributor-list');
1517

1618
const getComponent = async () => {

src/components/IntersectionLoadComponent/IntersectionLoadComponent.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,11 @@ type Props<Component extends React.ComponentType> = {
1111
intersectionOptions?: IntersectionObserverInit;
1212
onIntersect?: () => void;
1313
onLoad?: NoInfer<(component: Component, props: React.ComponentProps<Component>) => void>;
14+
wrapperClassName?: string;
1415
};
1516

1617
const cache = new Map();
1718

18-
/**
19-
* HOC for lazy loading component when it reaches viewport
20-
* @param {string} cacheKey
21-
* @param {function(): Promise<Component>} getComponent component import function
22-
* @param {function(): Promise<React.ComponentProps<Component>>} getComponentProps async function for component props; async for loading data from server by demand
23-
* @param {IntersectionObserverInit} intersectionOptions IntersectionObserver options
24-
* @param {JSX.Element} loader displaying while component is being loaded
25-
* @param {function(): void} onIntersect callback, fires when component reaches viewport
26-
* @param {function(Component, React.ComponentProps<Component>): void} onLoad callback, fires when component is loaded
27-
* @returns {JSX.Element} loaded component or loader
28-
*/
29-
// unknown/{}/object doesn't work
30-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3119
export const IntersectionLoadComponent = <Component extends React.ComponentType<any>>({
3220
cacheKey,
3321
getComponent,
@@ -36,6 +24,7 @@ export const IntersectionLoadComponent = <Component extends React.ComponentType<
3624
intersectionOptions,
3725
onIntersect,
3826
onLoad,
27+
wrapperClassName,
3928
}: Props<Component>) => {
4029
const [waitingLoad, setWaitingLoad] = React.useState(!cache.has(cacheKey));
4130
const [intersectionElementRef, setIntersectionElementRef] =
@@ -73,21 +62,25 @@ export const IntersectionLoadComponent = <Component extends React.ComponentType<
7362
if (cache.has(cacheKey)) {
7463
const {Component, props} = cache.get(cacheKey);
7564

76-
return <Component key={cacheKey} {...props} />;
65+
return (
66+
<div className={wrapperClassName} key={cacheKey}>
67+
<Component {...props} />
68+
</div>
69+
);
7770
}
7871

7972
if (waitingLoad) {
8073
return (
81-
<div key={cacheKey}>
74+
<div className={wrapperClassName} key={cacheKey}>
8275
<div ref={setIntersectionElementRef} />
8376
{loader}
8477
</div>
8578
);
8679
}
8780

8881
return (
89-
<div key={cacheKey}>
90-
<React.Suspense fallback={loader}>
82+
<div className={wrapperClassName} key={cacheKey}>
83+
<React.Suspense key={cacheKey} fallback={loader}>
9184
<LazyComponent />
9285
</React.Suspense>
9386
</div>
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import {Loader} from '@gravity-ui/uikit';
12
import {IntersectionLoadComponent} from 'src/components/IntersectionLoadComponent/IntersectionLoadComponent';
3+
import {block} from 'src/utils';
24

3-
import {UISamplesLoader} from '../UISamplesLoader/UISamplesLoader';
5+
import './TablePreview.scss';
6+
7+
const b = block('table-preview');
48

59
const getComponent = async () => (await import('./TablePreview')).TablePreview;
610

@@ -9,7 +13,8 @@ export const LazyTablePreview: React.FC = () => {
913
<IntersectionLoadComponent
1014
cacheKey="TablePreview"
1115
getComponent={getComponent}
12-
loader={<UISamplesLoader />}
16+
loader={<Loader className={b('loader')} size="l" />}
17+
wrapperClassName={b('loader')}
1318
/>
1419
);
1520
};

src/components/UISamples/TablePreview/TablePreview.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ $block: '.#{variables.$ns}table-preview';
1616
overflow-x: auto;
1717
white-space: nowrap;
1818
}
19+
20+
&__loader {
21+
width: 100%;
22+
height: 100%;
23+
24+
display: flex;
25+
justify-content: center;
26+
align-items: center;
27+
}
1928
}

src/components/UISamples/UISamplesLoader/UISamplesLoader.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ $block: '.#{variables.$ns}uisamples-loader';
1010
display: flex;
1111
justify-content: center;
1212
align-items: center;
13+
14+
border: 1px solid var(--g-color-line-generic);
15+
border-radius: 16px;
1316
}

0 commit comments

Comments
 (0)