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

moved actions to top of timeline #2

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/lib/components/Timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import Action from './Action.svelte';

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

<div class="flex flex-col items-center h-[80vh] bg-btn_grey text-text_white p-1 rounded gap-2 w-80">
{#each actions as _, i}
{#each latestActions as _, i}
<Action
bind:action={actions[i]}
bind:action={latestActions[i]}
deleteself={() => {
actions.splice(i, 1);
actions.splice(actions.indexOf(latestActions[i]), 1);
}}
/>
{/each}
Expand Down
16 changes: 9 additions & 7 deletions src/routes/scout/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@

function addAction() {
//everything here is for testing, as there is no system for this yet
latestActions.push({ type: actionType.ScoreAnotherRobotsTote, result: actionResult.success });
latestActions.push({ type: actionType.EjectTote, result: actionResult.fail });
latestActions.push({ type: actionType.IntakeTote, result: actionResult.success });
actions.push({ type: actionType.ScoreAnotherRobotsTote, result: actionResult.success });
actions.push({ type: actionType.EjectTote, result: actionResult.fail });
actions.push({ type: actionType.IntakeTote, result: actionResult.success });
}

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

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

<!--to be changed in the future-->
<button class="bg-btn_grey w-80 p-1 rounded border-2 border-outline_gray" onclick={addAction}>Add Action</button>
<!--to be changed in the future-->
<button class="bg-btn_grey w-80 p-1 rounded border-2 border-outline_gray" onclick={addAction}
>Add Action</button
awwpotato marked this conversation as resolved.
Show resolved Hide resolved
>
</main>