aotds-docks/src/components/ShipSpecs/Identification.svelte

48 lines
1.0 KiB
Svelte
Raw Normal View History

2020-07-28 18:03:59 +00:00
<div>
2020-07-19 20:21:28 +00:00
<Field label="ship class" value={general.ship_class}
on:change={change_class} />
<Field label="ship type">
<select value={ship_type} on:change={change_ship_type}>
{#each ship_types as type (type)}
<option>{type}</option>
{/each}
</select>
</Field>
</div>
<script>
import { getContext } from 'svelte';
2021-05-17 13:48:31 +00:00
import Field from '$lib/components/Field/index.svelte';
import { candidate_ship_types } from '../../dux/ship_types';
2020-07-19 20:21:28 +00:00
export let ship = getContext('ship');
let general;
$: general = $ship.general;
const change_class = (event) => ship.dispatch(
ship.actions.set_ship_class(event.target.value)
);
let ship_type;
$: ship_type = $ship.general.ship_type;
const change_ship_type = ({ target: {value}}) =>
ship.dispatch.set_ship_type(value);
let ship_types;
2020-07-27 17:42:19 +00:00
$: ship_types = candidate_ship_types($ship.general.mass,$ship.carrier.bays>0).map(
2020-07-19 20:21:28 +00:00
({name}) => name
);
</script>
<style>
2020-07-28 18:03:59 +00:00
div {
2020-07-19 20:21:28 +00:00
display: flex;
2020-07-28 18:03:59 +00:00
align-items: end;
gap: 2em;
}
2020-07-19 20:21:28 +00:00
</style>