diff --git a/src/lib/components/Field.svelte b/src/lib/components/Field.svelte index 68c73cc..506ea34 100644 --- a/src/lib/components/Field.svelte +++ b/src/lib/components/Field.svelte @@ -1,4 +1,4 @@ -
+
{#if label} {/if} diff --git a/src/lib/components/ShipEdit/Weaponry.story.svelte b/src/lib/components/ShipEdit/Weaponry.story.svelte new file mode 100644 index 0000000..f62f327 --- /dev/null +++ b/src/lib/components/ShipEdit/Weaponry.story.svelte @@ -0,0 +1,17 @@ + + + + + diff --git a/src/lib/components/ShipEdit/Weaponry.svelte b/src/lib/components/ShipEdit/Weaponry.svelte index 5d133ab..6ff4423 100644 --- a/src/lib/components/ShipEdit/Weaponry.svelte +++ b/src/lib/components/ShipEdit/Weaponry.svelte @@ -2,14 +2,12 @@ - + {#each weapons as weapon (weapon.id)} + + {/each} diff --git a/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.story.svelte b/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.story.svelte new file mode 100644 index 0000000..59dc606 --- /dev/null +++ b/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.story.svelte @@ -0,0 +1,8 @@ + + + + + diff --git a/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.svelte b/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.svelte index 6657c21..effd42c 100644 --- a/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.svelte +++ b/src/lib/components/ShipEdit/Weaponry/Weapon/Arcs.svelte @@ -1,10 +1,10 @@ - {#each all_arcs as arc (arc)} + {#each arcs as arc (arc)} click_arc(arc)} + on:click={() => clickArc(arc)} /> {/each} @@ -12,17 +12,17 @@ diff --git a/src/lib/components/ShipEdit/Weaponry/Weapon/Submunition.svelte b/src/lib/components/ShipEdit/Weaponry/Weapon/Submunition.svelte index 070b55a..584d318 100644 --- a/src/lib/components/ShipEdit/Weaponry/Weapon/Submunition.svelte +++ b/src/lib/components/ShipEdit/Weaponry/Weapon/Submunition.svelte @@ -1,19 +1,16 @@ - click_arc(detail)} /> + clickArc(detail)} /> diff --git a/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte b/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte index 0f799df..adb081d 100644 --- a/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte +++ b/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte @@ -1,15 +1,8 @@
- + - +
@@ -19,34 +12,33 @@ import Arc from "./Arc.svelte"; import ShipItem from "$lib/components/ShipItem.svelte"; import Field from "$lib/components/Field.svelte"; - import Beam from "./Beam/index.svelte"; - import Submunition from "./Submunition.svelte"; - import PointDefenceSystem from "./PDS.svelte"; - import Scattergun from "./Scattergun.svelte"; + import Beam from "./Beam/index.svelte"; + import Submunition from "./Submunition.svelte"; + import PointDefenceSystem from "./PDS.svelte"; + import Scattergun from "./Scattergun.svelte"; import Needle from "./Needle.svelte"; const component = { - beam: Beam, - submunition: Submunition, - pds: PointDefenceSystem, - scattergun: Scattergun, - needle: Needle, + beam: Beam, + submunition: Submunition, + pds: PointDefenceSystem, + scattergun: Scattergun, + needle: Needle, }; - export let weapon = {}; - $: reqs = weapon.reqs; + export let reqs = {}; + export let specs = {}; export let id; - const ship = getContext("ship"); + const api = getContext("api"); - $: type = weapon.type; + $: type = specs.type; - const remove = () => ship.dispatch.removeWeapon(id); + const remove = () => api?.dispatch?.removeWeapon?.(id); const update = ({ detail }) => { - console.log({id,type}) - ship.dispatch.setWeapon({ - id, + console.log({ id, type }); + api?.dispatch?.setWeapon?.(id, { type, ...detail, }); @@ -54,6 +46,9 @@