11import { useEffect } from "react" ;
2- import { BrowserRouter , Routes , Route } from "react-router-dom" ;
2+ import { BrowserRouter , Routes , Route , useLocation } from "react-router-dom" ;
33import BleConnectButtonContainer from "./features/deviceBLEconnection/BleContainer" ;
44import VolcanoLoaderLoader from "./features/shared/OutletRenderer/VolcanoLoaderLoader" ;
55import Volcano from "./features/deviceInteraction/DeviceInteraction" ;
6- import { DeviceInformationWithToggleControls } from "./features/deviceInformation/DeviceInformation" ;
76import ContactMe from "./features/contactMe/ContactMe" ;
87import { clearCache } from "./services/BleCharacteristicCache" ;
98import "bootstrap/dist/css/bootstrap.min.css" ;
109import Settings from "./features/settings/Settings" ;
11- import styled from "styled-components" ;
10+ import styled , { createGlobalStyle } from "styled-components" ;
1211import { ThemeProvider } from "styled-components" ;
1312import { useSelector } from "react-redux" ;
1413import GetTheme from "./themes/ThemeProvider" ;
@@ -19,6 +18,9 @@ import { TouchBackend } from "react-dnd-touch-backend";
1918import Snowfall from "./features/shared/Snowfall" ;
2019import { isMobile } from "./constants/constants" ;
2120import DragPreview from "./features/workflowEditor/DND/DragPreview" ;
21+ import MinimalistLayout from "./features/shared/MinimalistLayout" ;
22+ import { convertToFahrenheitFromCelsius } from "./services/utils" ;
23+ import { DEGREE_SYMBOL , MIN_CELSIUS_TEMP , MAX_CELSIUS_TEMP } from "./constants/temperature" ;
2224const Div = styled . div `
2325 color: ${ ( props ) => props . theme . primaryFontColor } ;
2426 background-color: ${ ( props ) => props . theme . backgroundColor } ;
@@ -27,6 +29,63 @@ const Div = styled.div`
2729 display: flex;
2830` ;
2931
32+ const GlobalStyle = createGlobalStyle `
33+ /* Custom scrollbar styling for Webkit browsers */
34+ *::-webkit-scrollbar {
35+ width: 10px;
36+ height: 10px;
37+ }
38+
39+ *::-webkit-scrollbar-track {
40+ background: ${ props => props . theme . backgroundColor } ;
41+ border-radius: 5px;
42+ }
43+
44+ *::-webkit-scrollbar-thumb {
45+ background: ${ props => props . theme . buttonColorMain || props . theme . borderColor } ;
46+ border-radius: 5px;
47+ border: 1px solid ${ props => props . theme . borderColor } ;
48+ }
49+
50+ *::-webkit-scrollbar-thumb:hover {
51+ background: ${ props => props . theme . buttonActive ?. backgroundColor || props . theme . primaryFontColor } ;
52+ }
53+
54+ *::-webkit-scrollbar-corner {
55+ background: ${ props => props . theme . backgroundColor } ;
56+ }
57+
58+ /* Firefox scrollbar styling */
59+ * {
60+ scrollbar-width: thin;
61+ scrollbar-color: ${ props => props . theme . buttonColorMain || props . theme . borderColor } ${ props => props . theme . backgroundColor } ;
62+ }
63+ ` ;
64+
65+ function AppRoutes ( { isMinimalistMode } ) {
66+ const location = useLocation ( ) ;
67+
68+ // Show minimalist mode only when connected (not on home page)
69+ const shouldShowMinimalistMode = isMinimalistMode && location . pathname !== "/" ;
70+
71+ if ( shouldShowMinimalistMode ) {
72+ return < MinimalistLayout /> ;
73+ }
74+
75+ return (
76+ < Routes >
77+ < Route path = "/" element = { < BleConnectButtonContainer /> } />
78+ < Route path = "Volcano" element = { < VolcanoLoaderLoader /> } >
79+ < Route path = "App" element = { < Volcano /> } />
80+ < Route path = "Settings" element = { < Settings /> } />
81+ < Route path = "WorkflowEditor" element = { < WorkflowEditor /> } />
82+ < Route path = "ContactMe" element = { < ContactMe /> } />
83+ </ Route >
84+ < Route path = "*" element = { < BleConnectButtonContainer /> } />
85+ </ Routes >
86+ ) ;
87+ }
88+
3089function App ( ) {
3190 useEffect ( ( ) => {
3291 window . onunhandledrejection = ( event ) => {
@@ -38,34 +97,64 @@ function App() {
3897 const themeId = useSelector (
3998 ( state ) => state . settings . config ?. currentTheme || GetTheme ( ) . themeId
4099 ) ;
100+ const isMinimalistMode = useSelector ( ( state ) => state . settings . config ?. isMinimalistMode || false ) ;
101+
102+ // Temperature state for page title
103+ const currentTemperature = useSelector ( ( state ) => state . deviceInteraction . currentTemperature ) ;
104+ const targetTemperature = useSelector ( ( state ) => state . deviceInteraction . targetTemperature ) ;
105+ const isF = useSelector ( ( state ) => state . settings . isF ) ;
106+ const isHeatOn = useSelector ( ( state ) => state . deviceInteraction . isHeatOn ) ;
41107
42108 useEffect ( ( ) => {
43109 document . body . style = `background: ${ GetTheme ( themeId ) . backgroundColor } ;` ;
44110 } , [ themeId ] ) ;
45111
112+ // Update page title with current and target temperature (works for both regular and minimalist mode)
113+ useEffect ( ( ) => {
114+ const currentTemp = currentTemperature || currentTemperature === 0
115+ ? isF
116+ ? convertToFahrenheitFromCelsius ( currentTemperature )
117+ : currentTemperature
118+ : currentTemperature ;
119+
120+ const targetTemp = targetTemperature || targetTemperature === 0
121+ ? isF
122+ ? convertToFahrenheitFromCelsius ( targetTemperature )
123+ : targetTemperature
124+ : targetTemperature ;
125+
126+ const showCurrentTemp = ( ! isNaN ( parseInt ( currentTemperature ) ) &&
127+ currentTemperature > MIN_CELSIUS_TEMP &&
128+ currentTemperature <= MAX_CELSIUS_TEMP ) || isHeatOn ;
129+
130+ const displayCurrentTemperature = currentTemp && ! isNaN ( parseInt ( currentTemp ) )
131+ ? Math . round ( currentTemp )
132+ : null ;
133+
134+ const displayTargetTemperature = targetTemp && ! isNaN ( parseInt ( targetTemp ) )
135+ ? Math . round ( targetTemp )
136+ : null ;
137+
138+ if ( displayCurrentTemperature && displayTargetTemperature && showCurrentTemp ) {
139+ document . title = `${ displayCurrentTemperature } /${ displayTargetTemperature } ${ DEGREE_SYMBOL } ${ isF ? "F" : "C" } - Onyx` ;
140+ } else if ( displayCurrentTemperature && showCurrentTemp ) {
141+ document . title = `${ displayCurrentTemperature } ${ DEGREE_SYMBOL } ${ isF ? "F" : "C" } - Onyx` ;
142+ } else {
143+ document . title = "Onyx" ;
144+ }
145+ } , [ currentTemperature , targetTemperature , isF , isHeatOn ] ) ;
146+
46147 return (
47148 < >
48149 < DndProvider
49150 backend = { window . ontouchstart || isMobile ? TouchBackend : HTML5Backend }
50151 >
51152 < ThemeProvider theme = { GetTheme ( themeId ) } >
153+ < GlobalStyle />
52154 < DragPreview />
53155 < Div >
54156 < BrowserRouter >
55- < Routes >
56- < Route path = "/" element = { < BleConnectButtonContainer /> } />
57- < Route path = "Volcano" element = { < VolcanoLoaderLoader /> } >
58- < Route path = "App" element = { < Volcano /> } />
59- < Route
60- path = "DeviceInformation"
61- element = { < DeviceInformationWithToggleControls /> }
62- />
63- < Route path = "Settings" element = { < Settings /> } />
64- < Route path = "WorkflowEditor" element = { < WorkflowEditor /> } />
65- < Route path = "ContactMe" element = { < ContactMe /> } />
66- </ Route >
67- < Route path = "*" element = { < BleConnectButtonContainer /> } />
68- </ Routes >
157+ < AppRoutes isMinimalistMode = { isMinimalistMode } />
69158 </ BrowserRouter >
70159 </ Div >
71160 </ ThemeProvider >
0 commit comments