add carrier switch to Identification

This commit is contained in:
Yanick Champoux 2023-04-21 13:12:37 -04:00
parent 3f6db25c99
commit 7cc85f2572
4 changed files with 41 additions and 1 deletions

View File

@ -8,10 +8,18 @@
mass: 13, mass: 13,
usedMass: 9, usedMass: 9,
}} }}
{api}
/> />
</Hst.Story> </Hst.Story>
<script lang="ts"> <script lang="ts">
export let Hst; export let Hst;
import { logEvent } from "histoire/client";
import Identification from "./Identification.svelte"; import Identification from "./Identification.svelte";
const api = {
dispatch: {
setCarrier: (isCarrier) => logEvent("isCarrier", { isCarrier }),
},
};
</script> </script>

View File

@ -10,6 +10,14 @@
<label class="active">ship type</label> <label class="active">ship type</label>
<i>arrow_drop_down</i> <i>arrow_drop_down</i>
</Field> </Field>
<label class="switch icon">
<div>carrier</div>
<input type="checkbox" bind:checked={isCarrier} />
<span>
<i>airplanemode_inactive</i>
<i>airplanemode_active</i>
</span>
</label>
</div> </div>
<ShipCost {...reqs} /> <ShipCost {...reqs} />
</div> </div>
@ -36,6 +44,9 @@
shipType = shipTypes[0]; shipType = shipTypes[0];
$: api?.dispatch?.updateIdentification?.({ shipType, shipClass }); $: api?.dispatch?.updateIdentification?.({ shipType, shipClass });
$: console.log(isCarrier);
$: api?.dispatch.setCarrier?.(isCarrier);
</script> </script>
<style> <style>
@ -48,8 +59,18 @@
display: flex; display: flex;
align-items: start; align-items: start;
} }
select {
min-width: 10em;
}
.identification-row :global(> *:first-child) { .identification-row :global(> *:first-child) {
flex: 1; flex: 1;
} }
label div {
font-size: var(--font-scale-10);
margin-right: 1em;
}
label.switch {
margin-left: 2em;
}
</style> </style>

View File

@ -0,0 +1,10 @@
import { render, fireEvent } from "@testing-library/svelte";
import "@testing-library/jest-dom";
import { tick } from "svelte";
import Identification from "./Identification.svelte";
test("carrier", () => {
const { getByLabelText } = render(Identification);
expect(getByLabelText("carrier")).toBeInTheDocument();
});

View File

@ -1,8 +1,9 @@
<Hst.Story> <Hst.Story>
<Propulsion /> <Propulsion {api} />
</Hst.Story> </Hst.Story>
<script> <script>
export let Hst; export let Hst;
import Propulsion from "./Propulsion.svelte"; import Propulsion from "./Propulsion.svelte";
</script> </script>