mirror of
https://github.com/sussy-code/smov.git
synced 2026-05-14 22:00:43 +00:00
Fix subtitle styling settings and add reset button
This commit is contained in:
parent
6d5934e930
commit
a190523b4e
3 changed files with 50 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ import classNames from "classnames";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { Button } from "@/components/buttons/Button";
|
||||||
import { Toggle } from "@/components/buttons/Toggle";
|
import { Toggle } from "@/components/buttons/Toggle";
|
||||||
import { Icon, Icons } from "@/components/Icon";
|
import { Icon, Icons } from "@/components/Icon";
|
||||||
import { Menu } from "@/components/player/internals/ContextMenu";
|
import { Menu } from "@/components/player/internals/ContextMenu";
|
||||||
|
|
@ -241,6 +242,16 @@ export function CaptionSettingsView({
|
||||||
updateStyling(newStyling);
|
updateStyling(newStyling);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resetSubStyling = () => {
|
||||||
|
subtitleStore.updateStyling({
|
||||||
|
color: "#ffffff",
|
||||||
|
backgroundOpacity: 0.5,
|
||||||
|
size: 1,
|
||||||
|
backgroundBlur: 0.5,
|
||||||
|
bold: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Menu.BackLink
|
<Menu.BackLink
|
||||||
|
|
@ -344,6 +355,13 @@ export function CaptionSettingsView({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<Button
|
||||||
|
className="w-full md:w-auto"
|
||||||
|
theme="secondary"
|
||||||
|
onClick={resetSubStyling}
|
||||||
|
>
|
||||||
|
{t("settings.reset")}
|
||||||
|
</Button>
|
||||||
</Menu.Section>
|
</Menu.Section>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
|
||||||
import { Helmet } from "react-helmet-async";
|
import { Helmet } from "react-helmet-async";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { Button } from "@/components/buttons/Button";
|
||||||
import { Toggle } from "@/components/buttons/Toggle";
|
import { Toggle } from "@/components/buttons/Toggle";
|
||||||
import { Icon, Icons } from "@/components/Icon";
|
import { Icon, Icons } from "@/components/Icon";
|
||||||
import {
|
import {
|
||||||
|
|
@ -89,6 +90,17 @@ export function CaptionsPart(props: {
|
||||||
subtitleStore.updateStyling(newStyling);
|
subtitleStore.updateStyling(newStyling);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resetSubStyling = () => {
|
||||||
|
subtitleStore.resetStyling();
|
||||||
|
props.setStyling({
|
||||||
|
color: "#ffffff",
|
||||||
|
backgroundOpacity: 0.5,
|
||||||
|
size: 1,
|
||||||
|
backgroundBlur: 0.5,
|
||||||
|
bold: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Heading1 border>{t("settings.subtitles.title")}</Heading1>
|
<Heading1 border>{t("settings.subtitles.title")}</Heading1>
|
||||||
|
|
@ -117,7 +129,7 @@ export function CaptionsPart(props: {
|
||||||
backgroundBlur: v / 100,
|
backgroundBlur: v / 100,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
value={props.styling.backgroundBlur * 1}
|
value={props.styling.backgroundBlur * 100}
|
||||||
textTransformer={(s) => `${s}%`}
|
textTransformer={(s) => `${s}%`}
|
||||||
/>
|
/>
|
||||||
<CaptionSetting
|
<CaptionSetting
|
||||||
|
|
@ -200,6 +212,13 @@ export function CaptionsPart(props: {
|
||||||
styling={props.styling}
|
styling={props.styling}
|
||||||
onToggle={() => setFullscreenPreview((s) => !s)}
|
onToggle={() => setFullscreenPreview((s) => !s)}
|
||||||
/>
|
/>
|
||||||
|
<Button
|
||||||
|
className="w-full md:w-auto"
|
||||||
|
theme="secondary"
|
||||||
|
onClick={resetSubStyling}
|
||||||
|
>
|
||||||
|
{t("settings.reset")}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ export interface SubtitleStore {
|
||||||
overrideCasing: boolean;
|
overrideCasing: boolean;
|
||||||
delay: number;
|
delay: number;
|
||||||
updateStyling(newStyling: Partial<SubtitleStyling>): void;
|
updateStyling(newStyling: Partial<SubtitleStyling>): void;
|
||||||
|
resetStyling(): void;
|
||||||
setLanguage(language: string | null): void;
|
setLanguage(language: string | null): void;
|
||||||
setIsOpenSubtitles(isOpenSubtitles: boolean): void;
|
setIsOpenSubtitles(isOpenSubtitles: boolean): void;
|
||||||
setCustomSubs(): void;
|
setCustomSubs(): void;
|
||||||
|
|
@ -93,6 +94,17 @@ export const useSubtitleStore = create(
|
||||||
if (newStyling.bold !== undefined) s.styling.bold = newStyling.bold;
|
if (newStyling.bold !== undefined) s.styling.bold = newStyling.bold;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
resetStyling() {
|
||||||
|
set((s) => {
|
||||||
|
s.styling = {
|
||||||
|
color: "#ffffff",
|
||||||
|
backgroundOpacity: 0.5,
|
||||||
|
size: 1,
|
||||||
|
backgroundBlur: 0.5,
|
||||||
|
bold: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
setLanguage(lang) {
|
setLanguage(lang) {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
s.enabled = !!lang;
|
s.enabled = !!lang;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue