-
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.
Merge pull request #11 from renanrms/time-window-control
Time window control
- Loading branch information
Showing
14 changed files
with
109 additions
and
19 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
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
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
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
src/renderer/src/features/measurements/components/ControlCard.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,35 @@ | ||
import { Dispatch, SetStateAction } from 'react' | ||
|
||
import { Slider } from '@mui/material' | ||
|
||
import { maxDisplayedTimeRange } from '../constants/maxDisplayedTimeRange' | ||
import { formatTime } from '../utils/formatTime' | ||
|
||
interface ControlCardProps { | ||
timeRange: number | ||
setTimeRange: Dispatch<SetStateAction<number>> | ||
} | ||
|
||
export function ControlCard(props: ControlCardProps) { | ||
return ( | ||
<div className="w-full p-4 mb-4 border border-neutral-90 dark:border-neutral-30 rounded-md flex flex-col items-start justify-between bg-neutral-100 dark:bg-background text-on-background"> | ||
<p className="mb-1"> | ||
Janela de tempo:{' '} | ||
<span className="text-sm">{formatTime(props.timeRange)}</span> | ||
</p> | ||
<Slider | ||
defaultValue={maxDisplayedTimeRange} | ||
step={0.1} | ||
min={1} | ||
max={Math.log2(24 * 60 * 60)} | ||
valueLabelFormat={(value) => `${value} s`} | ||
valueLabelDisplay="auto" | ||
scale={(value) => Math.floor(2 ** value)} | ||
value={Math.log2(props.timeRange)} | ||
onChange={(event, value) => { | ||
props.setTimeRange(2 ** (value as number)) | ||
}} | ||
/> | ||
</div> | ||
) | ||
} |
1 change: 0 additions & 1 deletion
1
src/renderer/src/features/measurements/constants/defaultDisplayedTimeRange.ts
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/renderer/src/features/measurements/constants/maxDisplayedTimeRange.ts
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 @@ | ||
export const maxDisplayedTimeRange = 8 |
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
13 changes: 13 additions & 0 deletions
13
src/renderer/src/features/measurements/utils/formatTime.ts
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,13 @@ | ||
export function formatTime(t: number) { | ||
const hours = Math.floor(t / 3600) | ||
const minutes = Math.floor((t - 3600 * hours) / 60) | ||
const seconds = Math.floor((t - 3600 * hours - 60 * minutes) % 60) | ||
|
||
if (hours > 0) { | ||
return `${hours}h ${minutes}min` | ||
} else if (minutes > 0) { | ||
return `${minutes}min ${seconds}s` | ||
} else { | ||
return `${seconds}s` | ||
} | ||
} |
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