🌒 refactor: Theme Handling to use isDark Utility (#9405)

*  fix: Refactor theme handling to use isDark utility across components

* 🔧 fix: Update package client version to 0.2.8 and adjust theme import path in ThemeSelector component

---------

Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com>
This commit is contained in:
Eduardo Cruz Guedes 2025-09-03 03:56:36 -03:00 committed by GitHub
parent b66bf93b31
commit 122ff416ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 11 additions and 15 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@librechat/client",
"version": "0.2.7",
"version": "0.2.8",
"description": "React components for LibreChat",
"main": "dist/index.js",
"module": "dist/index.es.js",

View file

@ -1,6 +1,6 @@
import { useContext, useCallback, useEffect, useState } from 'react';
import { Sun, Moon, Monitor } from 'lucide-react';
import { ThemeContext } from '../theme';
import { ThemeContext, isDark } from '../theme';
declare global {
interface Window {
@ -17,7 +17,7 @@ const Theme = ({ theme, onChange }: { theme: string; onChange: (value: string) =
light: <Sun />,
};
const nextTheme = theme === 'dark' ? 'light' : 'dark';
const nextTheme = isDark(theme) ? 'light' : 'dark';
const label = `Switch to ${nextTheme} theme`;
useEffect(() => {
@ -65,7 +65,7 @@ const ThemeSelector = ({ returnThemeOnly }: { returnThemeOnly?: boolean }) => {
window.lastThemeChange = now;
setTheme(value);
setAnnouncement(value === 'dark' ? 'Dark theme enabled' : 'Light theme enabled');
setAnnouncement(isDark(value) ? 'Dark theme enabled' : 'Light theme enabled');
},
[setTheme],
);