-
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.
Some calculation fixes, add progress bar
Live update with current time. Some UI updates.
- Loading branch information
Showing
11 changed files
with
113 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<script setup lang="ts"> | ||
import { useTimesStore } from '@/stores/times' | ||
import { formatDuration } from 'date-fns' | ||
import { computed } from 'vue' | ||
import { getRatio } from '../lib/date-fns/getRatio' | ||
const timesStore = useTimesStore() | ||
const atLeast8Hours = computed(() => (timesStore.workTimeOfSelectedDay.hours ?? 0) < 8) | ||
const remainingLabel = computed(() => | ||
atLeast8Hours.value ? '8 Stunden erreicht in:' : 'Überstunden:' | ||
) | ||
</script> | ||
|
||
<template> | ||
<div class="grid grid-cols-2 gap-2 px-2"> | ||
<div>Heute gearbeitet:</div> | ||
<div class="font-bold"> | ||
{{ formatDuration(timesStore.workTimeOfSelectedDay, { format: ['hours', 'minutes'] }) }} | ||
</div> | ||
|
||
<div>{{ remainingLabel }}</div> | ||
<div class="font-bold"> | ||
{{ | ||
formatDuration(timesStore.remainingWorkTimeOfSelectedDay, { | ||
format: ['hours', 'minutes'] | ||
}) | ||
}} | ||
</div> | ||
|
||
<div class="col-span-2"> | ||
<progress | ||
class="w-full appearance-none [&::-webkit-progress-bar]:rounded-full [&::-webkit-progress-bar]:h-3 [&::-webkit-progress-bar]:bg-white [&::-webkit-progress-bar]:border-solid [&::-webkit-progress-bar]:border-2 [&::-webkit-progress-bar]:border-teal-600 [&::-webkit-progress-value]:bg-teal-600" | ||
:value="getRatio(timesStore.workTimeOfSelectedDay, { hours: 8 })" | ||
max="1" | ||
></progress> | ||
</div> | ||
|
||
<div>Pausenzeit:</div> | ||
<div class="font-bold"> | ||
{{ | ||
formatDuration(timesStore.breakTimeOfSelectedDay, { format: ['hours', 'minutes'] }) || '-' | ||
}} | ||
</div> | ||
</div> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
<script setup lang="ts"> | ||
import { format } from 'date-fns' | ||
import { useTimesStore } from '@/stores/times' | ||
import { format, isSameDay } from 'date-fns' | ||
defineProps<{ day: Date }>() | ||
const timesStore = useTimesStore() | ||
</script> | ||
|
||
<template> | ||
<div class="px-3 py-2 hover:bg-gray-200"> | ||
<div | ||
class="px-3 py-2 cursor-default text-center rounded select-none" | ||
:class="{ | ||
'hover:bg-gray-200': !isSameDay(timesStore.selectedDay, day), | ||
'bg-gray-300': isSameDay(timesStore.selectedDay, day) | ||
}" | ||
@click="timesStore.setSelectedDay(day)" | ||
> | ||
{{ format(day, 'dd.MM.yyyy') }} | ||
</div> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<button class="px-3 py-1 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 rounded border border-gray-300 hover:border-gray-400 active:border-gray-400"> | ||
<button class="px-3 py-1 bg-gray-100 hover:bg-gray-200 active:bg-gray-300 rounded border border-gray-300 hover:border-gray-400 active:border-gray-400 cursor-default select-none"> | ||
<slot></slot> | ||
</button> | ||
</template> |
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 @@ | ||
<template> | ||
<div class="flex flex-col gap-4"> | ||
<slot></slot> | ||
</div> | ||
</template> |
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 @@ | ||
<template> | ||
<div class="mx-2 pb-4 mb-4 border-b border-gray-300"> | ||
<slot></slot> | ||
</div> | ||
</template> |
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,8 @@ | ||
import { add, type Duration } from 'date-fns' | ||
|
||
export function getRatio(duration: Duration, compareDuration: Duration): number { | ||
const baseDate = new Date(0) | ||
const compareDate = add(baseDate, compareDuration) | ||
const date = add(baseDate, duration) | ||
return 1 / compareDate.getTime() * date.getTime() | ||
} |
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