From 3903e69093bcd4799839736df885c4561601c78b Mon Sep 17 00:00:00 2001 From: ftk789 Date: Tue, 9 Aug 2022 16:19:39 +0300 Subject: [PATCH] Added Toggle for dark/light theme --- packages/fakeyou/src/App.tsx | 29 ++++++++++++++----- .../src/v2/view/patrons/PatronPage.tsx | 5 ++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/packages/fakeyou/src/App.tsx b/packages/fakeyou/src/App.tsx index cab48a3fc5..48873d8fa8 100644 --- a/packages/fakeyou/src/App.tsx +++ b/packages/fakeyou/src/App.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect} from "react"; import { ApiConfig } from "@storyteller/components"; import { DetectLocale, @@ -31,6 +31,7 @@ import { FAKEYOU_MERGED_TRANSLATIONS } from "./_i18n/FakeYouTranslations"; import i18n from "i18next"; import { initReactI18next } from "react-i18next"; import { USE_REFRESH } from "./Refresh"; +import { DragControls } from "framer-motion"; i18n .use(initReactI18next) // passes i18n down to react-i18next @@ -169,6 +170,7 @@ class App extends React.Component { textBuffer: "", darkMode: true + }; } @@ -602,17 +604,29 @@ class App extends React.Component { }; - public render() { + // Redesign features let mainClassNames; mainClassNames = USE_REFRESH ? "bg-gradient " : ""; - mainClassNames = mainClassNames + (this.state.darkMode ? ' dark-mode' : '') + mainClassNames = mainClassNames + (this.state.darkMode ? '' : 'dark-mode') + const DarkModeOff = () =>{ + const currentValue = this.state.darkMode // true or false + window.localStorage.setItem("darkMode", (currentValue ? "true" : "false")) + + this.setState({darkMode: !currentValue}) + + + } return ( - +
+ + +
+
@@ -624,7 +638,6 @@ class App extends React.Component {
-
{/* This is the old vocodes1.0-compatible username and version switch { /> -
+ + +
); } } -export { App, MigrationMode, TtsInferenceJob, W2lInferenceJob }; +export { DarkModeOff, App, MigrationMode, TtsInferenceJob, W2lInferenceJob }; diff --git a/packages/fakeyou/src/v2/view/patrons/PatronPage.tsx b/packages/fakeyou/src/v2/view/patrons/PatronPage.tsx index be786e1481..f194be586a 100644 --- a/packages/fakeyou/src/v2/view/patrons/PatronPage.tsx +++ b/packages/fakeyou/src/v2/view/patrons/PatronPage.tsx @@ -9,7 +9,6 @@ import { faPatreon } from "@fortawesome/free-brands-svg-icons"; import { USE_REFRESH } from "../../../Refresh"; import { motion } from "framer-motion"; import { container, item, image, panel } from "../../../data/animation"; - interface Props { sessionWrapper: SessionWrapper; } @@ -78,6 +77,7 @@ function PatronPage(props: Props) { } return ( +
@@ -104,8 +104,7 @@ function PatronPage(props: Props) { Support us on Patreon -
-
+