From 31d48d092641bf410978e3d3e11eaec4cb3a9d4f Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 2 Mar 2022 13:42:42 -0500 Subject: [PATCH 1/2] Drive UI --- .../Propulsion/Drive}/Engine.stories.svelte | 12 ++++---- .../Propulsion/Drive}/index.svelte | 7 ++--- .../ShipEdit/Propulsion/index.svelte | 11 ++++++++ src/lib/components/ShipEdit/index.svelte | 3 ++ src/lib/shipDux/engine.js | 8 +++--- src/lib/shipDux/index.js | 5 ++-- src/lib/shipDux/propulsion/drive.js | 28 +++++++++++++++++++ src/lib/shipDux/propulsion/index.js | 12 ++++++++ 8 files changed, 70 insertions(+), 16 deletions(-) rename src/lib/components/{Engine => ShipEdit/Propulsion/Drive}/Engine.stories.svelte (75%) rename src/lib/components/{Engine => ShipEdit/Propulsion/Drive}/index.svelte (83%) create mode 100644 src/lib/components/ShipEdit/Propulsion/index.svelte create mode 100644 src/lib/shipDux/propulsion/drive.js create mode 100644 src/lib/shipDux/propulsion/index.js diff --git a/src/lib/components/Engine/Engine.stories.svelte b/src/lib/components/ShipEdit/Propulsion/Drive/Engine.stories.svelte similarity index 75% rename from src/lib/components/Engine/Engine.stories.svelte rename to src/lib/components/ShipEdit/Propulsion/Drive/Engine.stories.svelte index 6000962..3e3fa70 100644 --- a/src/lib/components/Engine/Engine.stories.svelte +++ b/src/lib/components/ShipEdit/Propulsion/Drive/Engine.stories.svelte @@ -1,6 +1,6 @@
- +
@@ -22,10 +22,12 @@ import { setContext } from "svelte"; - import Engine from "./index.svelte"; + import Drive from "./index.svelte"; setContext("ship", { - dispatch: (type, detail) => action(type)(detail), + dispatch: { + setDrive: action('setDrive') + }, }); let advanced = false; diff --git a/src/lib/components/Engine/index.svelte b/src/lib/components/ShipEdit/Propulsion/Drive/index.svelte similarity index 83% rename from src/lib/components/Engine/index.svelte rename to src/lib/components/ShipEdit/Propulsion/Drive/index.svelte index c106aea..9af3248 100644 --- a/src/lib/components/Engine/index.svelte +++ b/src/lib/components/ShipEdit/Propulsion/Drive/index.svelte @@ -17,11 +17,10 @@ export let advanced = false; export let rating = 0; - const ship = getContext("ship") || { - dispatch: (...args) => console.log(args), - }; + const ship = getContext("ship"); - $: ship.dispatch("setEngine", { rating, advanced }); + console.log( ship.dispatch ) + $: ship.dispatch.setDrive({ rating, advanced });