Merge branch 'master' into ai/issue-57
Some checks failed
Test / test (push) Failing after 2s

This commit is contained in:
2026-10-15 14:00:02 +00:00
5 changed files with 246 additions and 104 deletions

View File

@@ -24,6 +24,16 @@ const abilityStats = [
{ key: 'int', label: 'INT' }, { key: 'wis', label: 'WIS' }, { key: 'cha', label: 'CHA' }
];
// Les pestanyes del lateral dret reparteixen la fitxa: característiques i combat,
// inventari, trets i conjurs. Són pestanyes de marcadors, no una pàgina nova.
const tabs = [
{ key: 'abilities', label: 'campaigns.character-sheet.tabs.abilities' },
{ key: 'inventory', label: 'campaigns.character-sheet.tabs.inventory' },
{ key: 'traits', label: 'campaigns.character-sheet.tabs.traits' },
{ key: 'spells', label: 'campaigns.character-sheet.tabs.spells' }
];
const activeTab = ref('abilities');
function normalizeActor(actor) {
return {
name: actor?.name ?? '',
@@ -207,7 +217,9 @@ async function saveSheet() {
<div v-if="error" class="sheet-error">{{ error }}</div>
<main class="sheet-grid">
<div class="sheet-layout">
<div class="sheet-content">
<main v-show="activeTab === 'abilities'" class="sheet-grid">
<div v-if="form.image || editing" class="sheet-portrait" :class="{ empty: !form.image }">
<img v-if="form.image" :src="imageUrl" :alt="$t('campaigns.character-sheet.photo')">
<button v-if="editing && !form.image" class="portrait-upload" type="button" :disabled="uploadingPhoto" @click="pickPhoto">
@@ -256,19 +268,9 @@ async function saveSheet() {
<textarea v-if="editing" v-model="form.proficiencies" rows="5" :placeholder="$t('campaigns.character-sheet.proficiencies-placeholder')" />
<p v-else class="sheet-copy">{{ form.proficiencies || $t('campaigns.character-sheet.empty-proficiencies') }}</p>
</section>
</main>
<section class="sheet-panel traits-panel">
<h2>{{ $t('campaigns.character-sheet.traits') }}</h2>
<textarea v-if="editing" v-model="form.traits" rows="5" :placeholder="$t('campaigns.character-sheet.traits-placeholder')" />
<p v-else class="sheet-copy">{{ form.traits || $t('campaigns.character-sheet.empty-traits') }}</p>
</section>
<section class="sheet-panel spells-panel">
<h2>{{ $t('campaigns.character-sheet.spells') }}</h2>
<textarea v-if="editing" v-model="form.spells" rows="5" :placeholder="$t('campaigns.character-sheet.spells-placeholder')" />
<p v-else class="sheet-copy">{{ form.spells || $t('campaigns.character-sheet.empty-spells') }}</p>
</section>
<main v-show="activeTab === 'inventory'" class="sheet-tab-body">
<section class="sheet-panel inventory-panel">
<div class="panel-title-row">
<h2>{{ $t('campaigns.character-sheet.inventory') }}</h2>
@@ -302,6 +304,37 @@ async function saveSheet() {
</div>
</section>
</main>
<main v-show="activeTab === 'traits'" class="sheet-tab-body">
<section class="sheet-panel traits-panel">
<h2>{{ $t('campaigns.character-sheet.traits') }}</h2>
<textarea v-if="editing" v-model="form.traits" rows="12" :placeholder="$t('campaigns.character-sheet.traits-placeholder')" />
<p v-else class="sheet-copy">{{ form.traits || $t('campaigns.character-sheet.empty-traits') }}</p>
</section>
</main>
<main v-show="activeTab === 'spells'" class="sheet-tab-body">
<section class="sheet-panel spells-panel">
<h2>{{ $t('campaigns.character-sheet.spells') }}</h2>
<textarea v-if="editing" v-model="form.spells" rows="12" :placeholder="$t('campaigns.character-sheet.spells-placeholder')" />
<p v-else class="sheet-copy">{{ form.spells || $t('campaigns.character-sheet.empty-spells') }}</p>
</section>
</main>
</div>
<nav class="sheet-tabs" role="tablist" aria-orientation="vertical">
<button
v-for="tab in tabs"
:key="tab.key"
class="sheet-tab"
:class="{ active: activeTab === tab.key }"
type="button"
role="tab"
:aria-selected="activeTab === tab.key"
@click="activeTab = tab.key"
>{{ $t(tab.label) }}</button>
</nav>
</div>
</div>
</div>
</template>
@@ -325,7 +358,27 @@ async function saveSheet() {
.sheet-button.primary { background: var(--color-link); color: var(--color-background); border-color: var(--color-link); }
.sheet-button:disabled { opacity: .55; cursor: wait; }
.sheet-button.compact { padding: 5px 9px; font-size: 12px; }
.sheet-grid { display: grid; grid-template-columns: minmax(200px, 34%) minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto auto; gap: 11px; align-items: start; }
.sheet-grid { display: grid; grid-template-columns: minmax(200px, 34%) minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto; gap: 11px; align-items: start; }
.sheet-layout { display: flex; align-items: flex-start; gap: 10px; }
.sheet-content { flex: 1 1 auto; min-width: 0; }
.sheet-tab-body { display: block; }
.sheet-tabs { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; align-self: flex-start; }
.sheet-tab {
text-align: left;
padding: 9px 14px 9px 11px;
border: 1px solid var(--color-border);
border-left-width: 3px;
border-radius: 0 9px 9px 0;
background: var(--color-background-soft);
color: var(--color-text);
font: 13px MrEavesRemake;
letter-spacing: .02em;
white-space: nowrap;
cursor: pointer;
transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.sheet-tab:hover { background: var(--color-button-hover); }
.sheet-tab.active { background: var(--color-background-light); color: var(--color-link); border-left-color: var(--color-link); box-shadow: 0 3px 12px var(--color-window-shadow); }
.sheet-panel { min-width: 0; padding: 13px; border: 1px solid var(--color-border); border-radius: 10px; background: var(--color-background-light); box-shadow: 0 3px 12px var(--color-window-shadow); }
.sheet-panel h2 { margin: 0 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--color-border); font: 17px MrEavesRemake; letter-spacing: .03em; }
.sheet-panel h3 { margin: 13px 0 7px; font: 14px MrEavesRemake; }
@@ -340,9 +393,7 @@ async function saveSheet() {
.portrait-controls button:disabled { opacity: .55; cursor: wait; }
.photo-input { display: none; }
.abilities-panel { grid-column: 2 / -1; grid-row: 1; }
.combat-panel { grid-column: 2; grid-row: 2; }
.traits-panel { grid-column: 3; grid-row: 2; }
.spells-panel { grid-column: 2 / -1; grid-row: 3; }
.combat-panel { grid-column: 2 / -1; grid-row: 2; }
.ability-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.ability-card { min-height: 83px; padding: 8px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-background-soft); }
.ability-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; opacity: .75; }
@@ -369,7 +420,6 @@ textarea { resize: vertical; width: 100%; min-height: 88px; font-size: 12px; }
.weight-summary strong { white-space: nowrap; }
.weight-track { height: 5px; margin-bottom: 10px; overflow: hidden; border-radius: 999px; background: var(--color-background-soft); }
.weight-fill { height: 100%; border-radius: inherit; background: var(--color-link); transition: width .2s ease; }
.inventory-panel { grid-column: 2 / -1; grid-row: 4; }
.inventory-table-wrap { overflow-x: auto; }
.inventory-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.inventory-table th { padding: 6px 7px; text-align: left; font-weight: 600; opacity: .7; }
@@ -383,17 +433,17 @@ textarea { resize: vertical; width: 100%; min-height: 88px; font-size: 12px; }
.sheet-error { padding: 7px 10px; margin-bottom: 10px; border-radius: 6px; color: var(--color-red); background: var(--color-background-soft); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
.sheet-grid { grid-template-columns: 1fr 1fr; grid-template-rows: none; }
.sheet-portrait { grid-column: 1 / -1; grid-row: auto; }
.abilities-panel { grid-column: 1 / -1; grid-row: auto; }
.combat-panel, .traits-panel { grid-column: auto; grid-row: auto; }
.spells-panel, .inventory-panel { grid-column: 1 / -1; grid-row: auto; }
.sheet-grid { grid-template-columns: 1fr; grid-template-rows: none; }
.sheet-portrait, .abilities-panel, .combat-panel { grid-column: 1 / -1; grid-row: auto; }
}
@media (max-width: 520px) {
.sheet-body { padding: 10px; }
.sheet-hero { align-items: flex-start; flex-wrap: wrap; }
.sheet-actions { margin-left: auto; }
.sheet-grid { grid-template-columns: 1fr; }
.ability-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sheet-layout { flex-direction: column; }
.sheet-tabs { flex-direction: row; flex-wrap: wrap; order: -1; }
.sheet-tab { flex: 1 1 auto; text-align: center; border-radius: 7px; border-left-width: 1px; border-top-width: 3px; }
.sheet-tab.active { border-left-color: var(--color-border); border-top-color: var(--color-link); }
}
</style>

View File

@@ -105,6 +105,7 @@
},
"character-sheet": {
"title": "Fitxa de personatge", "name": "Nom del personatge", "class": "Classe", "subclass": "Subclasse", "unset-class": "Classe sense definir",
"tabs": { "abilities": "Característiques", "inventory": "Inventari", "traits": "Trets", "spells": "Conjurs" },
"level": "Nivell", "species": "Espècie", "unset-species": "Espècie sense definir", "edit": "Edita la fitxa", "cancel": "Cancel·la",
"saving": "Desant...", "save": "Desa la fitxa", "save-error": "No s'ha pogut desar aquesta fitxa de personatge.", "photo": "Foto", "upload-photo": "Pujar foto", "change-photo": "Canviar foto", "remove-photo": "Treure foto", "uploading-photo": "Pujant...", "photo-error": "No s'ha pogut pujar aquesta foto.", "ability-scores": "Característiques", "proficiency-bonus": "Bonificador de competència",
"combat": "Combat", "armor-class": "Classe d'armadura", "speed": "Velocitat", "proficiencies": "Competències",

View File

@@ -109,6 +109,7 @@
},
"character-sheet": {
"title": "Character Sheet", "name": "Character name", "class": "Class", "subclass": "Subclass", "unset-class": "Class not set",
"tabs": { "abilities": "Ability Scores", "inventory": "Inventory", "traits": "Traits", "spells": "Spells" },
"level": "Level", "species": "Species", "unset-species": "Species not set", "edit": "Edit sheet", "cancel": "Cancel",
"saving": "Saving...", "save": "Save sheet", "save-error": "Unable to save this character sheet.",
"photo": "Photo", "upload-photo": "Upload photo", "change-photo": "Change photo", "remove-photo": "Remove photo",

View File

@@ -105,6 +105,7 @@
},
"character-sheet": {
"title": "Hoja de personaje", "name": "Nombre del personaje", "class": "Clase", "subclass": "Subclase", "unset-class": "Clase sin definir",
"tabs": { "abilities": "Características", "inventory": "Inventario", "traits": "Rasgos", "spells": "Conjuros" },
"level": "Nivel", "species": "Especie", "unset-species": "Especie sin definir", "edit": "Editar hoja", "cancel": "Cancelar",
"saving": "Guardando...", "save": "Guardar hoja", "save-error": "No se pudo guardar esta hoja de personaje.", "photo": "Foto", "upload-photo": "Subir foto", "change-photo": "Cambiar foto", "remove-photo": "Quitar foto", "uploading-photo": "Subiendo...", "photo-error": "No se pudo subir esta foto.", "ability-scores": "Características", "proficiency-bonus": "Bonificador por competencia",
"combat": "Combate", "armor-class": "Clase de armadura", "speed": "Velocidad", "proficiencies": "Competencias",

View File

@@ -0,0 +1,89 @@
// Tests for Syndria98/dragonroll#55: the character sheet splits its contents across bookmarks down
// the right edge (ability scores, inventory, traits, spells) instead of stacking every panel on one
// long page.
//
// The repository root installs no dependencies, so the window wiring is read from the sources the way
// tests/item-sheet-window.test.js and tests/settings-window.test.js do it.
//
// Run with `npm test` from the repository root, or `node --test tests/`.
const { test } = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const read = (...parts) => fs.readFileSync(path.join(__dirname, "..", ...parts), "utf8");
const sheetSource = read("frontend", "app", "components", "windows", "CharacterSheetWindow.vue");
const script = /<script setup>([\s\S]*?)<\/script>/.exec(sheetSource)?.[1] ?? "";
const template = /<template>([\s\S]*)<\/template>/.exec(sheetSource)?.[1] ?? "";
// The four bookmarks the issue asks for, in order.
test("the sheet declares the four tabs the issue splits the contents into", () => {
const array = /const tabs = \[([\s\S]*?)\];/.exec(script)?.[1] ?? "";
const keys = [...array.matchAll(/key:\s*['"](\w+)['"]/g)].map((m) => m[1]);
assert.deepEqual(keys, ["abilities", "inventory", "traits", "spells"]);
for (const key of keys) {
assert.ok(
new RegExp(`label:\\s*['"]campaigns\\.character-sheet\\.tabs\\.${key}['"]`).test(array),
`the ${key} tab must point at its own i18n key`
);
}
assert.match(script, /const activeTab = ref\(['"]abilities['"]\)/, "the sheet opens on the ability scores tab");
});
test("the tabs sit on the right as a vertical bookmark rail", () => {
assert.match(template, /<nav class="sheet-tabs"[^>]*role="tablist"[^>]*aria-orientation="vertical"/);
assert.match(template, /v-for="tab in tabs"[\s\S]*?:aria-selected="activeTab === tab\.key"/);
const rail = /\.sheet-tabs\s*\{[^}]*\}/.exec(sheetSource)?.[0] ?? "";
assert.match(rail, /flex-direction:\s*column/, "the bookmarks stack down the right edge");
// content column and rail sit side by side, the rail hugging the right
assert.match(sheetSource, /\.sheet-layout\s*\{[^}]*display:\s*flex[^}]*\}/, "content and rail share a row");
assert.match(sheetSource, /\.sheet-content\s*\{[^}]*flex:\s*1[^}]*\}/, "the content takes the room, the rail stays slim");
});
// Each tab shows only its own panels; the rest are hidden with v-show so an in-progress edit is
// not thrown away when hopping between tabs.
function tabBody(key) {
const block = new RegExp(`<main v-show="activeTab === '${key}'"[\\s\\S]*?</main>`).exec(template)?.[0];
assert.ok(block, `expected a body for the ${key} tab`);
return block;
}
test("every tab shows only its own content and hides the others", () => {
const abilities = tabBody("abilities");
assert.match(abilities, /class="sheet-portrait"/, "the portrait stays with ability scores");
assert.match(abilities, /class="sheet-panel abilities-panel"/);
assert.match(abilities, /class="sheet-panel combat-panel"/, "combat rides with the ability scores");
for (const other of ["inventory-panel", "traits-panel", "spells-panel"]) {
assert.doesNotMatch(abilities, new RegExp(other));
}
for (const [key, panel] of [["inventory", "inventory-panel"], ["traits", "traits-panel"], ["spells", "spells-panel"]]) {
const body = tabBody(key);
assert.ok(body.includes(panel), `the ${key} tab shows the ${panel}`);
assert.doesNotMatch(body, /class="sheet-portrait"/);
}
// the panels are toggled, not unmounted, so editing on one tab and flipping away keeps the draft
assert.match(template, /v-show="activeTab === 'inventory'"/);
assert.match(template, /v-show="activeTab === 'traits'"/);
assert.match(template, /v-show="activeTab === 'spells'"/);
});
test("the tabs still edit and save through the existing sheet form", () => {
assert.match(tabBody("inventory"), /@click="addInventoryItem"/);
assert.match(tabBody("inventory"), /removeInventoryItem\(index\)/);
assert.match(tabBody("traits"), /v-model="form\.traits"/);
assert.match(tabBody("spells"), /v-model="form\.spells"/);
assert.match(tabBody("abilities"), /v-model\.number="form\.abilityScores\[stat\.key\]"/);
});
test("every locale names the four tabs", () => {
for (const locale of ["en", "es", "ca"]) {
const sheet = JSON.parse(read("frontend", "i18n", "locales", locale, "campaigns.json"))["character-sheet"];
for (const key of ["abilities", "inventory", "traits", "spells"]) {
assert.ok(sheet.tabs?.[key], `${locale} is missing campaigns.character-sheet.tabs.${key}`);
}
}
});