mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
splitting SuggestionsView component
This commit is contained in:
parent
f4b878bea2
commit
7543e494c9
12 changed files with 311 additions and 187 deletions
62
src/view/components/ResumableItemsContainer.tsx
Normal file
62
src/view/components/ResumableItemsContainer.tsx
Normal file
|
@ -0,0 +1,62 @@
|
|||
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||
|
||||
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
||||
|
||||
import cardBuilder from '../../components/cardbuilder/cardBuilder';
|
||||
import globalize from '../../scripts/globalize';
|
||||
import ItemsContainerElement from '../../elements/ItemsContainerElement';
|
||||
|
||||
type ResumableItemsContainerProps = {
|
||||
getThumbShape: () => string;
|
||||
enableScrollX: () => boolean;
|
||||
itemsResult?: BaseItemDtoQueryResult;
|
||||
}
|
||||
|
||||
const ResumableItemsContainer: FunctionComponent<ResumableItemsContainerProps> = ({ getThumbShape, enableScrollX, itemsResult = {} }: ResumableItemsContainerProps) => {
|
||||
const element = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const section = element.current?.querySelector('#resumableSection') as HTMLDivElement;
|
||||
if (itemsResult.Items?.length) {
|
||||
section.classList.remove('hide');
|
||||
} else {
|
||||
section.classList.add('hide');
|
||||
}
|
||||
|
||||
const allowBottomPadding = !enableScrollX();
|
||||
const container = element.current?.querySelector('#resumableItems') as HTMLDivElement;
|
||||
cardBuilder.buildCards(itemsResult.Items || [], {
|
||||
itemsContainer: container,
|
||||
preferThumb: true,
|
||||
shape: getThumbShape(),
|
||||
scalable: true,
|
||||
overlayPlayButton: true,
|
||||
allowBottomPadding: allowBottomPadding,
|
||||
cardLayout: false,
|
||||
showTitle: true,
|
||||
showYear: true,
|
||||
centerText: true
|
||||
});
|
||||
}, [enableScrollX, getThumbShape, itemsResult.Items]);
|
||||
|
||||
return (
|
||||
<div ref={element}>
|
||||
<div id='resumableSection' className='verticalSection hide'>
|
||||
<div className='sectionTitleContainer sectionTitleContainer-cards'>
|
||||
<h2 className='sectionTitle sectionTitle-cards padded-left'>
|
||||
{globalize.translate('HeaderContinueWatching')}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<ItemsContainerElement
|
||||
id='resumableItems'
|
||||
className='itemsContainer padded-left padded-right'
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ResumableItemsContainer;
|
Loading…
Add table
Add a link
Reference in a new issue