Browse Source
add thin progress bars to stuff, fix tiny issue with progress bars when they're too smol.
main
add thin progress bars to stuff, fix tiny issue with progress bars when they're too smol.
main
Gisle Aune
4 years ago
6 changed files with 72 additions and 25 deletions
-
23svelte-ui/src/components/GoalEntry.svelte
-
5svelte-ui/src/components/ParentEntry.svelte
-
31svelte-ui/src/components/Progress.svelte
-
1svelte-ui/src/components/ProjectEntry.svelte
-
5svelte-ui/src/components/QLListItem.svelte
-
32svelte-ui/src/components/TimeProgress.svelte
@ -0,0 +1,32 @@ |
|||||
|
<script lang="ts"> |
||||
|
import EveryMinute from "./EveryMinute.svelte"; |
||||
|
import Progress from "./Progress.svelte"; |
||||
|
|
||||
|
export let startTime: string | Date; |
||||
|
export let endTime: string | Date; |
||||
|
|
||||
|
let msLength: number; |
||||
|
let msElapsed: number; |
||||
|
let now = Date.now(); |
||||
|
|
||||
|
$: { |
||||
|
const start = (startTime instanceof Date) ? startTime.getTime() : Date.parse(startTime) |
||||
|
const length = ((endTime instanceof Date) ? endTime.getTime() : Date.parse(endTime)) - start; |
||||
|
|
||||
|
msLength = length; |
||||
|
msElapsed = 0; |
||||
|
|
||||
|
if (now > start) { |
||||
|
if (now > start + length) { |
||||
|
msElapsed = length; |
||||
|
} else { |
||||
|
msElapsed = Math.round(now - start); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$: console.log(startTime, endTime, msLength, msElapsed, msElapsed < msLength) |
||||
|
</script> |
||||
|
|
||||
|
<EveryMinute bind:now={now} /> |
||||
|
<Progress thinner gray count={msElapsed} target={msLength} titleTime /> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue