/** * External dependencies */ import { Button, Text, useBreakpointMatch } from '@automattic/jetpack-components'; import { createInterpolateElement } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { grid, formatListBullets } from '@wordpress/icons'; import classnames from 'classnames'; import React, { useState } from 'react'; import { useHistory } from 'react-router-dom'; /** * Internal dependencies */ import useVideos from '../../hooks/use-videos'; import { SearchInput } from '../input'; import { ConnectLocalPagination, ConnectPagination } from '../pagination'; import { FilterButton, ConnectFilterSection } from '../video-filter'; import VideoGrid from '../video-grid'; import VideoList, { LocalVideoList } from '../video-list'; import styles from './styles.module.scss'; /** * Types */ import { LocalLibraryProps, VideoLibraryProps } from './types'; const LIBRARY_TYPE_LOCALSORAGE_KEY = 'videopress-library-type'; const LibraryType = { List: 'list', Grid: 'grid', } as const; type LibraryType = typeof LibraryType[ keyof typeof LibraryType ]; const VideoLibraryWrapper = ( { children, totalVideos = 0, libraryType = LibraryType.List, onChangeType, hideFilter = false, title, disabled, }: { children: React.ReactNode; libraryType?: LibraryType; totalVideos?: number; onChangeType?: () => void; hideFilter?: boolean; title?: string; disabled?: boolean; } ) => { const { setSearch, search, isFetching } = useVideos(); const [ searchQuery, setSearchQuery ] = useState( search ); const [ isLg ] = useBreakpointMatch( 'lg' ); const [ isFilterActive, setIsFilterActive ] = useState( false ); const singularTotalVideosLabel = __( '1 Video', 'jetpack-videopress-pkg' ); const pluralTotalVideosLabel = sprintf( /* translators: placeholder is the number of videos */ __( '%s Videos', 'jetpack-videopress-pkg' ), totalVideos ); const totalVideosLabel = totalVideos === 1 ? singularTotalVideosLabel : pluralTotalVideosLabel; return (