mirror of
https://github.com/RussellChamp/tpw-roller.git
synced 2026-10-28 00:22:36 +00:00
add icons to danger roller
This commit is contained in:
1 parent
e96028b65c
commit
d5a1654b22
1 file changed
+13
-3
@@ -1,12 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as _ from "lodash";
|
import * as _ from "lodash";
|
||||||
import { format as formatDate } from "date-fns";
|
import { format as formatDate } from "date-fns";
|
||||||
|
import { Icon } from "sveltestrap";
|
||||||
import { Danger, rollDanger } from "./dangers";
|
import { Danger, rollDanger } from "./dangers";
|
||||||
|
|
||||||
export let rollResults: { value: Danger; timestamp: string }[] = [];
|
export let rollResults: { danger: Danger; icon: string; timestamp: string }[] = [];
|
||||||
|
|
||||||
function roll(event: Event) {
|
function roll(event: Event) {
|
||||||
rollResults = [{ value: rollDanger(), timestamp: formatDate(new Date(), "P kk:mm:ss") }, ...rollResults];
|
let danger = rollDanger();
|
||||||
|
let icon =
|
||||||
|
danger.category == "unnatural entity"
|
||||||
|
? "person-square"
|
||||||
|
: danger.category == "hazard"
|
||||||
|
? "lightning-fill"
|
||||||
|
: danger.category == "creature"
|
||||||
|
? "emoji-neutral"
|
||||||
|
: "";
|
||||||
|
rollResults = [{ danger, icon, timestamp: formatDate(new Date(), "P kk:mm:ss") }, ...rollResults];
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -16,7 +26,7 @@
|
|||||||
|
|
||||||
{#each rollResults as result}
|
{#each rollResults as result}
|
||||||
<h4>
|
<h4>
|
||||||
{result.timestamp}: {result.value.category} ({result.value.subcategory}): {result.value.description}
|
{result.timestamp}: {result.danger.category} ({result.danger.subcategory}) <Icon name={result.icon} />: {result.danger.description}
|
||||||
</h4>
|
</h4>
|
||||||
{/each}
|
{/each}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
Reference in new issue
Block a user