theme fixes

This commit is contained in:
2026-04-04 16:00:33 +05:30
parent 3771eb7dca
commit 86e5bc6429
5 changed files with 168 additions and 34 deletions

View File

@@ -8,7 +8,6 @@ import { getAppConfig } from "./config";
import { initializeApiClients } from "./api/client"; import { initializeApiClients } from "./api/client";
import { AppConfig } from "./types/config"; import { AppConfig } from "./types/config";
import { Box, Typography, Paper, CircularProgress } from "@mui/material"; import { Box, Typography, Paper, CircularProgress } from "@mui/material";
import AppTheme from "./shared-theme/AppTheme";
import { import {
Routes, Routes,
Route, Route,
@@ -126,30 +125,26 @@ export default function Admin({ basePath = "/admin" }: { basePath?: string }) {
if (!config) { if (!config) {
return ( return (
<AppTheme> <Box
<Box sx={{
sx={{ display: "flex",
display: "flex", justifyContent: "center",
justifyContent: "center", alignItems: "center",
alignItems: "center", height: "100vh",
height: "100vh", }}
}} >
> <CircularProgress />
<CircularProgress /> </Box>
</Box>
</AppTheme>
); );
} }
return ( return (
<AppTheme> <QueryClientProvider client={queryClient}>
<QueryClientProvider client={queryClient}> <ConfigContext.Provider value={config}>
<ConfigContext.Provider value={config}> <UploadProvider>
<UploadProvider> <AdminApp basePath={basePath} />
<AdminApp basePath={basePath} /> </UploadProvider>
</UploadProvider> </ConfigContext.Provider>
</ConfigContext.Provider> </QueryClientProvider>
</QueryClientProvider>
</AppTheme>
); );
} }

View File

@@ -1,13 +1,48 @@
import * as React from "react"; import * as React from "react";
import { ThemeProvider, createTheme } from "@mui/material/styles"; import { ThemeProvider, createTheme } from "@mui/material/styles";
import { getDesignTokens } from "./shared-theme/themePrimitives";
import { inputsCustomizations } from "./shared-theme/customizations/inputs";
import { dataDisplayCustomizations } from "./shared-theme/customizations/dataDisplay";
import { feedbackCustomizations } from "./shared-theme/customizations/feedback";
import { navigationCustomizations } from "./shared-theme/customizations/navigation";
import { surfacesCustomizations } from "./shared-theme/customizations/surfaces";
const theme = createTheme({ export const ColorModeContext = React.createContext({
palette: { toggleColorMode: () => {},
// mode: "light", // or "dark" mode: "light" as "light" | "dark",
mode: "dark", // or "dark"
},
}); });
export default function AppTheme({ children }: { children: React.ReactNode }) { export default function AppTheme({ children }: { children: React.ReactNode }) {
return <ThemeProvider theme={theme}>{children}</ThemeProvider>; const [mode, setMode] = React.useState<"light" | "dark">("light");
const colorMode = React.useMemo(
() => ({
toggleColorMode: () => {
setMode((prevMode) => (prevMode === "light" ? "dark" : "light"));
},
mode,
}),
[mode]
);
const theme = React.useMemo(
() =>
createTheme({
...getDesignTokens(mode),
components: {
...inputsCustomizations,
...dataDisplayCustomizations,
...feedbackCustomizations,
...navigationCustomizations,
...surfacesCustomizations,
},
}),
[mode]
);
return (
<ColorModeContext.Provider value={colorMode}>
<ThemeProvider theme={theme}>{children}</ThemeProvider>
</ColorModeContext.Provider>
);
} }

View File

@@ -40,7 +40,6 @@ export default function Footer() {
flexDirection: 'column', flexDirection: 'column',
alignItems: 'center', alignItems: 'center',
gap: { xs: 2, sm: 4 }, gap: { xs: 2, sm: 4 },
py: { xs: 2, sm: 4 },
textAlign: { sm: 'center', md: 'left' }, textAlign: { sm: 'center', md: 'left' },
}} }}
> >

View File

@@ -16,8 +16,11 @@ import {
} from "@mui/material"; } from "@mui/material";
import MenuIcon from "@mui/icons-material/Menu"; import MenuIcon from "@mui/icons-material/Menu";
import LogoutIcon from "@mui/icons-material/Logout"; import LogoutIcon from "@mui/icons-material/Logout";
import DarkModeIcon from "@mui/icons-material/DarkMode";
import LightModeIcon from "@mui/icons-material/LightMode";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useAuth } from "../react-auth"; import { useAuth } from "../react-auth";
import { ColorModeContext } from "./AppTheme";
interface HeaderProps { interface HeaderProps {
routerMapping: { routerMapping: {
@@ -39,6 +42,7 @@ export default function Header({
const navigate = useNavigate(); const navigate = useNavigate();
const { currentUser, logout } = useAuth(); const { currentUser, logout } = useAuth();
const { mode, toggleColorMode } = React.useContext(ColorModeContext);
const theme = useTheme(); const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("md")); const isMobile = useMediaQuery(theme.breakpoints.down("md"));
@@ -70,6 +74,11 @@ export default function Header({
</IconButton> </IconButton>
)} )}
{/* THEME TOGGLE */}
<IconButton onClick={toggleColorMode} color="inherit" sx={{ mr: 2 }}>
{mode === 'dark' ? <LightModeIcon /> : <DarkModeIcon />}
</IconButton>
{/* TITLE */} {/* TITLE */}
<Typography <Typography
variant="h6" variant="h6"

View File

@@ -1,12 +1,108 @@
import * as React from "react"; import * as React from "react";
import { Box, Typography } from '@mui/material'; import { Box, Typography, Button, Container, Stack } from "@mui/material";
import { useNavigate } from "react-router-dom";
import ArrowForwardIcon from "@mui/icons-material/ArrowForward";
export default function Home() { export default function Home() {
const navigate = useNavigate();
return ( return (
<Box sx={{ p: 4 }}> <Box
<Typography variant="h1" gutterBottom> sx={{
Welcome to Khata width: "100%",
</Typography> minHeight: "calc(100vh - 64px)", // accounting for header
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "relative",
overflow: "hidden",
"&::before": {
content: '""',
position: "absolute",
top: "-20%",
left: "-10%",
width: "50%",
height: "60%",
background: "radial-gradient(circle, rgba(99,102,241,0.15) 0%, rgba(0,0,0,0) 70%)",
zIndex: 0,
},
"&::after": {
content: '""',
position: "absolute",
bottom: "-20%",
right: "-10%",
width: "50%",
height: "60%",
background: "radial-gradient(circle, rgba(236,72,153,0.15) 0%, rgba(0,0,0,0) 70%)",
zIndex: 0,
},
}}
>
<Container maxWidth="lg" sx={{ position: "relative", zIndex: 1 }}>
<Stack
spacing={4}
alignItems="center"
textAlign="center"
sx={{
p: { xs: 4, md: 8 },
backdropFilter: "blur(20px)",
backgroundColor: (theme) =>
theme.palette.mode === "dark" ? "rgba(255, 255, 255, 0.03)" : "rgba(255, 255, 255, 0.6)",
border: "1px solid",
borderColor: "divider",
borderRadius: 4,
boxShadow: (theme) =>
theme.palette.mode === "dark"
? "0 8px 32px 0 rgba(0, 0, 0, 0.37)"
: "0 8px 32px 0 rgba(31, 38, 135, 0.07)",
}}
>
<Typography
variant="h1"
sx={{
fontWeight: 800,
fontSize: { xs: "3rem", md: "5rem" },
background: "linear-gradient(45deg, #6366f1 30%, #ec4899 90%)",
WebkitBackgroundClip: "text",
WebkitTextFillColor: "transparent",
mb: 2,
}}
>
Welcome to Khata
</Typography>
<Typography
variant="h5"
color="text.secondary"
sx={{ maxWidth: "600px", lineHeight: 1.6 }}
>
Your intelligent, extensible financial ledger. Control accounts, manage transactions, and track your data dynamically with our OpenAPI-driven architecture.
</Typography>
<Box mt={4}>
<Button
variant="contained"
size="large"
endIcon={<ArrowForwardIcon />}
onClick={() => navigate("/admin")}
sx={{
px: 4,
py: 1.5,
borderRadius: "50px",
fontWeight: "bold",
background: "linear-gradient(45deg, #6366f1 30%, #ec4899 90%)",
transition: "transform 0.2s ease-in-out, box-shadow 0.2s",
"&:hover": {
transform: "translateY(-3px)",
boxShadow: "0 8px 20px rgba(236,72,153,0.4)",
},
}}
>
Enter Dashboard
</Button>
</Box>
</Stack>
</Container>
</Box> </Box>
); );
} }