integrity print

This commit is contained in:
Yanick Champoux 2022-03-26 12:37:43 -04:00
parent 9ecea73c44
commit 33ccbaf293
2 changed files with 30 additions and 10 deletions

View File

@ -0,0 +1,20 @@
<Meta title="Output/Print/Structure/Integrity" component={Integrity} argTypes={{
shipMass: {defaultValue:50},
rating: {defaultValue:14},
advanced: {defaultValue:false},
}} />
<Story name="Primary" args={{}} />
<Story name="Advanced" args={{ advanced: true }} />
<Template let:args>
<div style="width: 50em">
<Integrity {...args} />
</div>
</Template>
<script>
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
import Integrity from './index.svelte';
</script>

View File

@ -1,9 +1,9 @@
<div> <div>
{#each rows as row, i (i)} {#each rows as row, i (i)}
<div class="row"> <div class="row">
{#each row as item, j (j)} {#each row as threshold, j (j)}
<div class="cell"> <div class="cell">
{#if item} {#if threshold}
<img src="icons/crew-star.svg" alt="crew loss threshold" /> <img src="icons/crew-star.svg" alt="crew loss threshold" />
{/if} {/if}
</div> </div>
@ -13,9 +13,7 @@
</div> </div>
<script> <script>
import { ceil } from "$lib/dux/utils"; export let shipMass = 0;
export let ship_mass = 0;
export let rating = 0; export let rating = 0;
export let advanced = false; export let advanced = false;
@ -26,7 +24,7 @@
$: cells = Array(rating).fill(false); $: cells = Array(rating).fill(false);
let dcp; let dcp;
$: dcp = ceil(ship_mass / 20); $: dcp = Math.ceil(shipMass / 20);
$: cells = divide(cells, dcp) $: cells = divide(cells, dcp)
.map((g) => { .map((g) => {
@ -52,15 +50,17 @@
<style> <style>
.row { .row {
margin-bottom: 0.5em;
} }
.cell { .cell {
display: inline-block; display: inline-block;
margin-right: 0.5em; margin-right: 0.5em;
width: 1em; width: 1.5em;
height: 1em; height: 1.5em;
border: 1px solid black; border: 1px solid black;
} }
img { img {
width: 1em; width: 1em;
margin-left: 0.2em;
} }
</style> </style>