Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggleable timeline #5

Merged
merged 9 commits into from
Nov 9, 2024
18 changes: 16 additions & 2 deletions src/lib/components/Timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@
import type { ActionData } from '$lib/types';
import Action from './Action.svelte';

let { actions = $bindable() }: { actions: ActionData[] } = $props();
let {
actions = $bindable(),
displaying = $bindable()
}: { actions: ActionData[]; displaying: boolean } = $props();
// let latestActions: ActionData[] = $derived(actions.toReversed().slice(0, 5));
</script>

<h1 class="text-text_red">Timeline</h1>
<div
class="flex flex-col items-center h-full bg-btn_grey border-solid border-2 border-text_red p-2 rounded gap-2 w-full overflow-auto"
class="flex flex-col items-center bg-btn_grey text-text_white p-1 rounded-t-lg transition-transform gap-2 fixed h-[50svh] inset-x-0 bottom-0
{displaying ? '' : 'translate-y-full'}"
id="timeline"
>
<button
class="bg-btn_grey w-80 p-1 rounded border-2 border-outline_gray fixed bottom-0"
onclick={() => {
displaying = false;
}}
>
Hide Timeline
</button>

{#each actions as _, i}
<Action
bind:action={actions[i]}
Expand Down
26 changes: 18 additions & 8 deletions src/routes/scout/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,25 @@
actions.push({ type: actionType.IntakeTote, result: actionResult.success });
}

let actions: ActionData[] = $state([]);
let timelineExtended = $state(false);
function toggleTimeline() {
timelineExtended = !timelineExtended;
}

let latestActions: ActionData[] = $state([]);
</script>

<main class="flex flex-col items-center gap-2 p-2 justify-center h-screen">
<Timeline bind:actions />

<!--to be changed in the future-->
<button
class="bg-btn_grey w-80 p-1 rounded border-2 border-text_red text-text_yellow"
onclick={addAction}>Add Action</button
>
<Timeline bind:actions={latestActions} bind:displaying={timelineExtended} />
<div class="flex flex-col grow justify-end">
<!--this button to be changed in the future (deleted)-->
<button
class="bg-btn_grey w-80 p-1 rounded border-2 border-outline_gray static"
onclick={addAction}>Add Action</button
>
<button
class="bg-btn_grey w-80 p-1 rounded border-2 border-outline_gray static"
onclick={toggleTimeline}>Show Timeline</button
>
</div>
</main>