🎨 Replace for loop with a <For/> control flow for PassagesPanel component

This commit is contained in:
2023-02-09 21:14:16 +01:00
parent e34355e8be
commit 275954f52d

View File

@@ -1,4 +1,4 @@
import { VoidComponent, createEffect, createResource, createSignal, ParentComponent, ParentProps, Show, useContext } from 'solid-js'; import { VoidComponent, createEffect, createResource, createSignal, ParentComponent, ParentProps, Show, useContext, For } from 'solid-js';
import { createDateNow, getTime } from '@solid-primitives/date'; import { createDateNow, getTime } from '@solid-primitives/date';
import { AnimationOptions } from '@motionone/types'; import { AnimationOptions } from '@motionone/types';
import { Motion } from "@motionone/solid"; import { Motion } from "@motionone/solid";
@@ -123,18 +123,17 @@ export const PassagesPanel: PassagesPanelComponent = (props) => {
return ( return (
<div classList={{ [styles.passagesContainer]: true, [styles.displayed]: props.show }} > <div classList={{ [styles.passagesContainer]: true, [styles.displayed]: props.show }} >
<Show when={lines() !== undefined} > <Show when={lines() !== undefined} >
{() => { <For each={lines()}>
const ret = []; {(line) =>
for (const line of lines()) { <Show when={props.passages[line.id]}>
const byLinePassages = props.passages[line.id]; <For each={Object.keys(props.passages[line.id])}>
if (byLinePassages !== undefined) { {(destination) =>
for (const destination of Object.keys(byLinePassages)) { <DestinationPassages passages={props.passages[line.id][destination]} line={line} destination={destination} />
ret.push(<DestinationPassages passages={byLinePassages[destination]} line={line} destination={destination} />); }
} </For>
} </Show>
} }
return ret; </For>
}}
</Show> </Show>
</div > </div >
); );