mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
Format code
This commit is contained in:
parent
ca41ddb271
commit
03b05dfc87
@ -61,7 +61,13 @@ export const EpisodeLine = ({ episode, sx }: { episode?: Episode; sx?: SxProps }
|
|||||||
<Typography variant="overline" align="center" sx={{ width: "4rem", flexShrink: 0 }}>
|
<Typography variant="overline" align="center" sx={{ width: "4rem", flexShrink: 0 }}>
|
||||||
{episode ? displayNumber(episode) : <Skeleton />}
|
{episode ? displayNumber(episode) : <Skeleton />}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Image img={episode?.thumbnail} alt="" width="18%" aspectRatio="16/9" sx={{ flexShrink: 0 }} />
|
<Image
|
||||||
|
img={episode?.thumbnail}
|
||||||
|
alt=""
|
||||||
|
width="18%"
|
||||||
|
aspectRatio="16/9"
|
||||||
|
sx={{ flexShrink: 0 }}
|
||||||
|
/>
|
||||||
{episode ? (
|
{episode ? (
|
||||||
<Box sx={{ flexGrow: 1 }}>
|
<Box sx={{ flexGrow: 1 }}>
|
||||||
<Typography variant="h6">{episode.name ?? t("show.episodeNoMetadata")}</Typography>
|
<Typography variant="h6">{episode.name ?? t("show.episodeNoMetadata")}</Typography>
|
||||||
|
@ -22,7 +22,7 @@ import { Alert, Box, Snackbar, SnackbarCloseReason, Typography, SxProps } from "
|
|||||||
import { SyntheticEvent, useState } from "react";
|
import { SyntheticEvent, useState } from "react";
|
||||||
import { KyooErrors } from "~/models";
|
import { KyooErrors } from "~/models";
|
||||||
|
|
||||||
export const ErrorComponent = ({ errors, sx }: { errors: string[], sx?: SxProps }) => {
|
export const ErrorComponent = ({ errors, sx }: { errors: string[]; sx?: SxProps }) => {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -32,10 +32,12 @@ export const ErrorComponent = ({ errors, sx }: { errors: string[], sx?: SxProps
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
backgroundColor: "error.light",
|
backgroundColor: "error.light",
|
||||||
...sx
|
...sx,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Typography variant="h1" component="h1" sx={{ fontWeight: 500 }}>Error</Typography>
|
<Typography variant="h1" component="h1" sx={{ fontWeight: 500 }}>
|
||||||
|
Error
|
||||||
|
</Typography>
|
||||||
{errors.map((x, i) => (
|
{errors.map((x, i) => (
|
||||||
<Typography variant="h2" component="h2" key={i}>
|
<Typography variant="h2" component="h2" key={i}>
|
||||||
{x}
|
{x}
|
||||||
|
@ -24,7 +24,15 @@ import { ReactNode, useRef } from "react";
|
|||||||
import { Container } from "./container";
|
import { Container } from "./container";
|
||||||
import useTranslation from "next-translate/useTranslation";
|
import useTranslation from "next-translate/useTranslation";
|
||||||
|
|
||||||
export const HorizontalList = ({ title, noContent, children }: { title: string, noContent: string, children: ReactNode[] }) => {
|
export const HorizontalList = ({
|
||||||
|
title,
|
||||||
|
noContent,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
title: string;
|
||||||
|
noContent: string;
|
||||||
|
children: ReactNode[];
|
||||||
|
}) => {
|
||||||
const { t } = useTranslation("browse");
|
const { t } = useTranslation("browse");
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const getScrollSize = () => {
|
const getScrollSize = () => {
|
||||||
@ -47,12 +55,18 @@ export const HorizontalList = ({ title, noContent, children }: { title: string,
|
|||||||
</Typography>
|
</Typography>
|
||||||
<Box>
|
<Box>
|
||||||
<Tooltip title={t("misc.prev-page")}>
|
<Tooltip title={t("misc.prev-page")}>
|
||||||
<IconButton aria-label={t("misc.prev-page")} onClick={() => ref.current?.scrollBy({ left: -getScrollSize(), behavior: "smooth" })}>
|
<IconButton
|
||||||
|
aria-label={t("misc.prev-page")}
|
||||||
|
onClick={() => ref.current?.scrollBy({ left: -getScrollSize(), behavior: "smooth" })}
|
||||||
|
>
|
||||||
<ArrowLeft />
|
<ArrowLeft />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip title={t("misc.next-page")}>
|
<Tooltip title={t("misc.next-page")}>
|
||||||
<IconButton aria-label={t("misc.next-page")} onClick={() => ref.current?.scrollBy({ left: getScrollSize(), behavior: "smooth" })}>
|
<IconButton
|
||||||
|
aria-label={t("misc.next-page")}
|
||||||
|
onClick={() => ref.current?.scrollBy({ left: getScrollSize(), behavior: "smooth" })}
|
||||||
|
>
|
||||||
<ArrowRight />
|
<ArrowRight />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -80,4 +94,4 @@ export const HorizontalList = ({ title, noContent, children }: { title: string,
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
@ -63,7 +63,7 @@ const KyooTitle = (props: { sx: SxProps<Theme> }) => {
|
|||||||
mr: 2,
|
mr: 2,
|
||||||
fontFamily: "monospace",
|
fontFamily: "monospace",
|
||||||
fontWeight: 700,
|
fontWeight: 700,
|
||||||
color: "white"
|
color: "white",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Kyoo
|
Kyoo
|
||||||
@ -112,7 +112,7 @@ export const Navbar = (barProps: AppBarProps) => {
|
|||||||
</Box>
|
</Box>
|
||||||
<Tooltip title={t("navbar.login")}>
|
<Tooltip title={t("navbar.login")}>
|
||||||
<IconButton sx={{ p: 0 }} href="/auth/login">
|
<IconButton sx={{ p: 0 }} href="/auth/login">
|
||||||
<Avatar alt={t("navbar.login")}/>
|
<Avatar alt={t("navbar.login")} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
@ -125,4 +125,3 @@ Navbar.query = (): QueryIdentifier<Page<Library>> => ({
|
|||||||
parser: Paged(LibraryP),
|
parser: Paged(LibraryP),
|
||||||
path: ["libraries"],
|
path: ["libraries"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,11 +26,15 @@ export const PersonAvatar = ({ person, sx }: { person?: Person; sx?: SxProps })
|
|||||||
if (!person) {
|
if (!person) {
|
||||||
return (
|
return (
|
||||||
<Box sx={sx}>
|
<Box sx={sx}>
|
||||||
<Skeleton variant="circular" sx={{ width: "100%", aspectRatio: "1/1", height: "unset" }}/>
|
<Skeleton variant="circular" sx={{ width: "100%", aspectRatio: "1/1", height: "unset" }} />
|
||||||
<Typography align="center"><Skeleton/></Typography>
|
<Typography align="center">
|
||||||
<Typography variant="body2" align="center"><Skeleton/></Typography>
|
<Skeleton />
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" align="center">
|
||||||
|
<Skeleton />
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Link href={`/person/${person.slug}`} color="inherit" sx={sx}>
|
<Link href={`/person/${person.slug}`} color="inherit" sx={sx}>
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { ImagesP, ResourceP } from "../traits";
|
import { ImagesP, ResourceP } from "../traits";
|
||||||
|
|
||||||
|
|
||||||
export const CollectionP = ResourceP.merge(ImagesP).extend({
|
export const CollectionP = ResourceP.merge(ImagesP).extend({
|
||||||
/**
|
/**
|
||||||
* The title of this collection.
|
* The title of this collection.
|
||||||
|
@ -38,8 +38,17 @@ export const LibraryItemP = z.preprocess(
|
|||||||
return x;
|
return x;
|
||||||
},
|
},
|
||||||
z.union([
|
z.union([
|
||||||
|
/*
|
||||||
|
* Either a Show
|
||||||
|
*/
|
||||||
ShowP.and(z.object({ type: z.literal(ItemType.Show) })),
|
ShowP.and(z.object({ type: z.literal(ItemType.Show) })),
|
||||||
|
/*
|
||||||
|
* Or a Movie
|
||||||
|
*/
|
||||||
MovieP.and(z.object({ type: z.literal(ItemType.Movie) })),
|
MovieP.and(z.object({ type: z.literal(ItemType.Movie) })),
|
||||||
|
/*
|
||||||
|
* Or a Collection
|
||||||
|
*/
|
||||||
CollectionP.and(z.object({ type: z.literal(ItemType.Collection) })),
|
CollectionP.and(z.object({ type: z.literal(ItemType.Collection) })),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
@ -32,8 +32,7 @@ export const getDisplayDate = (data: Show | Movie) => {
|
|||||||
return startAir.getFullYear().toString();
|
return startAir.getFullYear().toString();
|
||||||
}
|
}
|
||||||
return startAir.getFullYear() + (endAir ? ` - ${endAir.getFullYear()}` : "");
|
return startAir.getFullYear() + (endAir ? ` - ${endAir.getFullYear()}` : "");
|
||||||
}
|
} else if (airDate) {
|
||||||
else if (airDate) {
|
|
||||||
return airDate.getFullYear().toString();
|
return airDate.getFullYear().toString();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -67,9 +67,7 @@ const App = ({ Component, pageProps }: AppProps) => {
|
|||||||
</Head>
|
</Head>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<Hydrate state={queryState}>
|
<Hydrate state={queryState}>
|
||||||
<ThemeProvider theme={defaultTheme}>
|
<ThemeProvider theme={defaultTheme}>{getLayout(<Component {...props} />)}</ThemeProvider>
|
||||||
{getLayout(<Component {...props} />)}
|
|
||||||
</ThemeProvider>
|
|
||||||
</Hydrate>
|
</Hydrate>
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</>
|
</>
|
||||||
|
@ -247,7 +247,9 @@ const BrowseSettings = ({
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation("browse");
|
const { t } = useTranslation("browse");
|
||||||
|
|
||||||
const switchViewTitle = layout === Layout.Grid ? t("browse.switchToList") : t("browse.switchToGrid");
|
const switchViewTitle = layout === Layout.Grid
|
||||||
|
? t("browse.switchToList")
|
||||||
|
: t("browse.switchToGrid");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
* along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import BrowsePage from "./browse"
|
import BrowsePage from "./browse";
|
||||||
|
|
||||||
export default BrowsePage;
|
export default BrowsePage;
|
||||||
|
@ -135,7 +135,11 @@ export const ShowHeader = ({ data }: { data?: Show | Movie }) => {
|
|||||||
{data?.name ?? <Skeleton width="15rem" />}
|
{data?.name ?? <Skeleton width="15rem" />}
|
||||||
</Typography>
|
</Typography>
|
||||||
{(!data || getDisplayDate(data)) && (
|
{(!data || getDisplayDate(data)) && (
|
||||||
<Typography component="p" variant="h5" sx={{ color: { md: "white" }, fontWeight: 300, mb: ".5rem" }}>
|
<Typography
|
||||||
|
component="p"
|
||||||
|
variant="h5"
|
||||||
|
sx={{ color: { md: "white" }, fontWeight: 300, mb: ".5rem" }}
|
||||||
|
>
|
||||||
{data != undefined ? (
|
{data != undefined ? (
|
||||||
getDisplayDate(data)
|
getDisplayDate(data)
|
||||||
) : (
|
) : (
|
||||||
@ -247,7 +251,6 @@ export const ShowHeader = ({ data }: { data?: Show | Movie }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const ShowStaff = ({ slug }: { slug: string }) => {
|
export const ShowStaff = ({ slug }: { slug: string }) => {
|
||||||
const { items, isError, error } = useInfiniteFetch(ShowStaff.query(slug));
|
const { items, isError, error } = useInfiniteFetch(ShowStaff.query(slug));
|
||||||
const { t } = useTranslation("browse");
|
const { t } = useTranslation("browse");
|
||||||
@ -300,11 +303,6 @@ const MovieDetails: QueryPage<{ slug: string }> = ({ slug }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MovieDetails.getFetchUrls = ({ slug }) => [query(slug), ShowStaff.query(slug), Navbar.query()];
|
||||||
MovieDetails.getFetchUrls = ({ slug }) => [
|
|
||||||
query(slug),
|
|
||||||
ShowStaff.query(slug),
|
|
||||||
Navbar.query(),
|
|
||||||
];
|
|
||||||
|
|
||||||
export default withRoute(MovieDetails);
|
export default withRoute(MovieDetails);
|
||||||
|
@ -19,14 +19,22 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { forwardRef, Ref } from "react";
|
import { forwardRef, Ref } from "react";
|
||||||
import NLink, { LinkProps as NLinkProps} from "next/link";
|
import NLink, { LinkProps as NLinkProps } from "next/link";
|
||||||
import { Button as MButton, ButtonProps, Link as MLink, LinkProps as MLinkProps} from "@mui/material";
|
import {
|
||||||
|
Button as MButton,
|
||||||
|
ButtonProps,
|
||||||
|
Link as MLink,
|
||||||
|
LinkProps as MLinkProps,
|
||||||
|
} from "@mui/material";
|
||||||
|
|
||||||
type ButtonRef = HTMLButtonElement;
|
type ButtonRef = HTMLButtonElement;
|
||||||
type ButtonLinkProps = Omit<ButtonProps, "href"> &
|
type ButtonLinkProps = Omit<ButtonProps, "href"> &
|
||||||
Pick<NLinkProps, "href" | "as" | "prefetch" | "locale">;
|
Pick<NLinkProps, "href" | "as" | "prefetch" | "locale">;
|
||||||
|
|
||||||
const NextButton = ({ href, as, prefetch, locale, ...props }: ButtonLinkProps, ref: Ref<ButtonRef>) => (
|
const NextButton = (
|
||||||
|
{ href, as, prefetch, locale, ...props }: ButtonLinkProps,
|
||||||
|
ref: Ref<ButtonRef>,
|
||||||
|
) => (
|
||||||
<NLink href={href} as={as} prefetch={prefetch} locale={locale} passHref>
|
<NLink href={href} as={as} prefetch={prefetch} locale={locale} passHref>
|
||||||
<MButton ref={ref} {...props} />
|
<MButton ref={ref} {...props} />
|
||||||
</NLink>
|
</NLink>
|
||||||
@ -37,10 +45,21 @@ export const ButtonLink = forwardRef<ButtonRef, ButtonLinkProps>(NextButton);
|
|||||||
type LinkRef = HTMLAnchorElement;
|
type LinkRef = HTMLAnchorElement;
|
||||||
type LinkProps = Omit<MLinkProps, "href"> &
|
type LinkProps = Omit<MLinkProps, "href"> &
|
||||||
Pick<NLinkProps, "as" | "prefetch" | "locale" | "shallow" | "replace"> &
|
Pick<NLinkProps, "as" | "prefetch" | "locale" | "shallow" | "replace"> &
|
||||||
({ to: NLinkProps["href"], href?: undefined } | { href: NLinkProps["href"], to?: undefined });
|
({ to: NLinkProps["href"]; href?: undefined } | { href: NLinkProps["href"]; to?: undefined });
|
||||||
|
|
||||||
const NextLink = ({ href, to, as, prefetch, locale, shallow, replace, ...props }: LinkProps, ref: Ref<LinkRef>) => (
|
const NextLink = (
|
||||||
<NLink href={href ?? to} as={as} prefetch={prefetch} locale={locale} shallow={shallow} replace={replace} passHref>
|
{ href, to, as, prefetch, locale, shallow, replace, ...props }: LinkProps,
|
||||||
|
ref: Ref<LinkRef>,
|
||||||
|
) => (
|
||||||
|
<NLink
|
||||||
|
href={href ?? to}
|
||||||
|
as={as}
|
||||||
|
prefetch={prefetch}
|
||||||
|
locale={locale}
|
||||||
|
shallow={shallow}
|
||||||
|
replace={replace}
|
||||||
|
passHref
|
||||||
|
>
|
||||||
<MLink ref={ref} {...props} />
|
<MLink ref={ref} {...props} />
|
||||||
</NLink>
|
</NLink>
|
||||||
);
|
);
|
||||||
|
@ -61,7 +61,7 @@ const queryFn = async <Data>(
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
data = { errors: [error] } as KyooErrors;
|
data = { errors: [error] } as KyooErrors;
|
||||||
}
|
}
|
||||||
console.log("Invalid response:", data)
|
console.log("Invalid response:", data);
|
||||||
throw data as KyooErrors;
|
throw data as KyooErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ export const useInfiniteFetch = <Data>(query: QueryIdentifier<Data>) => {
|
|||||||
queryFn: (ctx) => queryFn(Paged(query.parser), ctx),
|
queryFn: (ctx) => queryFn(Paged(query.parser), ctx),
|
||||||
getNextPageParam: (page: Page<Data>) => page?.next || undefined,
|
getNextPageParam: (page: Page<Data>) => page?.next || undefined,
|
||||||
});
|
});
|
||||||
return {...ret, items: ret.data?.pages.flatMap((x) => x.items)}
|
return { ...ret, items: ret.data?.pages.flatMap((x) => x.items) };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchQuery = async (queries: QueryIdentifier[]) => {
|
export const fetchQuery = async (queries: QueryIdentifier[]) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user