diff --git a/src/components/CaptionColorSelector.tsx b/src/components/CaptionColorSelector.tsx new file mode 100644 index 00000000..3d286f78 --- /dev/null +++ b/src/components/CaptionColorSelector.tsx @@ -0,0 +1,29 @@ +import { useSettings } from "@/state/settings"; +import { Icon, Icons } from "./Icon"; + +export const colors = ["#ffffff", "#00ffff", "#ffff00"]; +export default function CaptionColorSelector({ color }: { color: string }) { + const { captionSettings, setCaptionColor } = useSettings(); + return ( +
setCaptionColor(color)} + > +
+ +
+ ); +} diff --git a/src/components/layout/Modal.tsx b/src/components/layout/Modal.tsx index aa25ca7a..d5a910c1 100644 --- a/src/components/layout/Modal.tsx +++ b/src/components/layout/Modal.tsx @@ -40,7 +40,7 @@ export function ModalCard(props: { className?: string; children?: ReactNode }) {
{props.children} diff --git a/src/setup/iso6391.ts b/src/setup/iso6391.ts index 3677560a..0d12f39c 100644 --- a/src/setup/iso6391.ts +++ b/src/setup/iso6391.ts @@ -184,7 +184,7 @@ export type LangCode = | "za" | "zh" | "zu"; -type CaptionLanguageOptions = { +export type CaptionLanguageOption = { id: LangCode; name: string; englishName: string; @@ -212,7 +212,7 @@ type CaptionLanguageOptions = { // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -export const captionLanguages: CaptionLanguageOptions[] = [ +export const captionLanguages: CaptionLanguageOption[] = [ { id: "none", englishName: "None", diff --git a/src/video/components/actions/CaptionRendererAction.tsx b/src/video/components/actions/CaptionRendererAction.tsx index f3a65f52..664cffef 100644 --- a/src/video/components/actions/CaptionRendererAction.tsx +++ b/src/video/components/actions/CaptionRendererAction.tsx @@ -22,14 +22,10 @@ export function CaptionCue({ text, scale }: { text?: string; scale?: number }) { return (

; @@ -16,11 +18,9 @@ export function CaptionSettingsPopout(props: { const { captionSettings, setCaptionBackgroundColor, - setCaptionColor, setCaptionDelay, setCaptionFontSize, } = useSettings(); - const colors = ["#ffffff", "#00ffff", "#ffff00"]; return ( setCaptionDelay(e.target.valueAsNumber)} />

{colors.map((color) => ( -
setCaptionColor(color)} - > -
- -
+ ))}
diff --git a/src/views/SettingsModal.tsx b/src/views/SettingsModal.tsx index b05ebe14..073e03c9 100644 --- a/src/views/SettingsModal.tsx +++ b/src/views/SettingsModal.tsx @@ -4,10 +4,18 @@ import { Modal, ModalCard } from "@/components/layout/Modal"; import { useSettings } from "@/state/settings"; import { useTranslation } from "react-i18next"; import { CaptionCue } from "@/video/components/actions/CaptionRendererAction"; -import { Slider } from "@/video/components/popouts/CaptionSettingsPopout"; -import { LangCode, captionLanguages } from "@/setup/iso6391"; +import { + CaptionLanguageOption, + LangCode, + captionLanguages, +} from "@/setup/iso6391"; import { useMemo } from "react"; import { appLanguageOptions } from "@/setup/i18n"; +import CaptionColorSelector, { + colors, +} from "@/components/CaptionColorSelector"; +import { Slider } from "@/components/Slider"; +import { conf } from "@/setup/config"; export default function SettingsModal(props: { onClose: () => void; @@ -19,16 +27,18 @@ export default function SettingsModal(props: { setLanguage, setCaptionLanguage, setCaptionBackgroundColor, - setCaptionColor, setCaptionFontSize, } = useSettings(); const { t, i18n } = useTranslation(); - const colors = ["#ffffff", "#00ffff", "#ffff00"]; const selectedCaptionLanguage = useMemo( - () => captionLanguages.find((l) => l.id === captionSettings.language)!, + () => captionLanguages.find((l) => l.id === captionSettings.language), [captionSettings.language] - ); + ) as CaptionLanguageOption; + const appLanguage = useMemo( + () => appLanguageOptions.find((l) => l.id === language), + [language] + ) as CaptionLanguageOption; const captionBackgroundOpacity = ( (parseInt(captionSettings.style.backgroundColor.substring(7, 9), 16) / 255) * @@ -54,9 +64,7 @@ export default function SettingsModal(props: { {t("settings.language")} l.id === language)! - } + selectedItem={appLanguage} setSelectedItem={(val) => { i18n.changeLanguage(val.id); setLanguage(val.id as LangCode); @@ -78,7 +86,11 @@ export default function SettingsModal(props: {
setCaptionFontSize(e.target.valueAsNumber)} />
{colors.map((color) => ( -
setCaptionColor(color)} - > -
- -
+ ))}
@@ -149,6 +142,7 @@ export default function SettingsModal(props: {
+
v{conf().APP_VERSION}
);