Merge branch 'svench'
This commit is contained in:
commit
511c93de8a
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ node_modules
|
||||
.svelte-kit/
|
||||
.vercel_build_output/
|
||||
package-lock.json
|
||||
.svench
|
||||
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"useTabs": true,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"printWidth": 100
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
## Next
|
||||
|
||||
* Add svench.
|
||||
* Switch to Sveltekit.
|
||||
|
12
package.json
12
package.json
@ -10,13 +10,15 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/kit": "^1.0.0-next.107",
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.10",
|
||||
"eslint": "^7.22.0",
|
||||
"eslint-config-prettier": "^8.1.0",
|
||||
"eslint-plugin-svelte3": "^3.2.0",
|
||||
"prettier": "~2.2.1",
|
||||
"prettier-plugin-svelte": "^2.2.0",
|
||||
"svelte": "^3.34.0",
|
||||
"vite": "^2.2.3"
|
||||
"svench": "^0.2.0-14",
|
||||
"vite": "^2.3.2"
|
||||
},
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
@ -29,5 +31,13 @@
|
||||
"reselect": "^4.0.0",
|
||||
"ts-action": "^11.0.0",
|
||||
"updux": "link:/home/yanick/work/javascript/updux/"
|
||||
},
|
||||
"prettier": {
|
||||
"svelteSortOrder": "options-markup-scripts-styles",
|
||||
"svelteStrictMode": false,
|
||||
"svelteAllowShorthand": true,
|
||||
"plugins": [
|
||||
"prettier-plugin-svelte"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ h1 {
|
||||
font-size: var(--font-scale-14);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: var(--font-scale-12);
|
||||
}
|
||||
|
||||
|
||||
html, body {
|
||||
position: relative;
|
||||
@ -107,3 +111,4 @@ input:focus, select:focus {
|
||||
input.short {
|
||||
width:5em;
|
||||
}
|
||||
|
||||
|
@ -1,90 +1,93 @@
|
||||
<Ribbon />
|
||||
<Header />
|
||||
|
||||
<nav>
|
||||
<input class="reset button small red" type="button" value="reset" on:click={reset} />
|
||||
<nav>
|
||||
<button class="button is-danger" type="button" on:click={reset}>reset</button>
|
||||
|
||||
<div class="spacer" />
|
||||
<input type="button" class="button small notes" value="notes" on:click={toggle_notes} />
|
||||
<div class="spacer" />
|
||||
|
||||
<ul class="button-group">
|
||||
<input type="button" class="button small green" value="editor"
|
||||
on:click={() => set_output(null)} />
|
||||
<input type="button" class="button small green" value="json"
|
||||
on:click={() => set_output('json')} />
|
||||
<input type="button" class="button small green" value="print"
|
||||
on:click={() => set_output('print')} />
|
||||
</ul>
|
||||
</nav>
|
||||
<button class="button is-info about" on:click={toggle_notes}>about</button>
|
||||
|
||||
<div class="field has-addons">
|
||||
<p class="control">
|
||||
<button class="button" on:click={() => set_output(null)}>editor</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<button class="button" on:click={() => set_output("json")}>json</button>
|
||||
</p>
|
||||
<p class="control">
|
||||
<button class="button" on:click={() => set_output("print")}>print</button>
|
||||
</p>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{#if show_notes}
|
||||
<Notes show={show_notes} on:close={toggle_notes} />
|
||||
<Notes show={show_notes} on:close={toggle_notes} />
|
||||
{/if}
|
||||
|
||||
{#if output === 'json'}
|
||||
<OutputJson ship={$ship}
|
||||
on:close={() => set_output(null)}/>
|
||||
{:else if output === 'print' }
|
||||
<Print ship={$ship} />
|
||||
{#if output === "json"}
|
||||
<OutputJson ship={$ship} on:close={() => set_output(null)} />
|
||||
{:else if output === "print"}
|
||||
<Print ship={$ship} />
|
||||
{:else}
|
||||
<main>
|
||||
<ShipSpecs />
|
||||
|
||||
<main>
|
||||
<Propulsion
|
||||
ftl={$ship.ftl}
|
||||
engine={$ship.engine}
|
||||
on:change_ftl={change_ftl}
|
||||
on:change_engine={change_engine}
|
||||
/>
|
||||
|
||||
<ShipSpecs />
|
||||
<Hull
|
||||
ship_mass={$ship.general.mass}
|
||||
{...$ship.structure.hull}
|
||||
on:change_hull={change_hull}
|
||||
screens={$ship.structure.screens}
|
||||
armour={$ship.structure.armour}
|
||||
on:set_screens={set_screens}
|
||||
cargo={$ship.cargo}
|
||||
streamlining={$ship.streamlining}
|
||||
on:set_cargo={ship_dispatch}
|
||||
on:ship_change={ship_dispatch}
|
||||
/>
|
||||
|
||||
<Propulsion
|
||||
ftl={$ship.ftl}
|
||||
engine={$ship.engine}
|
||||
on:change_ftl={change_ftl}
|
||||
on:change_engine={change_engine} />
|
||||
<Section label="weaponry">
|
||||
<Firecons
|
||||
{...$ship.weaponry.firecons}
|
||||
on:change_firecons={change_firecons}
|
||||
/>
|
||||
|
||||
<Hull
|
||||
ship_mass={$ship.general.mass}
|
||||
{...$ship.structure.hull}
|
||||
on:change_hull={change_hull}
|
||||
screens={$ship.structure.screens}
|
||||
armour={$ship.structure.armour}
|
||||
on:set_screens={set_screens}
|
||||
cargo={$ship.cargo}
|
||||
streamlining={$ship.streamlining}
|
||||
on:set_cargo={ship_dispatch}
|
||||
on:ship_change={ship_dispatch} />
|
||||
<ADFC {...$ship.weaponry.adfc} />
|
||||
|
||||
<Section label="weaponry">
|
||||
<Firecons
|
||||
{...$ship.weaponry.firecons}
|
||||
on:change_firecons={change_firecons} />
|
||||
<AddWeapon />
|
||||
|
||||
<ADFC {...$ship.weaponry.adfc} />
|
||||
{#each weapons as weapon (weapon.id)}
|
||||
<Weapon {weapon} id={weapon.id} cost={weapon.cost} mass={weapon.mass} />
|
||||
{/each}
|
||||
</Section>
|
||||
|
||||
<AddWeapon />
|
||||
|
||||
{#each weapons as weapon (weapon.id)}
|
||||
<Weapon {weapon} id={weapon.id} cost={weapon.cost} mass={weapon.mass} />
|
||||
{/each}
|
||||
|
||||
</Section>
|
||||
|
||||
<Carrier {...$ship.carrier} />
|
||||
|
||||
|
||||
</main>
|
||||
<Carrier {...$ship.carrier} />
|
||||
</main>
|
||||
<footer>
|
||||
Written by <a href="https://twitter.com/yenzie">Yanick Champoux</a>.
|
||||
Code available on <a
|
||||
href="https://github.com/yanick/aotds-shipyard">Github</a>
|
||||
Written by <a href="https://twitter.com/yenzie">Yanick Champoux</a>. Code
|
||||
available on
|
||||
<a href="https://github.com/yanick/aotds-shipyard">Github</a>
|
||||
</footer>
|
||||
|
||||
{/if}
|
||||
|
||||
<script>
|
||||
import { setContext } from "svelte";
|
||||
|
||||
import Header from './Header.svelte';
|
||||
import Header from "./Header.svelte";
|
||||
import Ribbon from "./Ribbon.svelte";
|
||||
import shipStore from "../stores/ship";
|
||||
import OutputJson from './Output/Json.svelte';
|
||||
import Print from './Output/Print/index.svelte';
|
||||
import OutputJson from "./Output/Json.svelte";
|
||||
import Print from "./Output/Print/index.svelte";
|
||||
|
||||
import ShipSpecs from './ShipSpecs/index.svelte';
|
||||
import Notes from './Notes.svelte';
|
||||
import ShipSpecs from "./ShipSpecs/index.svelte";
|
||||
import Notes from "./Notes.svelte";
|
||||
import ShipItem from "./ShipItem/index.svelte";
|
||||
import Field from "./Field/index.svelte";
|
||||
import Hull from "./Hull/index.svelte";
|
||||
@ -129,11 +132,11 @@
|
||||
setContext("ship_change", ship.dispatch);
|
||||
|
||||
let show_notes = false;
|
||||
const toggle_notes = () => show_notes = !show_notes;
|
||||
const toggle_notes = () => (show_notes = !show_notes);
|
||||
|
||||
let output = null;
|
||||
|
||||
const set_output = value => output = value;
|
||||
const set_output = (value) => (output = value);
|
||||
|
||||
</script>
|
||||
|
||||
@ -159,7 +162,6 @@
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
|
||||
:global(main > *) {
|
||||
grid-column: 1;
|
||||
}
|
||||
@ -174,7 +176,8 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.notes {
|
||||
.about {
|
||||
margin-right: 2em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
13
src/components/Output/Json.svench
Normal file
13
src/components/Output/Json.svench
Normal file
@ -0,0 +1,13 @@
|
||||
<Json ship={{potato: 'grande'}}>
|
||||
</Json>
|
||||
|
||||
<script>
|
||||
import Json from './Json.svelte';
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
div {
|
||||
background-color: red;
|
||||
}
|
||||
</style>
|
4
src/components/Ribbon.svelte
Normal file
4
src/components/Ribbon.svelte
Normal file
@ -0,0 +1,4 @@
|
||||
<!-- github ribbon from https://tholman.com/github-corners/ -->
|
||||
<a href="https://github.com/yanick/aotds-shipyard"
|
||||
class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>
|
||||
|
@ -1,12 +1,13 @@
|
||||
<div>
|
||||
<h2>{label}</h2>
|
||||
<hr/>
|
||||
<h2>{label}</h2>
|
||||
<hr />
|
||||
</div>
|
||||
|
||||
<slot />
|
||||
|
||||
<script>
|
||||
export let label;
|
||||
export let label;
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@ -16,8 +17,12 @@
|
||||
align-items: baseline;
|
||||
gap: 1em;
|
||||
}
|
||||
h2 {
|
||||
font-weight: bold;
|
||||
}
|
||||
hr {
|
||||
flex: 1;
|
||||
heigth: 0px;
|
||||
background: #333;
|
||||
}
|
||||
</style>
|
||||
|
||||
</style>
|
||||
|
@ -1,10 +1,10 @@
|
||||
<div><slot /></div>
|
||||
<div><slot /></div>
|
||||
|
||||
<div class="mass" bind:this={mass_el}>{ mass }</div>
|
||||
<div class="cost" bind:this={cost_el}>{ cost }</div>
|
||||
<div class="mass" bind:this={mass_el}>{mass}</div>
|
||||
<div class="cost" bind:this={cost_el}>{cost}</div>
|
||||
|
||||
<script>
|
||||
import { tick } from 'svelte';
|
||||
import { tick } from "svelte";
|
||||
|
||||
export let mass;
|
||||
export let cost;
|
||||
@ -13,40 +13,54 @@
|
||||
let cost_el;
|
||||
|
||||
const update_el = async (el) => {
|
||||
if(!el) return;
|
||||
el.classList.remove('updated');
|
||||
if (!el) return;
|
||||
el.classList.remove("updated");
|
||||
void el.offsetWidth;
|
||||
el.classList.add('updated');
|
||||
}
|
||||
el.classList.add("updated");
|
||||
};
|
||||
|
||||
$: update_el( mass_el, mass );
|
||||
$: update_el( cost_el, cost );
|
||||
$: update_el(mass_el, mass);
|
||||
$: update_el(cost_el, cost);
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
div {
|
||||
margin-bottom: 1em;
|
||||
|
||||
}
|
||||
.cost,.mass { padding: 0px 2em; text-align: right; }
|
||||
.cost { grid-column: 3 }
|
||||
.mass { grid-column: 2 }
|
||||
.cost,
|
||||
.mass {
|
||||
padding: 0px 2em;
|
||||
text-align: right;
|
||||
}
|
||||
.cost {
|
||||
grid-column: 3;
|
||||
}
|
||||
.mass {
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
.ship-item {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.ship-item :global(> *) {
|
||||
flex: 1;
|
||||
}
|
||||
.ship-item :global(> *) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 0.75em;
|
||||
}
|
||||
.cost:after { content: '\00A4'; margin-left: 0.5em; }
|
||||
.mass:after { content: url(mass.svg); width: 0.75em; display:
|
||||
inline-block; margin-left: 0.5em; }
|
||||
.cost:after {
|
||||
content: "\00A4";
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
.mass:after {
|
||||
content: url(mass.svg);
|
||||
width: 0.75em;
|
||||
display: inline-block;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
|
||||
:global(.updated) {
|
||||
animation-name: update;
|
||||
@ -54,11 +68,23 @@
|
||||
animation-fill-mode: forwards;
|
||||
}
|
||||
|
||||
@keyframes update {
|
||||
0% {color:inherit; font-weight: inherit;}
|
||||
20% {color:red; font-weight: bold;}
|
||||
80% {color:red; font-weight: bold;}
|
||||
100% {color:inherit; font-weight: inherit; }
|
||||
}
|
||||
@keyframes update {
|
||||
0% {
|
||||
color: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
20% {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
||||
80% {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
}
|
||||
100% {
|
||||
color: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user