2020-09-19 01:16:43 +02:00
|
|
|
<script>
|
|
|
|
import dj from 'dayjs'
|
|
|
|
|
|
|
|
import DateInput from './DateInput.svelte'
|
|
|
|
|
|
|
|
export let start
|
|
|
|
export let end
|
|
|
|
|
|
|
|
function set(interval, amount = 1) {
|
|
|
|
return () => {
|
2020-09-20 18:24:22 +02:00
|
|
|
start = dj().subtract(amount, interval).startOf('day').toDate()
|
|
|
|
end = dj().endOf('day').toDate()
|
2020-09-19 01:16:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function all() {
|
|
|
|
start = new Date(0)
|
|
|
|
end = new Date()
|
|
|
|
}
|
2020-09-19 01:30:42 +02:00
|
|
|
|
|
|
|
// Init
|
|
|
|
set('week')()
|
2020-09-19 01:16:43 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.spacer {
|
|
|
|
width: 0.5em;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<!-- <div class="flex flex-col"> -->
|
|
|
|
<div class="flex items-center">
|
|
|
|
<div class="btn-group">
|
|
|
|
<button class="btn btn-sm" on:click={all}>All</button>
|
2020-09-20 18:37:02 +02:00
|
|
|
<button class="btn btn-sm" on:click={set('month', 1)}>Month</button>
|
|
|
|
<button class="btn btn-sm" on:click={set('week', 1)}>Week</button>
|
|
|
|
<button class="btn btn-sm" on:click={set('day', 3)}>3 Days</button>
|
|
|
|
<button class="btn btn-sm" on:click={set('day', 0)}>Today</button>
|
2020-09-19 01:16:43 +02:00
|
|
|
</div>
|
|
|
|
<div class="spacer" />
|
|
|
|
<div class="input-group">
|
|
|
|
<DateInput bind:date={start} />
|
|
|
|
<DateInput bind:date={end} />
|
|
|
|
</div>
|
|
|
|
</div>
|