import React, {Fragment, ReactNode} from 'react'; import clsx from 'clsx'; import {Channel} from '@common/channels/channel'; import {FilterList} from '@common/datatable/filters/filter-list/filter-list'; import {AnimatePresence, m} from 'framer-motion'; import {opacityAnimation} from '@common/ui/animation/opacity-animation'; import {useBackendFilterUrlParams} from '@common/datatable/filters/backend-filter-url-params'; import {MOVIE_MODEL, SERIES_MODEL, TITLE_MODEL} from '@app/titles/models/title'; import {ChannelSortButton} from '@app/channels/channel-header/channel-sort-button'; import {AddFilterButton} from '@common/datatable/filters/add-filter-button'; import {TuneIcon} from '@common/icons/material/Tune'; import {SiteSectionHeading} from '@app/titles/site-section-heading'; import {Trans} from '@common/i18n/trans'; import {useParams} from 'react-router-dom'; import {ChannelLayoutButton} from '@app/channels/channel-header/channel-layout-button'; import {useTitleIndexFilters} from '@app/titles/use-title-index-filters'; import {FilterListSkeleton} from '@common/datatable/filters/filter-list/filter-list-skeleton'; import {UserListByline} from '@app/user-lists/user-list-byline'; import {UserListDetails} from '@app/user-lists/user-list-details'; const FilterModelTypes = [TITLE_MODEL, MOVIE_MODEL, SERIES_MODEL]; interface Props { channel: Channel; margin?: string; isNested: boolean; actions?: ReactNode; } export function ChannelHeader({ channel, isNested, actions, margin = isNested ? 'mb-16 md:mb-30' : 'mb-20 md:mb-40', }: Props) { const shouldShowFilterButton = !isNested && FilterModelTypes.includes(channel.config.contentModel) && channel.config.contentType === 'listAll'; const {encodedFilters} = useBackendFilterUrlParams(); const {filters, filtersLoading} = useTitleIndexFilters({ disabled: !shouldShowFilterButton, }); if (channel.config.hideTitle) { return null; } return (
{actions} {!isNested && } {shouldShowFilterButton && ( } color={null} variant="text" disabled={filtersLoading} filters={filters} /> )} {!isNested && } } /> {shouldShowFilterButton && (
{filtersLoading && encodedFilters ? ( ) : ( )}
)}
); } interface ChannelTitleProps { channel: Channel; isNested: boolean; actions?: ReactNode; } function ChannelTitle({channel, isNested, actions}: ChannelTitleProps) { const {restriction: urlParam} = useParams(); if (channel.config.hideTitle) { return null; } const link = channel.config.restriction && urlParam ? `/${channel.slug}/${urlParam}` : `/${channel.slug}`; return ( } actions={actions} headingType={isNested ? 'h2' : 'h1'} descriptionFontSize={isNested ? 'text-sm' : undefined} fontWeight={isNested ? 'font-normal' : undefined} link={isNested ? link : undefined} > ); } interface ChannelDescriptionProps { channel: Channel; } function ChannelDescription({channel}: ChannelDescriptionProps) { if (channel.type === 'channel') { return {channel.description}; } return (
{channel.user && }
); }