aotds-docks/src/lib/components/ShipItem.svelte

99 lines
1.4 KiB
Svelte
Raw Normal View History

2022-03-01 17:42:33 +00:00
<div class="ship-item">
<div><slot /></div>
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
<div class="reqs">
2023-03-20 15:59:50 +00:00
<div class="mass" bind:this={mass_el}>
2023-04-20 15:54:18 +00:00
{mass} <i>Weight</i>
</div>
<div class="cost" bind:this={cost_el}>
{cost}
<i>Paid</i>
2023-03-20 15:59:50 +00:00
</div>
2022-03-01 17:42:33 +00:00
</div>
</div>
2020-07-19 20:21:28 +00:00
<script>
2023-03-20 15:59:50 +00:00
import { base } from "$app/paths";
2021-05-17 14:07:01 +00:00
import { tick } from "svelte";
2020-07-25 15:56:23 +00:00
2020-07-19 20:21:28 +00:00
export let mass;
export let cost;
2020-07-25 15:56:23 +00:00
let mass_el;
let cost_el;
const update_el = async (el) => {
2021-05-17 14:07:01 +00:00
if (!el) return;
el.classList.remove("updated");
2020-07-25 15:56:23 +00:00
void el.offsetWidth;
2021-05-17 14:07:01 +00:00
el.classList.add("updated");
};
2020-07-25 15:56:23 +00:00
2021-05-17 14:07:01 +00:00
$: update_el(mass_el, mass);
$: update_el(cost_el, cost);
2020-07-19 20:21:28 +00:00
</script>
<style>
2020-07-28 18:38:40 +00:00
div {
margin-bottom: 1em;
}
2022-03-01 17:42:33 +00:00
2021-05-17 14:07:01 +00:00
.cost,
.mass {
2022-03-01 17:42:33 +00:00
width: 4em;
padding: 0px 0.5em;
2021-05-17 14:07:01 +00:00
text-align: right;
}
2020-07-28 18:38:40 +00:00
2020-07-19 20:21:28 +00:00
.ship-item {
display: flex;
}
2021-05-17 14:07:01 +00:00
.ship-item :global(> *) {
flex: 1;
}
2020-07-19 20:21:28 +00:00
img {
width: 0.75em;
}
2022-04-05 23:58:32 +00:00
.mass img {
2021-05-17 14:07:01 +00:00
width: 0.75em;
display: inline-block;
margin-left: 0.5em;
}
2020-07-25 15:56:23 +00:00
:global(.updated) {
animation-name: update;
animation-duration: 1.5s;
animation-fill-mode: forwards;
}
2021-05-17 14:07:01 +00:00
@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;
}
}
2020-07-25 15:56:23 +00:00
2022-03-01 17:42:33 +00:00
.ship-item {
display: flex;
}
.reqs {
flex: 0;
width: 10em;
display: flex;
}
2020-07-19 20:21:28 +00:00
</style>