color pallete

This commit is contained in:
2026-04-07 13:47:55 +05:30
parent b1db439dda
commit 82264a5c34
4 changed files with 52 additions and 6 deletions

View File

@@ -29,6 +29,20 @@ export default function Dashboard() {
expense: [], expense: [],
income: [] income: []
}); });
const palette = {
expense: {
primary: "#d32f2f",
light: "#fdecea",
dark: "#9a0007",
text: "#b71c1c"
},
income: {
primary: "#2e7d32",
light: "#e8f5e9",
dark: "#1b5e20",
text: "#1b5e20"
}
};
const [aggregated, setAggregated] = React.useState<{ const [aggregated, setAggregated] = React.useState<{
expense: AggregatedDashboardData | null; expense: AggregatedDashboardData | null;
@@ -45,6 +59,7 @@ export default function Dashboard() {
const [loading, setLoading] = React.useState(true); const [loading, setLoading] = React.useState(true);
const [error, setError] = React.useState<string | null>(null); const [error, setError] = React.useState<string | null>(null);
const colors = palette[mode];
// -------- LOAD ONCE -------- // -------- LOAD ONCE --------
React.useEffect(() => { React.useEffect(() => {
async function loadData() { async function loadData() {
@@ -112,13 +127,35 @@ export default function Dashboard() {
} }
return ( return (
<Container sx={{ mt: 4, mb: 4 }}> <Container
sx={{
mt: 4,
mb: 4,
background: `linear-gradient(180deg, ${colors.light} 0%, transparent 100%)`,
borderRadius: 4,
p: 2
}}
>
{/* -------- TOGGLE -------- */} {/* -------- TOGGLE -------- */}
<Box sx={{ display: "flex", justifyContent: "center", mb: 3 }}> <Box sx={{ display: "flex", justifyContent: "center", mb: 3 }}>
<ToggleButtonGroup <ToggleButtonGroup
value={mode} value={mode}
exclusive exclusive
onChange={(_, val) => val && setMode(val)} onChange={(_, val) => val && setMode(val)}
sx={{
borderRadius: 3,
overflow: "hidden",
"& .MuiToggleButton-root": {
px: 3,
textTransform: "none",
color: "text.secondary"
},
"&.Mui-selected": {
bgcolor: colors.primary,
color: "white",
borderColor: colors.primary
},
}}
> >
<ToggleButton value="expense">Expenses</ToggleButton> <ToggleButton value="expense">Expenses</ToggleButton>
<ToggleButton value="income">Income</ToggleButton> <ToggleButton value="income">Income</ToggleButton>
@@ -137,6 +174,7 @@ export default function Dashboard() {
onPeriodChange={setPeriod} onPeriodChange={setPeriod}
comparison={comparison} comparison={comparison}
setComparison={setComparison} setComparison={setComparison}
colorScheme={colors}
/> />
</Grid> </Grid>
@@ -145,6 +183,7 @@ export default function Dashboard() {
title={`Recent ${mode === "expense" ? "Expenses" : "Income"}`} title={`Recent ${mode === "expense" ? "Expenses" : "Income"}`}
items={currentLatest} items={currentLatest}
onViewAll={() => {}} onViewAll={() => {}}
accentColor={colors.primary}
/> />
</Grid> </Grid>

View File

@@ -72,6 +72,7 @@ export default function HistoryChart({
onPeriodChange, onPeriodChange,
comparison, comparison,
setComparison, setComparison,
colorScheme,
}: HistoryChartProps) { }: HistoryChartProps) {
const [activeTab, setActiveTab] = React.useState<string>(tabs[0] || ""); const [activeTab, setActiveTab] = React.useState<string>(tabs[0] || "");
@@ -141,10 +142,11 @@ export default function HistoryChart({
width: "100%", width: "100%",
boxShadow: "none", boxShadow: "none",
border: "1px solid", border: "1px solid",
borderColor: "divider" borderColor: "divider",
bgcolor: colorScheme.light,
}} }}
> >
<Typography variant="h6" fontWeight={700} gutterBottom> <Typography variant="h6" fontWeight={700} gutterBottom color={colorScheme.text}>
{header} {header}
</Typography> </Typography>
@@ -296,7 +298,7 @@ export default function HistoryChart({
sx={{ sx={{
width: 6, width: 6,
height: `${compareHeight}%`, height: `${compareHeight}%`,
bgcolor: "grey.400", bgcolor: `${colorScheme.primary}55`,
borderRadius: 2 borderRadius: 2
}} }}
/> />
@@ -310,7 +312,9 @@ export default function HistoryChart({
sx={{ sx={{
width: 10, width: 10,
height: `${currentHeight}%`, height: `${currentHeight}%`,
bgcolor: point.highlighted ? "error.main" : "primary.main", bgcolor: point.highlighted
? colorScheme.primary
: `${colorScheme.primary}99`,
borderRadius: 2 borderRadius: 2
}} }}
/> />

View File

@@ -24,12 +24,14 @@ export interface LatestItemsListProps {
title?: string; title?: string;
items: LatestItem[]; items: LatestItem[];
onViewAll?: () => void; onViewAll?: () => void;
accentColor: any;
} }
export default function LatestItemsList({ export default function LatestItemsList({
title = "Recent Transactions", title = "Recent Transactions",
items, items,
onViewAll, onViewAll,
accentColor,
}: LatestItemsListProps) { }: LatestItemsListProps) {
return ( return (
<Box sx={{ width: "100%", bgcolor: "background.paper", borderRadius: 4, p: 2 }}> <Box sx={{ width: "100%", bgcolor: "background.paper", borderRadius: 4, p: 2 }}>
@@ -69,7 +71,7 @@ export default function LatestItemsList({
<Avatar <Avatar
variant="rounded" variant="rounded"
sx={{ sx={{
bgcolor: item.iconBgColor || "grey.200", bgcolor: `${accentColor}22`,
color: "inherit", color: "inherit",
width: 48, width: 48,
height: 48, height: 48,

View File

@@ -33,4 +33,5 @@ export interface HistoryChartProps {
onPeriodChange: (mode: "rolling" | "calendar") => void; onPeriodChange: (mode: "rolling" | "calendar") => void;
comparison: boolean; comparison: boolean;
setComparison: (mode: boolean) => void; setComparison: (mode: boolean) => void;
colorScheme: any;
} }