Skip to content

Commit fdb6be7

Browse files
Fran McDadeFran McDade
authored andcommitted
fix: highlight selected page in topnav (#53)
1 parent 9fc1f53 commit fdb6be7

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

app/theme/common/palette.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PaletteColorOptions } from "@mui/material";
1+
import { PaletteColor } from "@mui/material";
22

33
/**
44
* Palette "Hero"
@@ -17,7 +17,9 @@ export const heroMain = HERO.MAIN;
1717
/**
1818
* Palette Option "Hero"
1919
*/
20-
export const hero: PaletteColorOptions = {
20+
export const hero: PaletteColor = {
21+
contrastText: "#FFFFFF",
22+
dark: heroMain,
2123
light: heroLight,
2224
main: heroMain,
2325
};

app/theme/theme.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@ import * as P from "./common/palette";
99
* @returns theme with custom theme overrides.
1010
*/
1111
export function mergeAppTheme(theme: Theme): Theme {
12-
return createTheme(
13-
deepmerge(theme, {
14-
components: {
15-
MuiButton: C.MuiButton(theme),
16-
MuiCssBaseline: C.MuiCssBaseline(theme),
17-
},
18-
palette: {
19-
hero: P.hero,
20-
},
21-
})
22-
);
12+
const appTheme = { ...theme };
13+
14+
// Merge palette with hero color.
15+
appTheme.palette = { ...appTheme.palette, hero: P.hero };
16+
17+
// Marge custom components.
18+
const components = {
19+
MuiButton: C.MuiButton(appTheme),
20+
MuiCssBaseline: C.MuiCssBaseline(appTheme),
21+
};
22+
23+
return createTheme(deepmerge(appTheme, components));
2324
}

types/theme.d.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import { Theme as MTheme } from "@mui/material";
2-
3-
/**
4-
* Button prop options.
5-
*/
6-
declare module "@mui/material/Button" {
7-
interface ButtonPropsColorOverrides {
8-
hero: true;
9-
}
10-
}
1+
import type {} from "@mui/material/Button";
2+
import { PaletteColorOptions } from "@mui/material/styles";
113

124
/**
135
* Palette definitions.
@@ -22,6 +14,15 @@ declare module "@mui/material/styles/createPalette" {
2214
}
2315
}
2416

17+
/**
18+
* Button prop options.
19+
*/
20+
declare module "@mui/material/Button" {
21+
interface ButtonPropsColorOverrides {
22+
hero: true;
23+
}
24+
}
25+
2526
declare module "@emotion/react" {
2627
export interface Theme extends MTheme {
2728
name: "EmotionTheme";

0 commit comments

Comments
 (0)