feat(period): p and a letter picks a period from any page
p t current period, p m month to date, p 7 and p 3 the last seven and thirty days, p y year to date, p l last year, p a everything, p c custom dates, p p opens the period menu, which now shows each key. The same presets are in the palette. Currencies make primary moves to P and the subscriptions card/currency toggle to v to free p.
This commit is contained in:
1 parent
617a4700e2
commit
4a03ab8e1a
7 files changed
+68
-13
No files matched your search
@@ -4,13 +4,13 @@
|
||||
import ChevronRight from "@lucide/svelte/icons/chevron-right";
|
||||
import { Popover } from "bits-ui";
|
||||
import { period } from "#lib/period.svelte.js";
|
||||
import { ui } from "#lib/ui.svelte.js";
|
||||
|
||||
let open = $state(false);
|
||||
let start = $state(period.start);
|
||||
let end = $state(period.end);
|
||||
|
||||
$effect(() => {
|
||||
if (open) {
|
||||
if (ui.periodOpen) {
|
||||
({ start, end } = period);
|
||||
}
|
||||
});
|
||||
@@ -19,7 +19,7 @@
|
||||
event.preventDefault();
|
||||
if (start && end && start <= end) {
|
||||
period.set({ end, start });
|
||||
open = false;
|
||||
ui.periodOpen = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -34,7 +34,7 @@
|
||||
>
|
||||
<ChevronLeft class="size-4" />
|
||||
</button>
|
||||
<Popover.Root bind:open>
|
||||
<Popover.Root bind:open={ui.periodOpen}>
|
||||
<Popover.Trigger
|
||||
class="flex h-8 items-center gap-2 px-2 font-medium text-[13px] hover:bg-black/10"
|
||||
title="Choose period"
|
||||
@@ -59,11 +59,16 @@
|
||||
: ""}"
|
||||
onclick={() => {
|
||||
period.set(preset.range);
|
||||
open = false;
|
||||
ui.periodOpen = false;
|
||||
}}
|
||||
type="button"
|
||||
>
|
||||
{preset.label}
|
||||
{#if preset.key || preset.hint}
|
||||
<span class="kbd"
|
||||
>{preset.key ? `p ${preset.key}` : preset.hint}</span
|
||||
>
|
||||
{/if}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -76,6 +81,7 @@
|
||||
Start
|
||||
<input
|
||||
class="cladd-cut cladd-focusable-input h-8 rounded-cladd-sm px-2 text-[13px] text-cladd-fg"
|
||||
id="period-start"
|
||||
type="date"
|
||||
bind:value={start}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user