MSP-3074 add layout
This commit is contained in:
1 parent
5f73d33a58
commit
92fcb4a352
7 files changed
+86
-34
No files matched your search
+15
-12
@@ -1,32 +1,35 @@
|
||||
import { useState } from 'react';
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
import {App} from 'antd';
|
||||
import { ThemeAppearance, ThemeProvider } from 'antd-style';
|
||||
import Layout from "../pages/Layout/Layout.tsx";
|
||||
import HomePages from '../pages/HomePage/HomePages.tsx';
|
||||
import {Context} from "../store";
|
||||
import './app.scss'
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Segmented } from 'antd';
|
||||
import { ThemeAppearance, ThemeProvider } from 'antd-style';
|
||||
|
||||
|
||||
|
||||
const options = [
|
||||
{ label: 'Light', value: 'light' },
|
||||
{ label: 'Dark', value: 'dark' },
|
||||
];
|
||||
|
||||
function App() {
|
||||
function AppDefault() {
|
||||
const [appearance, setTheme] = useState<ThemeAppearance>('light');
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
<Segmented onChange={(v) => setTheme(v as ThemeAppearance)} options={options} />
|
||||
<Context.Provider value={{setTheme}}>
|
||||
<ThemeProvider appearance={appearance} >
|
||||
<App>
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePages/>}/>
|
||||
<Route path="/" element={<Layout />}>
|
||||
<Route index element={<HomePages/>}/>
|
||||
</Route>
|
||||
</Routes>
|
||||
</App>
|
||||
</ThemeProvider>
|
||||
</Context.Provider>
|
||||
</div>
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
export default App
|
||||
export default AppDefault
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import {useContext} from "react";
|
||||
import {ThemeAppearance, useTheme} from "antd-style";
|
||||
import {Segmented} from "antd";
|
||||
import {Context} from "../../store";
|
||||
|
||||
|
||||
const options = [
|
||||
{ label: 'Light', value: 'light' },
|
||||
{ label: 'Dark', value: 'dark' },
|
||||
];
|
||||
function Header() {
|
||||
const theme = useTheme();
|
||||
const { setTheme } = useContext(Context)
|
||||
return <header style={{
|
||||
background: theme.colorBgLayout,
|
||||
width: '100%',
|
||||
border: 'none',
|
||||
display: 'flex',
|
||||
justifyContent: 'end'
|
||||
}}><Segmented onChange={(v) => setTheme(v as ThemeAppearance)} options={options} /></header>;
|
||||
}
|
||||
|
||||
export default Header;
|
||||
@@ -0,0 +1,25 @@
|
||||
import {Button} from 'antd';
|
||||
import {useTheme} from 'antd-style';
|
||||
|
||||
|
||||
|
||||
const Main= () => {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
background: theme.colorBgLayout,
|
||||
minHeight: '100vh',
|
||||
display: 'flex',
|
||||
justifyContent: 'center'
|
||||
}}>
|
||||
|
||||
<Button ghost type={'primary'}>
|
||||
Border
|
||||
</Button>
|
||||
<div>Проверка шрифтов</div>
|
||||
<Button type={'primary'}>Primary</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default Main;
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import {BrowserRouter} from 'react-router-dom';
|
||||
import App from './components/App.tsx'
|
||||
import './index.css'
|
||||
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
<App/>
|
||||
</BrowserRouter>,
|
||||
)
|
||||
@@ -1,7 +1,10 @@
|
||||
import Main from "../../components/Main/Main.tsx";
|
||||
|
||||
import Layout from '../Layout/Layout.tsx';
|
||||
function HomePages() {
|
||||
return <Layout />;
|
||||
return (
|
||||
<>
|
||||
<Main/>
|
||||
</>);
|
||||
}
|
||||
|
||||
export default HomePages;
|
||||
@@ -1,22 +1,13 @@
|
||||
import { App, Button } from 'antd';
|
||||
import { useTheme } from 'antd-style';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import Header from "../../components/Header/Header.tsx";
|
||||
|
||||
|
||||
|
||||
const Layout= () => {
|
||||
const theme = useTheme();
|
||||
function Layout() {
|
||||
return (
|
||||
<App>
|
||||
<div style={{
|
||||
background: theme.colorBgLayout,
|
||||
minHeight: '100vh'
|
||||
}}>
|
||||
<Button ghost type={'primary'}>
|
||||
Border
|
||||
</Button>
|
||||
<Button type={'primary'}>Primary</Button>
|
||||
<div style={{minHeight: 'calc(100vh - 96px)'}}>
|
||||
<Header/>
|
||||
<Outlet/>
|
||||
</div>
|
||||
</App>
|
||||
);
|
||||
};
|
||||
export default Layout;
|
||||
}
|
||||
|
||||
export default Layout;
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Dispatch, SetStateAction, createContext } from 'react'
|
||||
export interface ContextProps {
|
||||
setTheme: Dispatch<SetStateAction<'dark' | 'light' | string>>
|
||||
}
|
||||
export const Context = createContext<ContextProps>({
|
||||
setTheme: () => 'light'
|
||||
})
|
||||
Reference in new issue
Block a user