From 4dc3a3216a4c9fa3cbf0a7dcdecf9e397d4653e2 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Thu, 30 Nov 2023 21:25:28 +0100 Subject: [PATCH] Some shoepolish for movie-web Co-authored-by: Jip Frijlink --- src/assets/locales/en.json | 1 + src/components/Avatar.tsx | 16 ++----- src/components/LinksDropdown.tsx | 2 +- src/components/buttons/Button.tsx | 2 + src/components/form/Dropdown.tsx | 4 +- src/components/form/SearchBar.tsx | 3 +- src/components/layout/Footer.tsx | 2 +- src/components/layout/Navigation.tsx | 7 +-- src/components/player/atoms/AutoPlayStart.tsx | 2 +- .../atoms/settings/CaptionSettingsView.tsx | 4 +- src/pages/parts/errors/ErrorCard.tsx | 43 +++++++++++++++--- src/pages/parts/errors/ErrorPart.tsx | 35 +++++++++++---- src/pages/parts/player/PlaybackErrorPart.tsx | 40 +++++++++++------ src/pages/parts/player/PlayerPart.tsx | 44 +++++++++++++------ src/pages/parts/player/ScrapeErrorPart.tsx | 40 ++++++++++++----- src/pages/parts/settings/CaptionsPart.tsx | 6 +++ src/pages/parts/settings/ConnectionsPart.tsx | 6 +-- themes/default.ts | 12 +++-- 18 files changed, 186 insertions(+), 83 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 8951793d..c30dd9a1 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -46,6 +46,7 @@ "errors": { "details": "Error details", "reloadPage": "Reload the page", + "showError": "Show error details", "badge": "It broke", "title": "That's an error boss" }, diff --git a/src/components/Avatar.tsx b/src/components/Avatar.tsx index 0efd8e77..7a7b4882 100644 --- a/src/components/Avatar.tsx +++ b/src/components/Avatar.tsx @@ -81,20 +81,10 @@ export function UserAvatar(props: { ); } -export function NoUserAvatar(props: { - sizeClass?: string; - iconClass?: string; -}) { +export function NoUserAvatar(props: { iconClass?: string }) { return ( -
-
- -
+
+
); } diff --git a/src/components/LinksDropdown.tsx b/src/components/LinksDropdown.tsx index b6dfa3a6..fa4910ab 100644 --- a/src/components/LinksDropdown.tsx +++ b/src/components/LinksDropdown.tsx @@ -109,7 +109,7 @@ export function LinksDropdown(props: { children: React.ReactNode }) { return (
evt.key === "Enter" && toggleOpen()} diff --git a/src/components/buttons/Button.tsx b/src/components/buttons/Button.tsx index 4f36093f..0490189f 100644 --- a/src/components/buttons/Button.tsx +++ b/src/components/buttons/Button.tsx @@ -99,6 +99,8 @@ export function Button(props: Props) { ); } +// Sometimes you can't use normal button, due to not having access to a useHistory context +// When that happens, use this! interface ButtonPlainProps { onClick?: () => void; children?: ReactNode; diff --git a/src/components/form/Dropdown.tsx b/src/components/form/Dropdown.tsx index d3cb027b..c1e36c01 100644 --- a/src/components/form/Dropdown.tsx +++ b/src/components/form/Dropdown.tsx @@ -21,7 +21,7 @@ export function Dropdown(props: DropdownProps) { {() => ( <> - + {props.selectedItem.leftIcon ? props.selectedItem.leftIcon @@ -45,7 +45,7 @@ export function Dropdown(props: DropdownProps) { {props.options.map((opt) => ( - `flex gap-4 items-center relative cursor-default select-none py-3 pl-4 pr-4 ${ + `cursor-pointer flex gap-4 items-center relative select-none py-3 pl-4 pr-4 ${ active ? "bg-background-secondaryHover text-type-link" : "text-white" diff --git a/src/components/form/SearchBar.tsx b/src/components/form/SearchBar.tsx index 0573a285..717f964d 100644 --- a/src/components/form/SearchBar.tsx +++ b/src/components/form/SearchBar.tsx @@ -24,7 +24,7 @@ export const SearchBarInput = forwardRef( return ( ( "bg-search-focused": focused, })} /> -
diff --git a/src/components/layout/Footer.tsx b/src/components/layout/Footer.tsx index da84527d..3704c446 100644 --- a/src/components/layout/Footer.tsx +++ b/src/components/layout/Footer.tsx @@ -55,7 +55,7 @@ export function Footer() {

{t("footer.legal.disclaimerText")}

-
+
{t("footer.links.github")} diff --git a/src/components/layout/Navigation.tsx b/src/components/layout/Navigation.tsx index 8e56ffc1..d7cec107 100644 --- a/src/components/layout/Navigation.tsx +++ b/src/components/layout/Navigation.tsx @@ -59,6 +59,7 @@ export function Navigation(props: NavigationProps) {
) : null} +
-
-
+
+
@@ -99,7 +100,7 @@ export function Navigation(props: NavigationProps) {
-
+
{loggedIn ? : } diff --git a/src/components/player/atoms/AutoPlayStart.tsx b/src/components/player/atoms/AutoPlayStart.tsx index b5d02f29..7ae99e88 100644 --- a/src/components/player/atoms/AutoPlayStart.tsx +++ b/src/components/player/atoms/AutoPlayStart.tsx @@ -23,7 +23,7 @@ export function AutoPlayStart() { return (
setDelay(v)} @@ -241,7 +241,7 @@ export function CaptionSettingsView({ id }: { id: string }) { />
- {t("player.menus.captions.settings.delay")} + {t("player.menus.captions.settings.fixCapitals")}
void; +}) { const [hasCopied, setHasCopied] = useState(false); const hasCopiedUnsetDebounce = useRef | null>( null @@ -32,8 +35,6 @@ export function ErrorCard(props: { error: DisplayError | string }) { hasCopiedUnsetDebounce.current = setTimeout(() => setHasCopied(false), 2e3); } - if (!showErrorCard) return null; - return ( // I didn't put a here because it'd fade out, then jump height weirdly
@@ -60,7 +61,7 @@ export function ErrorCard(props: { error: DisplayError | string }) { @@ -72,3 +73,35 @@ export function ErrorCard(props: { error: DisplayError | string }) {
); } + +// use plain modal version if there is no access to history api (like in error boundary) +export function ErrorCardInPlainModal(props: { + error?: DisplayError | string; + onClose: () => void; + show?: boolean; +}) { + if (!props.show || !props.error) return null; + return ( +
+
+ +
+
+ ); +} + +export function ErrorCardInModal(props: { + error?: DisplayError | string; + id: string; + onClose: () => void; +}) { + if (!props.error) return null; + + return ( + +
+ +
+
+ ); +} diff --git a/src/pages/parts/errors/ErrorPart.tsx b/src/pages/parts/errors/ErrorPart.tsx index e61ec744..a7e24055 100644 --- a/src/pages/parts/errors/ErrorPart.tsx +++ b/src/pages/parts/errors/ErrorPart.tsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import { useTranslation } from "react-i18next"; import { ButtonPlain } from "@/components/buttons/Button"; @@ -7,10 +8,11 @@ import { DisplayError } from "@/components/player/display/displayInterface"; import { Title } from "@/components/text/Title"; import { Paragraph } from "@/components/utils/Text"; import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout"; -import { ErrorCard } from "@/pages/parts/errors/ErrorCard"; +import { ErrorCardInPlainModal } from "@/pages/parts/errors/ErrorCard"; export function ErrorPart(props: { error: any; errorInfo: any }) { const { t } = useTranslation(); + const [showErrorCard, setShowErrorCard] = useState(false); const maxLineCount = 5; const errorLines = (props.errorInfo.componentStack || "") @@ -30,15 +32,30 @@ export function ErrorPart(props: { error: any; errorInfo: any }) { {t("errors.badge")} {t("errors.title")} + {props.error.toString()} - - window.location.reload()} - > - {t("errors.reloadPage")} - + setShowErrorCard(false)} + error={error} + /> + +
+ window.location.reload()} + > + {t("errors.reloadPage")} + + setShowErrorCard(true)} + > + {t("errors.showError")} + +
diff --git a/src/pages/parts/player/PlaybackErrorPart.tsx b/src/pages/parts/player/PlaybackErrorPart.tsx index 03bf1e26..df6e6414 100644 --- a/src/pages/parts/player/PlaybackErrorPart.tsx +++ b/src/pages/parts/player/PlaybackErrorPart.tsx @@ -3,16 +3,18 @@ import { useTranslation } from "react-i18next"; import { Button } from "@/components/buttons/Button"; import { Icons } from "@/components/Icon"; import { IconPill } from "@/components/layout/IconPill"; +import { useModal } from "@/components/overlays/Modal"; import { Paragraph } from "@/components/text/Paragraph"; import { Title } from "@/components/text/Title"; import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout"; import { usePlayerStore } from "@/stores/player/store"; -import { ErrorCard } from "../errors/ErrorCard"; +import { ErrorCardInModal } from "../errors/ErrorCard"; export function PlaybackErrorPart() { const { t } = useTranslation(); const playbackError = usePlayerStore((s) => s.interface.error); + const modal = useModal("error"); return ( @@ -20,19 +22,31 @@ export function PlaybackErrorPart() { {t("player.playbackError.badge")} {t("player.playbackError.title")} {t("player.playbackError.text")} - - - - {/* Error */} - {playbackError ? : null} +
+ + +
+ {/* Error */} + modal.hide()} + error={playbackError} + id={modal.id} + />
); } diff --git a/src/pages/parts/player/PlayerPart.tsx b/src/pages/parts/player/PlayerPart.tsx index 2320eded..bafd64fd 100644 --- a/src/pages/parts/player/PlayerPart.tsx +++ b/src/pages/parts/player/PlayerPart.tsx @@ -64,38 +64,54 @@ export function PlayerPart(props: PlayerPartProps) {
- - + {status === playerStatus.PLAYING ? ( + <> + + + + ) : null}
- {isMobile ? : null} - + {status === playerStatus.PLAYING ? ( + <> + {isMobile ? : null} + + + ) : null}
- - - - - + {status === playerStatus.PLAYING ? ( + <> + + + + + + + ) : null}
- - - - + {status === playerStatus.PLAYING ? ( + <> + + + + + + ) : null}
- + {status === playerStatus.PLAYING ? : null}
diff --git a/src/pages/parts/player/ScrapeErrorPart.tsx b/src/pages/parts/player/ScrapeErrorPart.tsx index 632f9280..692ad198 100644 --- a/src/pages/parts/player/ScrapeErrorPart.tsx +++ b/src/pages/parts/player/ScrapeErrorPart.tsx @@ -4,12 +4,13 @@ import { useTranslation } from "react-i18next"; import { Button } from "@/components/buttons/Button"; import { Icons } from "@/components/Icon"; import { IconPill } from "@/components/layout/IconPill"; +import { useModal } from "@/components/overlays/Modal"; import { Paragraph } from "@/components/text/Paragraph"; import { Title } from "@/components/text/Title"; import { ScrapingItems, ScrapingSegment } from "@/hooks/useProviderScrape"; import { ErrorContainer, ErrorLayout } from "@/pages/layouts/ErrorLayout"; -import { ErrorCard } from "../errors/ErrorCard"; +import { ErrorCardInModal } from "../errors/ErrorCard"; export interface ScrapeErrorPartProps { data: { @@ -20,6 +21,8 @@ export interface ScrapeErrorPartProps { export function ScrapeErrorPart(props: ScrapeErrorPartProps) { const { t } = useTranslation(); + const modal = useModal("error"); + const error = useMemo(() => { const data = props.data; const amountError = Object.values(data.sources).filter( @@ -43,18 +46,33 @@ export function ScrapeErrorPart(props: ScrapeErrorPartProps) { {t("player.scraping.notFound.title")} {t("player.scraping.notFound.text")} - +
+ + +
- {/* Error */} - {error ? : null} + {error ? ( + modal.hide()} + error={error} + /> + ) : null} ); diff --git a/src/pages/parts/settings/CaptionsPart.tsx b/src/pages/parts/settings/CaptionsPart.tsx index 0f37a7da..8327e343 100644 --- a/src/pages/parts/settings/CaptionsPart.tsx +++ b/src/pages/parts/settings/CaptionsPart.tsx @@ -1,5 +1,6 @@ import classNames from "classnames"; import { useState } from "react"; +import { Helmet } from "react-helmet-async"; import { useTranslation } from "react-i18next"; import { Icon, Icons } from "@/components/Icon"; @@ -29,6 +30,11 @@ export function CaptionPreview(props: { "fixed inset-0 z-[60]": props.fullscreen, })} > + {props.fullscreen && props.show ? ( + + + + ) : null}

- {t("settings.connections.workers.label")} + {t("settings.connections.server.label")}

- {t("settings.connections.workers.description")} + {t("settings.connections.server.description")}

@@ -132,7 +132,7 @@ function BackendEdit({ backendUrl, setBackendUrl }: BackendEditProps) { <>

- {t("settings.connections.workers.urlLabel")} + {t("settings.connections.server.urlLabel")}

diff --git a/themes/default.ts b/themes/default.ts index 5e839998..f0dd5113 100644 --- a/themes/default.ts +++ b/themes/default.ts @@ -9,8 +9,8 @@ export const defaultTheme = { // Branding pill: { - background: "#1C1C36", - backgroundHover: "#1C1C36", + background: "#2e2e4d", + backgroundHover: "#3d3d61", highlight: "#714C97", }, @@ -97,7 +97,7 @@ export const defaultTheme = { dropdown: { background: "#171728", altBackground: "#151525", - highlight: "#FCEC61", + highlight: "#afa349", highlightHover: "#FCEC61", text: "#846D95", secondary: "#73739D", @@ -179,6 +179,11 @@ export const defaultTheme = { video: { buttonBackground: "#444B5C", + autoPlay: { + background: "#161C26", + hover: "#252533" + }, + scraping: { card: "#161620", error: "#E44F4F", @@ -211,6 +216,7 @@ export const defaultTheme = { active: "#0D1317", }, + type: { main: "#617A8A", secondary: "#374A56",