From eaad8a4cf523d070609065f3dc463e40ead252b1 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Thu, 18 Jan 2024 02:39:40 +0530 Subject: [PATCH 1/9] initialising dark mode --- docker-compose.yaml | 9 ------- frontend/src/Setting.tsx | 46 +++++++++++++++++++----------------- frontend/tailwind.config.cjs | 1 + 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 7008b53d..290345ab 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,15 +1,6 @@ version: "3.9" services: - frontend: - build: ./frontend - environment: - - VITE_API_HOST=http://localhost:7091 - - VITE_API_STREAMING=$VITE_API_STREAMING - ports: - - "5173:5173" - depends_on: - - backend backend: build: ./application diff --git a/frontend/src/Setting.tsx b/frontend/src/Setting.tsx index 65756bea..c1a2a153 100644 --- a/frontend/src/Setting.tsx +++ b/frontend/src/Setting.tsx @@ -10,7 +10,6 @@ import { selectSourceDocs, } from './preferences/preferenceSlice'; import { Doc } from './preferences/preferenceApi'; - type PromptProps = { prompts: { name: string; id: string; type: string }[]; selectedPrompt: { name: string; id: string; type: string }; @@ -97,7 +96,7 @@ const Setting: React.FC = () => { }; return ( -
+

Settings

@@ -113,11 +112,10 @@ const Setting: React.FC = () => { @@ -187,11 +185,20 @@ const Setting: React.FC = () => { }; const General: React.FC = () => { - const themes = ['Light']; + const themes = ['Light', 'Dark']; const languages = ['English']; - const [selectedTheme, setSelectedTheme] = useState(themes[0]); + const [selectedTheme, setSelectedTheme] = useState(localStorage.getItem('selectedTheme') || themes[0]); const [selectedLanguage, setSelectedLanguage] = useState(languages[0]); + useEffect(() => { + if (selectedTheme === 'Dark') { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + localStorage.setItem('selectedTheme', selectedTheme); + }, [selectedTheme]); + return (
@@ -380,33 +387,30 @@ const Prompts: React.FC = ({
{isOpen && ( @@ -496,9 +499,8 @@ function Dropdown({ arrow {isOpen && ( diff --git a/frontend/tailwind.config.cjs b/frontend/tailwind.config.cjs index ea40ed10..504b7e41 100644 --- a/frontend/tailwind.config.cjs +++ b/frontend/tailwind.config.cjs @@ -35,6 +35,7 @@ module.exports = { 'dove-gray': '#6c6c6c', silver: '#c4c4c4', 'rainy-gray': '#a4a4a4', + 'dark-bg':'#222327' }, }, }, From 0b997418d37b8389c038119d64323294d899b727 Mon Sep 17 00:00:00 2001 From: ManishMadan2882 Date: Fri, 19 Jan 2024 01:47:23 +0530 Subject: [PATCH 2/9] add dark - sidebar --- frontend/src/App.tsx | 11 ++++- frontend/src/Navigation.tsx | 42 +++++++++---------- frontend/src/Setting.tsx | 2 +- frontend/src/assets/discord.svg | 2 +- frontend/src/assets/documentation.svg | 2 +- frontend/src/assets/dropdown-arrow.svg | 2 +- frontend/src/assets/github.svg | 2 +- frontend/src/assets/info.svg | 2 +- frontend/src/assets/message.svg | 2 +- frontend/src/assets/settingGear.svg | 2 +- frontend/src/assets/upload.svg | 2 +- .../src/conversation/ConversationTile.tsx | 10 ++--- frontend/tailwind.config.cjs | 6 ++- 13 files changed, 49 insertions(+), 38 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index fdf86dd2..bad19744 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -5,7 +5,7 @@ import About from './About'; import PageNotFound from './PageNotFound'; import { inject } from '@vercel/analytics'; import { useMediaQuery } from './hooks'; -import { useState } from 'react'; +import { useState,useEffect } from 'react'; import Setting from './Setting'; inject(); @@ -13,7 +13,14 @@ inject(); export default function App() { const { isMobile } = useMediaQuery(); const [navOpen, setNavOpen] = useState(!isMobile); - + const selectedTheme = localStorage.getItem('selectedTheme'); + useEffect(()=>{ + if (selectedTheme === 'Dark') { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + },[]) return (
diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index f08f0bdf..a513b370 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -174,7 +174,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { <> {!navOpen && (