diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 72e5416..5e649ad 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -32,9 +32,10 @@ export const drawerWidth = 240; const Navbar: FC = () => { const [drawerIsOpen, setDrawerState] = useState(false); + const router = useRouter(); - const query = router.query["search_query"]; + const [search, setSearch] = useState(); const toggleDrawer = (open: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => { @@ -141,9 +142,20 @@ const Navbar: FC = () => { -
+ { + e.preventDefault(); + + router.push({ + pathname: "/results", + query: { search_query: search } + }); + }} + method="get" + > setSearch(e.target.value)} + value={search} name="search_query" placeholder="Search…" inputProps={{ "aria-label": "search" }} diff --git a/src/components/Video/Inline.tsx b/src/components/Video/Inline.tsx index 8646305..2644d0b 100644 --- a/src/components/Video/Inline.tsx +++ b/src/components/Video/Inline.tsx @@ -7,7 +7,9 @@ import Box from "@mui/material/Box"; import CircularProgress from "@mui/material/CircularProgress"; import Grid from "@mui/material/Grid"; import Paper from "@mui/material/Paper"; +import Tooltip from "@mui/material/Tooltip"; import Typography from "@mui/material/Typography"; +import { red } from "@mui/material/colors"; import { useTheme } from "@mui/material/styles"; import { abbreviateNumber } from "@src/utils/"; @@ -28,7 +30,22 @@ const Video: FC<{ video: VideoModel }> = ({ video }) => { return ( - + + {video.live && ( + + Live + + )} {/* eslint-disable-next-line @next/next/no-img-element */} = ({ video }) => { - - {video.title} - + + + {video.title} + + = ({ video }) => { variant="subtitle1" color={theme.palette.text.secondary} > - {abbreviateNumber(video.views)} Views • Published{" "} - {video.published.text} + {!(video.live || video.upcoming) && ( + <> + {abbreviateNumber(video.views)} Views • Published{" "} + {video.published.text} + + )} + {video.live && <>🔴 Live now} + {video.upcoming && video.premiereTimestamp && ( + <> + Premiering on{" "} + {new Date(video.premiereTimestamp * 1000).toLocaleDateString()}{" "} + at{" "} + {new Date(video.premiereTimestamp * 1000).toLocaleTimeString()} + + )} = (video) => { color={theme.palette.text.secondary} variant="body2" > - {abbreviateNumber(video.views)} Views • Published{" "} - {video.published.text} + {!(video.live || video.upcoming) && ( + <> + {abbreviateNumber(video.views)} Views • Published{" "} + {video.published.text} + + )} diff --git a/src/interfaces/api/search.ts b/src/interfaces/api/search.ts index 35b76e2..f35ef8d 100644 --- a/src/interfaces/api/search.ts +++ b/src/interfaces/api/search.ts @@ -31,6 +31,8 @@ export interface VideoResult extends Results { published: number; publishedText: string; lengthSeconds: number; + isUpcoming: boolean; + premiereTimestamp?: number; liveNow: boolean; premium: boolean; } diff --git a/src/interfaces/api/trending.ts b/src/interfaces/api/trending.ts index a1b6ddf..72495b7 100644 --- a/src/interfaces/api/trending.ts +++ b/src/interfaces/api/trending.ts @@ -17,6 +17,7 @@ interface Trending { liveNow: boolean; premium: boolean; isUpcoming: boolean; + premiereTimestamp?: number; } export default Trending; diff --git a/src/interfaces/video.ts b/src/interfaces/video.ts index c0ddd12..686e9a6 100644 --- a/src/interfaces/video.ts +++ b/src/interfaces/video.ts @@ -32,6 +32,8 @@ interface Video { }; subscriptions?: string; rating?: number; + upcoming?: boolean; + premiereTimestamp?: number; premiered?: Date; recommendedVideos?: RecommendedVideo[]; adaptiveFormats?: AdaptiveFormat[]; diff --git a/src/pages/results.tsx b/src/pages/results.tsx index 0b419fd..249ce58 100644 --- a/src/pages/results.tsx +++ b/src/pages/results.tsx @@ -4,13 +4,20 @@ import { NextPage } from "next"; import { NextSeo } from "next-seo"; import { useRouter } from "next/router"; +import { FC, useState } from "react"; + import { useQuery } from "react-query"; import axios from "axios"; +import Box from "@mui/material/Box"; +import Button from "@mui/material/Button"; import Container from "@mui/material/Container"; import Divider from "@mui/material/Divider"; import Typography from "@mui/material/Typography"; +import { useTheme } from "@mui/material/styles"; + +import Add from "@mui/icons-material/Add"; import Result, { CategoryResult, @@ -49,6 +56,50 @@ const Results: NextPage = () => { : undefined ); + const Category: FC<{ category: CategoryResult }> = ({ category }) => { + const initialCount = 3; + + const [count, setCount] = useState(initialCount); + + const shownVideos = category.contents.slice(0, count); + + return ( + <> + {category.title} + + {shownVideos.map((video, i) => ( +