From 1ee16327e945269f9f650ff49599cef8d60c209d Mon Sep 17 00:00:00 2001 From: Lukas Forsberg Date: Wed, 10 Dec 2025 22:54:41 +0100 Subject: [PATCH] better gui --- frontend/src/lib/common/autogrow.js | 18 ++++ frontend/src/lib/shadorwun/character.svelte | 104 ++++++++++++++------ 2 files changed, 92 insertions(+), 30 deletions(-) create mode 100644 frontend/src/lib/common/autogrow.js diff --git a/frontend/src/lib/common/autogrow.js b/frontend/src/lib/common/autogrow.js new file mode 100644 index 0000000..0dff45f --- /dev/null +++ b/frontend/src/lib/common/autogrow.js @@ -0,0 +1,18 @@ +import { tick } from "svelte"; + +export function autoGrow(node) { + function resize() { + node.style.height = "auto"; + node.style.height = node.scrollHeight + "px"; + } + + // wait until DOM updates to apply initial value + tick().then(resize); + node.addEventListener("input", resize); + + return { + destroy() { + node.removeEventListener("input", resize); + } + }; +} \ No newline at end of file diff --git a/frontend/src/lib/shadorwun/character.svelte b/frontend/src/lib/shadorwun/character.svelte index 0a07871..3f3ed42 100644 --- a/frontend/src/lib/shadorwun/character.svelte +++ b/frontend/src/lib/shadorwun/character.svelte @@ -3,7 +3,8 @@ import { API_BASE } from '$lib/config'; import { Defaults } from './defaults.svelte'; import type { Skill, Connection} from './types.svelte'; - + import { autoGrow } from '$lib/common/autogrow'; + export let currentCharacter: any; export let currentCharacterData: any; @@ -85,17 +86,46 @@

Attributes

-{#each Object.entries(characterData.Attributes) as [key, value], i} -
- - -
-{/each} + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + + + + + +

Skills

@@ -105,7 +135,7 @@ Name Rating Attribute - Dice Pool + Dice Page @@ -115,7 +145,7 @@ {#each characterData.Skills as skill, i} - + - + {/each} @@ -145,10 +175,10 @@ {#each characterData.Connections as connection, i} - + - + {/each} @@ -175,17 +205,17 @@ {#each characterData.RangedWeapons as weapon, i} - + - + - + - + - + {/each} @@ -200,8 +230,8 @@ Reach Damage Type - Strength Multiplier - Calculated Damage + Multiplier + Cal.Dmg AP Page @@ -220,7 +250,7 @@ - + {/each} @@ -247,7 +277,7 @@ - + {/each} @@ -276,7 +306,7 @@ - + {/each} @@ -305,7 +335,7 @@ - + {/each} @@ -330,7 +360,7 @@ - + {/each} @@ -353,7 +383,7 @@ - + {/each} @@ -416,6 +446,20 @@ gap: 0.5em; /* space between each input-row */ } + .red-button { + border: none; /* optional: remove default border */ + cursor: pointer; /* optional: pointer cursor */ + } + + .input-height { + border: none; /* optional: remove default border */ + font: inherit; /* copies all font-related properties from the parent/input styling */ + height: auto; /* allows autoGrow action to work */ + min-height: 0; + /* resize: none; */ + overflow: hidden; /* Allow autoGrow to work clean */ + width: 10em; /* 15 × current font size */ + } .input-row { display: flex; align-items: center;