Skip to content

Commit e57a40f

Browse files
committed
Add default night mode setting
1 parent c964621 commit e57a40f

5 files changed

Lines changed: 6 additions & 1 deletion

File tree

Plan/common/src/main/java/com/djrapitops/plan/delivery/webserver/resolver/json/metadata/MetadataJSONResolver.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ private Response getResponse() {
9797
.put("timeZoneOffsetMinutes", config.getTimeZoneOffsetHours() * 60)
9898
.put("contributors", Contributors.getContributors())
9999
.put("defaultTheme", config.get(DisplaySettings.THEME))
100+
.put("defaultNightMode", config.get(DisplaySettings.NIGHT_MODE))
100101
.put("availableThemes", getAvailableThemes())
101102
.put("gmPieColors", theme.getDefaultPieColors(ThemeVal.GRAPH_GM_PIE))
102103
.put("playerHeadImageUrl", config.get(DisplaySettings.PLAYER_HEAD_IMG_URL))

Plan/common/src/main/java/com/djrapitops/plan/settings/config/paths/DisplaySettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public class DisplaySettings {
2828

2929
public static final Setting<String> THEME = new StringSetting("Display_options.Theme");
30+
public static final Setting<Boolean> NIGHT_MODE = new BooleanSetting("Display_options.Night_mode");
3031
public static final Setting<String> PLAYER_HEAD_IMG_URL = new StringSetting("Display_options.Player_head_image_url");
3132
public static final Setting<Integer> SESSIONS_PER_PAGE = new IntegerSetting("Display_options.Sessions.Show_on_page");
3233
public static final Setting<Boolean> ORDER_WORLD_PIE_BY_PERCENTAGE = new BooleanSetting("Display_options.Sessions.Order_world_pies_by_percentage");

Plan/common/src/main/resources/assets/plan/bungeeconfig.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ Display_options:
176176
# More information about Themes:
177177
# https://github.com/plan-player-analytics/Plan/wiki/Themes
178178
Theme: default
179+
Night_mode: false
179180
# Can use ${playerName} or ${playerUUID} or ${playerUUIDNoDash}
180181
Player_head_image_url: "https://crafatar.com/avatars/${playerUUID}?size=120&default=MHF_Steve&overlay"
181182
Sessions:

Plan/common/src/main/resources/assets/plan/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ Display_options:
180180
# More information about Themes:
181181
# https://github.com/plan-player-analytics/Plan/wiki/Themes
182182
Theme: default
183+
Night_mode: false
183184
# Can use ${playerName} or ${playerUUID} or ${playerUUIDNoDash}
184185
Player_head_image_url: "https://crafatar.com/avatars/${playerUUID}?size=120&default=MHF_Steve&overlay"
185186
Sessions:

Plan/react/dashboard/src/hooks/themeHook.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const setStoredColor = themeColor => {
2626

2727
const getStoredNightMode = () => {
2828
const stored = window.localStorage.getItem('theme.nightMode');
29-
return stored && stored !== 'undefined' ? stored !== 'false' : false;
29+
return stored && stored !== 'undefined' ? stored !== 'false' : undefined;
3030
}
3131

3232
const setStoredNightMode = value => {
@@ -54,6 +54,7 @@ export const ThemeContextProvider = ({children, themeOverride}) => {
5454
if (themeOverride) return;
5555
const theme = getStoredTheme(metadata.defaultTheme);
5656
const invalidTheme = !metadata.getAvailableThemes().includes(theme);
57+
if (nightMode === undefined) setNightMode(metadata.defaultNightMode);
5758
setSelectedTheme(invalidTheme ? 'default' : theme);
5859
setSelectedColor(getStoredColor());
5960
}, [metadata.loaded, metadata, setSelectedTheme, setSelectedColor]);

0 commit comments

Comments
 (0)