Skip to content

Commit

Permalink
fix: global themes \ modal theme styles
Browse files Browse the repository at this point in the history
  • Loading branch information
TomatoVan committed Nov 8, 2023
1 parent 14133b7 commit 70ed6f1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React, { Suspense } from 'react';
import './styles/index.scss';
import { classNames } from 'shared/lib/classNames/classNames';
import { useTheme } from 'app/providers/ThemeProvider';
import { AppRouter } from 'app/providers/router';
import { Navbar } from 'widgets/Navbar';
import { Sidebar } from 'widgets/Sidebar';

function App() {
const { theme } = useTheme();

return (
<div className={classNames('app', {}, [theme])}>
<div className={classNames('app', {}, [])}>
<Suspense fallback="">
<Navbar />
<div className="content-page">
Expand Down
4 changes: 2 additions & 2 deletions src/app/providers/ThemeProvider/lib/ThemeContext.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createContext } from 'react';

export enum Theme {
LIGHT = 'light',
DARK = 'dark',
LIGHT = 'app_light_theme',

Check warning on line 4 in src/app/providers/ThemeProvider/lib/ThemeContext.ts

View workflow job for this annotation

GitHub Actions / pipeline (17.x)

'LIGHT' is defined but never used
DARK = 'app_dark_theme',

Check warning on line 5 in src/app/providers/ThemeProvider/lib/ThemeContext.ts

View workflow job for this annotation

GitHub Actions / pipeline (17.x)

'DARK' is defined but never used
}

export interface ThemeContextProps {
Expand Down
2 changes: 2 additions & 0 deletions src/app/providers/ThemeProvider/lib/useTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function useTheme(): UseThemeResult {
const toggleTheme = () => {
const newTheme = theme === Theme.DARK ? Theme.LIGHT : Theme.DARK;
setTheme(newTheme);
// чтобы работали стили в модалках и других частях приложения (используется по умолчанию везде как единая точка входа)
document.body.className = newTheme;
localStorage.setItem(LOCAL_STORAGE_THEME_KEY, newTheme);
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/styles/themes/dark.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.app.dark {
.app_dark_theme {
--bg-color: #090949;
--inverted-bg-color: #e8e8ea;
--primary-color: #04ff04;
Expand Down

0 comments on commit 70ed6f1

Please sign in to comment.