-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: Moving sensor sub-components to internal folder
- Loading branch information
Showing
7 changed files
with
76 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function Humidity({ value }: { value: number }) { | ||
return <span>{value.toFixed(1)} %</span>; | ||
} | ||
|
||
export default Humidity; |
16 changes: 16 additions & 0 deletions
16
apps/rasptherm/src/components/sensor/internal/sensor-readout-executed-at.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Skeleton } from '@mui/material'; | ||
|
||
interface SensorReadoutExecutedAtProps { | ||
executedAt: string; | ||
loading: boolean; | ||
} | ||
|
||
function SensorReadoutExecutedAt(props: SensorReadoutExecutedAtProps) { | ||
return props.loading ? ( | ||
<Skeleton width="60%" /> | ||
) : ( | ||
<span>{new Date(props.executedAt).toLocaleString()}</span> | ||
); | ||
} | ||
|
||
export default SensorReadoutExecutedAt; |
18 changes: 18 additions & 0 deletions
18
apps/rasptherm/src/components/sensor/internal/sensor-readout-without-loading.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { SensorReadoutProps } from './sensor-readout'; | ||
import Humidity from './humidity'; | ||
import Slash from './slash'; | ||
import Temperature from './temperature'; | ||
|
||
function SensorReadoutWithoutLoading( | ||
props: Omit<SensorReadoutProps, 'loading'> | ||
) { | ||
return ( | ||
<> | ||
<Temperature value={props.temperature} /> | ||
<Slash /> | ||
<Humidity value={props.humidity} /> | ||
</> | ||
); | ||
} | ||
|
||
export default SensorReadoutWithoutLoading; |
25 changes: 25 additions & 0 deletions
25
apps/rasptherm/src/components/sensor/internal/sensor-readout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Skeleton, Typography } from '@mui/material'; | ||
import SensorReadoutWithoutLoading from './sensor-readout-without-loading'; | ||
|
||
export interface SensorReadoutProps { | ||
temperature: number; | ||
humidity: number; | ||
loading: boolean; | ||
} | ||
|
||
function SensorReadout(props: SensorReadoutProps) { | ||
return ( | ||
<Typography variant="h4"> | ||
{props.loading ? ( | ||
<Skeleton width="80%" /> | ||
) : ( | ||
<SensorReadoutWithoutLoading | ||
temperature={props.temperature} | ||
humidity={props.humidity} | ||
/> | ||
)} | ||
</Typography> | ||
); | ||
} | ||
|
||
export default SensorReadout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function Slash() { | ||
return <span> / </span>; | ||
} | ||
|
||
export default Slash; |
5 changes: 5 additions & 0 deletions
5
apps/rasptherm/src/components/sensor/internal/temperature.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function Temperature({ value }: { value: number }) { | ||
return <span>{value.toFixed(1)} ℃</span>; | ||
} | ||
|
||
export default Temperature; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters