MSP-3074 ThemeProvider change to ConfigProvider
This commit is contained in:
1 parent
7ac446d783
commit
c598e0dde8
11 files changed
+34
-30
No files matched your search
File renamed without changes.
@@ -1,19 +1,19 @@
|
||||
import {useState} from 'react';
|
||||
import {ThemeAppearance, ThemeProvider} from 'antd-style';
|
||||
import {ConfigProvider} from "antd";
|
||||
import {Context} from "../store";
|
||||
import Routers from "./Routers/Routers.tsx";
|
||||
import Routers from "./Routers";
|
||||
import {lightTheme} from "../constants/theme.ts";
|
||||
import './app.scss'
|
||||
|
||||
|
||||
function App() {
|
||||
const [theme, setTheme] = useState<ThemeAppearance>('light');
|
||||
const [themes, setTheme] = useState(lightTheme);
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<Context.Provider value={{setTheme}}>
|
||||
<ThemeProvider appearance={theme}>
|
||||
<ConfigProvider theme={themes}>
|
||||
<Routers/>
|
||||
</ThemeProvider>
|
||||
</ConfigProvider>
|
||||
</Context.Provider>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import {useContext} from "react";
|
||||
import {ThemeAppearance, useTheme} from "antd-style";
|
||||
import {Segmented} from "antd";
|
||||
import {Segmented, theme} from "antd";
|
||||
import {Context} from "../../store";
|
||||
import {darkTheme, lightTheme} from "../../constants/theme.ts";
|
||||
import './header.scss'
|
||||
|
||||
|
||||
const options = [
|
||||
{label: 'Light', value: 'light'},
|
||||
{label: 'Light', value: 'light' },
|
||||
{label: 'Dark', value: 'dark'},
|
||||
];
|
||||
|
||||
function Header() {
|
||||
const theme = useTheme();
|
||||
const {setTheme} = useContext(Context)
|
||||
const { useToken } = theme;
|
||||
const { token } = useToken();
|
||||
|
||||
return <header className='header' style={{
|
||||
background: theme.colorBgLayout
|
||||
}}><Segmented onChange={(v) => setTheme(v as ThemeAppearance)} options={options}/></header>;
|
||||
backgroundColor: token.colorBgLayout
|
||||
}}><Segmented onChange={(v) => setTheme(v === 'light' ? lightTheme : darkTheme)} options={options}/></header>;
|
||||
}
|
||||
|
||||
export default Header;
|
||||
@@ -1,19 +1,17 @@
|
||||
import {Button} from 'antd';
|
||||
import {useTheme} from 'antd-style';
|
||||
import {Button, theme} from 'antd';
|
||||
import {PermissionKeys} from "../../types/roles.type.ts";
|
||||
import useRole from "../../hooks/useRole.tsx";
|
||||
import './main.scss'
|
||||
|
||||
|
||||
const Main = () => {
|
||||
const theme = useTheme();
|
||||
const {hasPermission} = useRole();
|
||||
|
||||
const { useToken } = theme;
|
||||
const { token } = useToken();
|
||||
const isPageAvailable = hasPermission(PermissionKeys.user_view);
|
||||
|
||||
return (
|
||||
<div className='main' style={{
|
||||
background: theme.colorBgLayout
|
||||
backgroundColor: token.colorBgLayout
|
||||
}}>
|
||||
|
||||
{isPageAvailable && <Button ghost type={'primary'}>
|
||||
|
||||
@@ -5,7 +5,6 @@ import HomePages from "../../pages/HomePage";
|
||||
import Test from "../Test/Test.tsx";
|
||||
import PrivateRoute from "../PrivateRoute";
|
||||
|
||||
|
||||
function Routers() {
|
||||
|
||||
return (
|
||||
@@ -6,3 +6,6 @@
|
||||
.app {
|
||||
min-height: 100vh;
|
||||
}
|
||||
.ant-space-item {
|
||||
width: 100%;
|
||||
}
|
||||
Reference in new issue
Block a user