Skip to content

Commit 1c282f8

Browse files
committed
fix: navbar background color
1 parent 9fc55dc commit 1c282f8

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

src/components/NavBar/index.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function NavBar(props: NavBarProps) {
2525
avatarAlt,
2626
avatarImage,
2727
title,
28-
color,
2928
onClick,
3029
handleTitleClick,
3130
position,
@@ -43,7 +42,7 @@ function NavBar(props: NavBarProps) {
4342
};
4443

4544
return (
46-
<AppBar color={color} position={position}>
45+
<AppBar color="navbar" position={position}>
4746
<Container maxWidth="xl">
4847
<Toolbar disableGutters>
4948
<Typography
@@ -96,7 +95,9 @@ function NavBar(props: NavBarProps) {
9695
>
9796
{pages.map((page: string) => (
9897
<MenuItem key={page} onClick={handleNavItemClick}>
99-
<Typography textAlign="center">{page}</Typography>
98+
<Typography textAlign="center" color="navbar.contrastColor">
99+
{page}
100+
</Typography>
100101
</MenuItem>
101102
))}
102103
</Menu>
@@ -124,7 +125,12 @@ function NavBar(props: NavBarProps) {
124125
<Button
125126
key={page}
126127
onClick={handleNavItemClick}
127-
sx={{ color: navItemColor, display: "block" }}
128+
sx={{
129+
display: "block",
130+
color: (theme) =>
131+
theme.palette.getContrastText(theme.palette.navbar.main),
132+
}}
133+
// color="navbar.contrastText"
128134
id={`blog-nav-item-${page}`}
129135
>
130136
{page}

src/components/NavBar/navbar.d.ts

+19
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,22 @@ export type NavBarProps = {
1818
handleTitleClick?: (event: BaseSyntheticEvent) => void;
1919
position?: "fixed" | "absolute" | "sticky" | "static" | "relative";
2020
};
21+
22+
declare module "@mui/material/AppBar" {
23+
interface AppBarPropsColorOverrides {
24+
blue: true;
25+
navbar: true;
26+
}
27+
}
28+
29+
declare module "@mui/material/styles" {
30+
interface Palette {
31+
blue: Palette["primary"];
32+
navbar: Palette["primary"];
33+
}
34+
35+
interface PaletteOptions {
36+
blue: PaletteOptions["primary"];
37+
navbar: PaletteOptions["primary"];
38+
}
39+
}
File renamed without changes.
File renamed without changes.

src/themes/light.theme.js src/themes/light.theme.ts

+16
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,26 @@
33
import { createTheme } from "@mui/material";
44
import components from "./components";
55

6+
declare module "@mui/material/styles" {
7+
interface Palette {
8+
blue: Palette["primary"];
9+
navbar: Palette["primary"];
10+
}
11+
12+
interface PaletteOptions {
13+
blue: PaletteOptions["primary"];
14+
navbar: PaletteOptions["primary"];
15+
}
16+
}
17+
618
export const lightTheme = createTheme({
719
components,
820
palette: {
921
mode: "light",
22+
navbar: {
23+
main: "#f5f5f5",
24+
// contrastText: '#999'
25+
},
1026
blue: {
1127
light: "#337ab7",
1228
main: "#0056b3",

0 commit comments

Comments
 (0)