ShipSpecs

This commit is contained in:
Yanick Champoux 2020-07-28 14:03:59 -04:00
parent da31439dea
commit e87c9a5ae4
5 changed files with 97 additions and 72 deletions

View File

@ -2,10 +2,7 @@
<main> <main>
<input class="reset" type="button" value="reset" on:click={reset} /> <input class="reset" type="button" value="reset" on:click={reset} />
<Identification /> <ShipSpecs />
<ShipCost />
<Propulsion <Propulsion
ftl={$ship.ftl} ftl={$ship.ftl}
engine={$ship.engine} engine={$ship.engine}
@ -51,11 +48,10 @@
import Header from './Header'; import Header from './Header';
import shipStore from "~/stores/ship"; import shipStore from "~/stores/ship";
import ShipSpecs from './ShipSpecs/index.svelte';
import ShipItem from "./ShipItem/index.svelte"; import ShipItem from "./ShipItem/index.svelte";
import ShipCost from "./ShipCost.svelte";
import Field from "./Field/index.svelte"; import Field from "./Field/index.svelte";
import Hull from "./Hull.svelte"; import Hull from "./Hull.svelte";
import Identification from "./Identification.svelte";
import Firecons from "./Firecons.svelte"; import Firecons from "./Firecons.svelte";
import Propulsion from "./Propulsion/index.svelte"; import Propulsion from "./Propulsion/index.svelte";
import Section from "~C/Section"; import Section from "~C/Section";

View File

@ -1,58 +0,0 @@
<div class="ship_cost">
<div>
<label>Ship tonnage</label>
<input
value={$ship.general.mass}
on:change={change_tonnage}
type="number" min="10" max="300" />
<div>
<div class="note" class:warning={!within_budget}>
{#if within_budget}
mass unused: { mass_unused }
{:else}
excessive mass: { -mass_unused }
{/if}
</div>
</div>
</div>
<div>
<label>Ship cost</label>
<div>{$ship.general.cost}</div>
</div>
</div>
<script>
import { getContext } from 'svelte';
export let ship = getContext('ship');
const change_tonnage =
({target: {value}}) =>
ship.dispatch(ship.actions.set_ship_mass(parseInt(value)));
let mass_unused;
$: mass_unused = $ship.general.mass - $ship.general.used_mass;
let within_budget = true;
$: within_budget = mass_unused >= 0;
</script>
<style>
.ship_cost {
display: flex;
grid-column: span 3;
justify-content: space-around;
}
.warning {
color: red;
}
.note {
font-size: smaller;
}
</style>

View File

@ -1,5 +1,4 @@
<div class="identification"> <div>
<Field label="ship class" value={general.ship_class} <Field label="ship class" value={general.ship_class}
on:change={change_class} /> on:change={change_class} />
@ -10,13 +9,12 @@
{/each} {/each}
</select> </select>
</Field> </Field>
</div> </div>
<script> <script>
import { getContext } from 'svelte'; import { getContext } from 'svelte';
import Field from './Field/index.svelte'; import Field from '~C/Field';
import { candidate_ship_types } from '~/dux/ship_types'; import { candidate_ship_types } from '~/dux/ship_types';
export let ship = getContext('ship'); export let ship = getContext('ship');
@ -41,9 +39,9 @@
</script> </script>
<style> <style>
.identification { div {
grid-column: span 3;
display: flex; display: flex;
justify-content: space-around; align-items: end;
} gap: 2em;
}
</style> </style>

View File

@ -0,0 +1,73 @@
<div class="mass">
<Field label="ship tonnage">
<input
value={$ship.general.mass}
on:change={change_tonnage}
type="number"
min="10"
max="300" />
<span class="mass_symbol"></span>
<div class="note" class:warning={!within_budget}>
{#if within_budget}
mass unused: {mass_unused}
{:else}excessive mass: {-mass_unused}{/if}
</div>
</Field>
</div>
<div class="cost">
<Field label="cost">
<span class="cost">{$ship.general.cost}</span></Field>
</div>
<script>
import { getContext } from "svelte";
import Field from "~C/Field";
export let ship = getContext("ship");
const change_tonnage = ({ target: { value } }) =>
ship.dispatch(ship.actions.set_ship_mass(parseInt(value)));
let mass_unused;
$: mass_unused = $ship.general.mass - $ship.general.used_mass;
let within_budget = true;
$: within_budget = mass_unused >= 0;
</script>
<style>
.ship_cost {
display: flex;
grid-column: span 3;
justify-content: space-around;
}
input {
width: 5em;
}
.mass_symbol:after {
content: url(mass.svg);
width: 0.75em;
display: inline-block;
margin-left: 0.5em;
}
.warning {
color: red;
}
.note {
font-size: smaller;
}
.mass {
grid-column: 2;
}
div.cost {
grid-column: 3;
}
span.cost:after {
content: '\00A4';
margin-left: 0.5em;
}
</style>

View File

@ -0,0 +1,16 @@
<Identification />
<ShipCost />
<script>
import Identification from "./Identification.svelte";
import ShipCost from "./ShipCost.svelte";
</script>
<style>
div {
background-color: red;
}
</style>