Skip to content

Commit 2f2ce34

Browse files
authored
Merge pull request #3132 from bluewave-labs/fix/theme-simplification-and-bug-fixes
Simplify theme and fix Redux state bugs
2 parents d82877b + 8b2ee8d commit 2f2ce34

File tree

9 files changed

+17
-77
lines changed

9 files changed

+17
-77
lines changed

client/src/Components/LanguageSelector.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const langMap = {
1616
const LanguageSelector = () => {
1717
const { i18n } = useTranslation();
1818
const theme = useTheme();
19-
const { language } = useSelector((state) => state.ui);
19+
const { language = "en" } = useSelector((state) => state.ui);
2020
const dispatch = useDispatch();
2121
const handleChange = (event) => {
2222
const newLang = event.target.value;

client/src/Components/v1/I18nLoader/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import i18n from "../../../Utils/i18n.js";
22
import { useSelector } from "react-redux";
33
import { useEffect } from "react";
44
const I18nLoader = () => {
5-
const language = useSelector((state) => state.ui.language);
5+
const language = useSelector((state) => state.ui.language ?? "en");
66

77
useEffect(() => {
88
if (language && i18n.language !== language) {

client/src/Components/v1/Sidebar/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const Sidebar = () => {
8484
const { t } = useTranslation();
8585
const navigate = useNavigate();
8686
// Redux state
87-
const collapsed = useSelector((state) => state.ui.sidebar.collapsed);
87+
const collapsed = useSelector((state) => state.ui.sidebar?.collapsed ?? false);
8888

8989
const menu = getMenu(t);
9090
const otherMenuItems = getOtherMenuItems(t);

client/src/Features/UI/uiSlice.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ const uiSlice = createSlice({
5858
state.showURL = action.payload;
5959
},
6060
setGreeting(state, action) {
61+
if (!state.greeting) {
62+
state.greeting = { index: 0, lastUpdate: null };
63+
}
6164
state.greeting.index = action.payload.index;
6265
state.greeting.lastUpdate = action.payload.lastUpdate;
6366
},

client/src/Pages/PageSpeed/Monitors/Components/MonitorGrid/index.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Grid, Grid2 } from "@mui/material";
1+
import { Grid } from "@mui/material";
22
import Card from "../Card/index.jsx";
33

4-
const MonitorGrid = ({ shouldRender, monitors }) => {
5-
console.log(monitors);
4+
const MonitorGrid = ({ monitors, shouldRender = true }) => {
5+
if (!shouldRender) return null;
6+
67
return (
78
<Grid
89
container
@@ -11,7 +12,7 @@ const MonitorGrid = ({ shouldRender, monitors }) => {
1112
{monitors?.map((monitor) => (
1213
<Card
1314
monitor={monitor}
14-
key={monitor._id}
15+
key={monitor._id || monitor.id}
1516
/>
1617
))}
1718
</Grid>

client/src/Pages/Settings/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const BREADCRUMBS = [{ name: `Settings`, path: "/settings" }];
3333

3434
const Settings = () => {
3535
// Redux state
36-
const { mode, language, timezone, showURL } = useSelector((state) => state.ui);
36+
const { mode, language = "en", timezone, showURL } = useSelector((state) => state.ui);
3737

3838
// Local state
3939
const [settingsData, setSettingsData] = useState({});

client/src/Utils/Theme/constants.js

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { lighten, darken } from "@mui/material/styles"; // CAIO_REVIEW
1+
import { lighten } from "@mui/material/styles"; // CAIO_REVIEW
22

33
const typographyBase = 13;
44

@@ -133,12 +133,6 @@ const newSemanticColors = {
133133
light: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW
134134
dark: lighten(newColors.blueBlueWave, 0.2), //CAIO_REVIEW
135135
},
136-
darker: {
137-
// CAIO_REVIEW
138-
light: darken(newColors.blueBlueWave, 0.2), // CAIO_REVIEW
139-
dark: darken(newColors.blueBlueWave, 0.2), // CAIO_REVIEW
140-
},
141-
142136
contrastText: {
143137
light: newColors.offWhite,
144138
dark: newColors.offWhite,
@@ -165,14 +159,6 @@ const newSemanticColors = {
165159
light: newColors.blueGray500,
166160
dark: newColors.gray500,
167161
},
168-
contrastBorder: {
169-
light: newColors.gray500,
170-
dark: newColors.blueGray600,
171-
},
172-
contrastBorderDisabled: {
173-
light: newColors.gray100,
174-
dark: newColors.blueGray800,
175-
},
176162
lowContrast: {
177163
light: newColors.gray250,
178164
dark: newColors.blueGray600,
@@ -207,18 +193,6 @@ const newSemanticColors = {
207193
light: newColors.blueGray800,
208194
dark: newColors.gray100,
209195
},
210-
background: {
211-
light: newColors.gray50,
212-
dark: newColors.offBlack,
213-
},
214-
border: {
215-
light: newColors.gray500,
216-
dark: newColors.blueGray600,
217-
},
218-
cardShadow: {
219-
light: "0 0 0 1px rgba(0, 0, 0, 0.04), 0 12px 24px rgba(0, 0, 0, 0.08)",
220-
dark: "0 2px 10px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.04)",
221-
},
222196
},
223197
success: {
224198
main: {
@@ -234,20 +208,6 @@ const newSemanticColors = {
234208
dark: newColors.green200,
235209
},
236210
},
237-
successSecondary: {
238-
main: {
239-
light: undefined,
240-
dark: "#073C2D",
241-
},
242-
contrastText: {
243-
light: undefined,
244-
dark: "#34D399",
245-
},
246-
lowContrast: {
247-
light: undefined,
248-
dark: "#094434",
249-
},
250-
},
251211
warning: {
252212
main: {
253213
light: newColors.orange700,
@@ -316,30 +276,6 @@ const newSemanticColors = {
316276
},
317277
},
318278

319-
map: {
320-
main: {
321-
light: newColors.offWhite,
322-
dark: undefined,
323-
},
324-
lowContrast: {
325-
light: newColors.gray200,
326-
dark: undefined,
327-
},
328-
highContrast: {
329-
light: newColors.gray500,
330-
dark: undefined,
331-
},
332-
},
333-
chatbot: {
334-
background: {
335-
light: newColors.gray200,
336-
dark: "#112B2B",
337-
},
338-
textAccent: {
339-
light: "#C084FC",
340-
dark: "#C084FC",
341-
},
342-
},
343279
alert: {
344280
main: {
345281
light: newColors.gray200,

client/src/Utils/Theme/globalTheme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const baseTheme = (palette) => ({
6464
letterSpacing: "0.5px",
6565
textShadow: "0 0 1px rgba(0, 0, 0, 0.15)",
6666
"&:hover": {
67-
backgroundColor: darken(theme.palette.accent.darker, 0.05),
67+
backgroundColor: darken(theme.palette.accent.main, 0.25),
6868
boxShadow: `0 2px 6px rgba(0, 0, 0, 0.1)`,
6969
transition: "all 0.2s ease-in-out",
7070
},
@@ -74,7 +74,7 @@ const baseTheme = (palette) => ({
7474
props: (props) => props.color === "accent",
7575
style: {
7676
"&:hover": {
77-
backgroundColor: theme.palette.accent.darker,
77+
backgroundColor: darken(theme.palette.accent.main, 0.2),
7878
},
7979
},
8080
},

client/src/Utils/greeting.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ const Greeting = ({ type = "" }) => {
136136
const dispatch = useDispatch();
137137
const { t } = useTranslation();
138138
const { firstName } = useSelector((state) => state.auth.user);
139-
const index = useSelector((state) => state.ui.greeting.index);
140-
const lastUpdate = useSelector((state) => state.ui.greeting.lastUpdate);
139+
const index = useSelector((state) => state.ui.greeting?.index ?? 0);
140+
const lastUpdate = useSelector((state) => state.ui.greeting?.lastUpdate ?? null);
141141

142142
const now = new Date();
143143
const hour = now.getHours();

0 commit comments

Comments
 (0)