2021-08-21 16:02:35 -04:00
|
|
|
<script lang="ts">
|
2021-08-23 14:26:25 -04:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2021-08-21 16:02:35 -04:00
|
|
|
import { capitalize } from "lodash";
|
|
|
|
|
import { Card, CardHeader, CardTitle, CardBody, CardText, CardFooter } from "sveltestrap";
|
2021-08-23 14:26:25 -04:00
|
|
|
import { Detail, rollDetail } from "../rollers/details";
|
2021-08-21 16:02:35 -04:00
|
|
|
import DieIcon from "./DieIcon.svelte";
|
2021-08-23 14:26:25 -04:00
|
|
|
import CardButtons from "./CardTitleButtons.svelte";
|
|
|
|
|
import { RerolledEvent } from "../types/RerolledEvent";
|
2021-08-21 16:02:35 -04:00
|
|
|
|
2021-08-23 14:26:25 -04:00
|
|
|
const dispatch = createEventDispatcher();
|
2021-08-21 16:02:35 -04:00
|
|
|
export let detail: Detail;
|
|
|
|
|
export let timestamp: string;
|
2021-08-23 14:26:25 -04:00
|
|
|
|
|
|
|
|
function reroll() {
|
|
|
|
|
detail = rollDetail(detail.type);
|
|
|
|
|
dispatch("rerolled", new RerolledEvent("detail-" + detail.type, detail));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function remove() {
|
|
|
|
|
dispatch("remove");
|
|
|
|
|
}
|
2021-08-21 16:02:35 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<main>
|
|
|
|
|
<Card class="mb-3">
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle>
|
2021-08-23 14:26:25 -04:00
|
|
|
<div class="title">
|
|
|
|
|
<div class="description">
|
|
|
|
|
Detail: {capitalize(detail.type)}
|
|
|
|
|
</div>
|
|
|
|
|
<CardButtons data={detail} dataType={"detail-" + detail.type} on:reroll={reroll} on:remove={remove} />
|
|
|
|
|
</div></CardTitle
|
|
|
|
|
>
|
2021-08-21 16:02:35 -04:00
|
|
|
</CardHeader>
|
|
|
|
|
<CardBody>
|
|
|
|
|
<CardText>
|
|
|
|
|
{detail.description}<DieIcon value={detail.roll} />
|
|
|
|
|
</CardText>
|
|
|
|
|
</CardBody>
|
2021-08-23 14:26:25 -04:00
|
|
|
{#if timestamp}
|
|
|
|
|
<CardFooter>{timestamp}</CardFooter>
|
|
|
|
|
{/if}
|
2021-08-21 16:02:35 -04:00
|
|
|
</Card>
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<style>
|
2021-08-23 14:26:25 -04:00
|
|
|
main {
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
.title {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
2021-08-21 16:02:35 -04:00
|
|
|
</style>
|