Merge pull request 'Fix #91: Make character column always visible' (#94) from ai/issue-91 into master
Reviewed-on: #94
This commit was merged in pull request #94.
This commit is contained in:
@@ -319,7 +319,10 @@ async function saveSheet() {
|
|||||||
|
|
||||||
<div v-if="error" class="sheet-error">{{ error }}</div>
|
<div v-if="error" class="sheet-error">{{ error }}</div>
|
||||||
|
|
||||||
<main v-show="activeTab === 'abilities'" class="sheet-grid">
|
<!-- La columna del personatge no penja de cap pestanya: la imatge i el que es mira
|
||||||
|
d'anada i tornada — classe d'armadura, velocitat, bonificadors i les barres de
|
||||||
|
cops — es queden a la vista des de qualsevol pestanya de la fitxa. -->
|
||||||
|
<div class="sheet-layout">
|
||||||
<div class="character-column">
|
<div class="character-column">
|
||||||
<div v-if="form.image || editing" class="sheet-portrait" :class="{ empty: !form.image }">
|
<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')">
|
<img v-if="form.image" :src="imageUrl" :alt="$t('campaigns.character-sheet.photo')">
|
||||||
@@ -387,146 +390,148 @@ async function saveSheet() {
|
|||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="sheet-panel abilities-panel">
|
<main v-show="activeTab === 'abilities'" class="sheet-tab-body">
|
||||||
<h2>{{ $t('campaigns.character-sheet.ability-scores') }}</h2>
|
<section class="sheet-panel abilities-panel">
|
||||||
<div class="ability-grid">
|
<h2>{{ $t('campaigns.character-sheet.ability-scores') }}</h2>
|
||||||
<div v-for="stat in abilityStats" :key="stat.key" class="ability-card">
|
<div class="ability-grid">
|
||||||
<span class="ability-label">{{ stat.label }}</span>
|
<div v-for="stat in abilityStats" :key="stat.key" class="ability-card">
|
||||||
<input v-if="editing" v-model.number="form.abilityScores[stat.key]" type="number" min="1" max="30" :aria-label="stat.label">
|
<span class="ability-label">{{ stat.label }}</span>
|
||||||
<strong v-else class="ability-score">{{ form.abilityScores[stat.key] }}</strong>
|
<input v-if="editing" v-model.number="form.abilityScores[stat.key]" type="number" min="1" max="30" :aria-label="stat.label">
|
||||||
<span class="ability-modifier">{{ abilityModifier(form.abilityScores[stat.key]) }}</span>
|
<strong v-else class="ability-score">{{ form.abilityScores[stat.key] }}</strong>
|
||||||
|
<span class="ability-modifier">{{ abilityModifier(form.abilityScores[stat.key]) }}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Les tirades de salvació van just a sota de les característiques, que
|
<!-- Les tirades de salvació van just a sota de les característiques, que
|
||||||
són les que les manen: el cercle diu si el personatge hi està entrenat. -->
|
són les que les manen: el cercle diu si el personatge hi està entrenat. -->
|
||||||
<h3>{{ $t('campaigns.character-sheet.saving-throws') }}</h3>
|
<h3>{{ $t('campaigns.character-sheet.saving-throws') }}</h3>
|
||||||
<div class="saving-throw-grid">
|
<div class="saving-throw-grid">
|
||||||
<button
|
<button
|
||||||
v-for="stat in abilityStats"
|
v-for="stat in abilityStats"
|
||||||
:key="stat.key"
|
:key="stat.key"
|
||||||
class="proficiency-row"
|
class="proficiency-row"
|
||||||
type="button"
|
type="button"
|
||||||
role="switch"
|
role="switch"
|
||||||
:aria-checked="form.savingThrows[stat.key]"
|
:aria-checked="form.savingThrows[stat.key]"
|
||||||
:disabled="!editing"
|
:disabled="!editing"
|
||||||
@click="toggleProficiency('savingThrows', stat.key)"
|
@click="toggleProficiency('savingThrows', stat.key)"
|
||||||
>
|
>
|
||||||
<span class="proficiency-dot" :class="{ proficient: form.savingThrows[stat.key] }" aria-hidden="true" />
|
<span class="proficiency-dot" :class="{ proficient: form.savingThrows[stat.key] }" aria-hidden="true" />
|
||||||
<span class="proficiency-name">{{ $t(`campaigns.character-sheet.abilities.${stat.key}`) }}</span>
|
<span class="proficiency-name">{{ $t(`campaigns.character-sheet.abilities.${stat.key}`) }}</span>
|
||||||
<span class="proficiency-modifier">{{ savingThrowModifier(stat) }}</span>
|
<span class="proficiency-modifier">{{ savingThrowModifier(stat) }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="sheet-panel skills-panel">
|
|
||||||
<h2>{{ $t('campaigns.character-sheet.skills') }}</h2>
|
|
||||||
<div class="skill-grid">
|
|
||||||
<button
|
|
||||||
v-for="skill in skillList"
|
|
||||||
:key="skill.key"
|
|
||||||
class="proficiency-row"
|
|
||||||
type="button"
|
|
||||||
role="switch"
|
|
||||||
:aria-checked="form.skills[skill.key]"
|
|
||||||
:disabled="!editing"
|
|
||||||
@click="toggleProficiency('skills', skill.key)"
|
|
||||||
>
|
|
||||||
<span class="proficiency-dot" :class="{ proficient: form.skills[skill.key] }" aria-hidden="true" />
|
|
||||||
<span class="proficiency-name">{{ $t(`campaigns.character-sheet.skill-names.${skill.key}`) }}</span>
|
|
||||||
<span class="proficiency-ability">{{ skill.ability.toUpperCase() }}</span>
|
|
||||||
<span class="proficiency-modifier">{{ skillModifier(skill) }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="sheet-panel proficiencies-panel">
|
|
||||||
<h2>{{ $t('campaigns.character-sheet.proficiencies') }}</h2>
|
|
||||||
<textarea v-if="editing" v-model="form.proficiencies" rows="7" :placeholder="$t('campaigns.character-sheet.proficiencies-placeholder')" />
|
|
||||||
<p v-else class="sheet-copy">{{ form.proficiencies || $t('campaigns.character-sheet.empty-proficiencies') }}</p>
|
|
||||||
|
|
||||||
<!-- Les eines i els idiomes tenen llista pròpia; el text de dalt guarda
|
|
||||||
el que no en té, com les armadures i les armes. -->
|
|
||||||
<div class="proficiency-lists">
|
|
||||||
<div class="proficiency-list">
|
|
||||||
<h3>{{ $t('campaigns.character-sheet.tools') }}</h3>
|
|
||||||
<textarea v-if="editing" v-model="form.tools" rows="4" :placeholder="$t('campaigns.character-sheet.tools-placeholder')" />
|
|
||||||
<p v-else class="sheet-copy">{{ form.tools || $t('campaigns.character-sheet.empty-tools') }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="proficiency-list">
|
</section>
|
||||||
<h3>{{ $t('campaigns.character-sheet.languages') }}</h3>
|
|
||||||
<textarea v-if="editing" v-model="form.languages" rows="4" :placeholder="$t('campaigns.character-sheet.languages-placeholder')" />
|
<section class="sheet-panel skills-panel">
|
||||||
<p v-else class="sheet-copy">{{ form.languages || $t('campaigns.character-sheet.empty-languages') }}</p>
|
<h2>{{ $t('campaigns.character-sheet.skills') }}</h2>
|
||||||
|
<div class="skill-grid">
|
||||||
|
<button
|
||||||
|
v-for="skill in skillList"
|
||||||
|
:key="skill.key"
|
||||||
|
class="proficiency-row"
|
||||||
|
type="button"
|
||||||
|
role="switch"
|
||||||
|
:aria-checked="form.skills[skill.key]"
|
||||||
|
:disabled="!editing"
|
||||||
|
@click="toggleProficiency('skills', skill.key)"
|
||||||
|
>
|
||||||
|
<span class="proficiency-dot" :class="{ proficient: form.skills[skill.key] }" aria-hidden="true" />
|
||||||
|
<span class="proficiency-name">{{ $t(`campaigns.character-sheet.skill-names.${skill.key}`) }}</span>
|
||||||
|
<span class="proficiency-ability">{{ skill.ability.toUpperCase() }}</span>
|
||||||
|
<span class="proficiency-modifier">{{ skillModifier(skill) }}</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</section>
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<main v-show="activeTab === 'inventory'" class="sheet-tab-body">
|
<section class="sheet-panel proficiencies-panel">
|
||||||
<section class="sheet-panel inventory-panel">
|
<h2>{{ $t('campaigns.character-sheet.proficiencies') }}</h2>
|
||||||
<div class="panel-title-row">
|
<textarea v-if="editing" v-model="form.proficiencies" rows="7" :placeholder="$t('campaigns.character-sheet.proficiencies-placeholder')" />
|
||||||
<h2>{{ $t('campaigns.character-sheet.inventory') }}</h2>
|
<p v-else class="sheet-copy">{{ form.proficiencies || $t('campaigns.character-sheet.empty-proficiencies') }}</p>
|
||||||
<button v-if="editing" class="sheet-button secondary compact" type="button" @click="addInventoryItem">{{ $t('campaigns.character-sheet.add-item') }}</button>
|
|
||||||
</div>
|
|
||||||
<div class="weight-summary">
|
|
||||||
<span>{{ $t('campaigns.character-sheet.carried-weight') }}</span>
|
|
||||||
<strong>{{ carriedWeight.toFixed(1) }} / {{ carryingCapacity }} lb</strong>
|
|
||||||
</div>
|
|
||||||
<div class="weight-track"><div class="weight-fill" :style="{ width: `${carryPercent}%` }" /></div>
|
|
||||||
|
|
||||||
<!-- La moneda que el personatge porta a sobre, en les cinc monedes del joc. -->
|
<!-- Les eines i els idiomes tenen llista pròpia; el text de dalt guarda
|
||||||
<h3>{{ $t('campaigns.character-sheet.currency') }}</h3>
|
el que no en té, com les armadures i les armes. -->
|
||||||
<div class="currency-row">
|
<div class="proficiency-lists">
|
||||||
<label v-for="unit in currencyUnits" :key="unit" class="currency-field">
|
<div class="proficiency-list">
|
||||||
<span>{{ $t(`campaigns.character-sheet.currency-units.${unit}`) }}</span>
|
<h3>{{ $t('campaigns.character-sheet.tools') }}</h3>
|
||||||
<input v-if="editing" v-model.number="form.currency[unit]" type="number" min="0" :aria-label="$t(`campaigns.character-sheet.currency-units.${unit}`)">
|
<textarea v-if="editing" v-model="form.tools" rows="4" :placeholder="$t('campaigns.character-sheet.tools-placeholder')" />
|
||||||
<strong v-else>{{ form.currency[unit] }}</strong>
|
<p v-else class="sheet-copy">{{ form.tools || $t('campaigns.character-sheet.empty-tools') }}</p>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
<div class="proficiency-list">
|
||||||
<div class="inventory-table-wrap">
|
<h3>{{ $t('campaigns.character-sheet.languages') }}</h3>
|
||||||
<table class="inventory-table">
|
<textarea v-if="editing" v-model="form.languages" rows="4" :placeholder="$t('campaigns.character-sheet.languages-placeholder')" />
|
||||||
<thead><tr>
|
<p v-else class="sheet-copy">{{ form.languages || $t('campaigns.character-sheet.empty-languages') }}</p>
|
||||||
<th><span class="sr-only">{{ $t('campaigns.character-sheet.item-icon') }}</span></th>
|
</div>
|
||||||
<th class="item-name-cell">{{ $t('campaigns.character-sheet.item-name') }}</th>
|
</div>
|
||||||
<th>{{ $t('campaigns.character-sheet.quantity') }}</th>
|
</section>
|
||||||
<th>{{ $t('campaigns.character-sheet.weight-each') }}</th>
|
</main>
|
||||||
<th>{{ $t('campaigns.character-sheet.total-weight') }}</th>
|
|
||||||
<th v-if="editing"><span class="sr-only">{{ $t('campaigns.character-sheet.actions') }}</span></th>
|
|
||||||
</tr></thead>
|
|
||||||
<tbody>
|
|
||||||
<tr v-for="(item, index) in form.inventory" :key="index">
|
|
||||||
<td class="item-icon-cell">
|
|
||||||
<img v-if="item.icon" :src="resolveImage(item.icon)" :alt="$t('campaigns.character-sheet.item-icon')">
|
|
||||||
<span v-else class="item-icon-blank" aria-hidden="true" />
|
|
||||||
</td>
|
|
||||||
<td class="item-name-cell"><input v-if="editing" v-model="item.name" :aria-label="$t('campaigns.character-sheet.item-name')"><span v-else>{{ item.name }}</span></td>
|
|
||||||
<td><input v-if="editing" v-model.number="item.quantity" type="number" min="1" :aria-label="$t('campaigns.character-sheet.quantity')"><span v-else>{{ item.quantity }}</span></td>
|
|
||||||
<td><input v-if="editing" v-model.number="item.weight" type="number" min="0" step="0.1" :aria-label="$t('campaigns.character-sheet.weight-each')"><span v-else>{{ Number(item.weight).toFixed(1) }} lb</span></td>
|
|
||||||
<td>{{ ((Number(item.quantity) || 0) * (Number(item.weight) || 0)).toFixed(1) }} lb</td>
|
|
||||||
<td v-if="editing"><button class="remove-item" type="button" @click="removeInventoryItem(index)">×</button></td>
|
|
||||||
</tr>
|
|
||||||
<tr v-if="form.inventory.length === 0"><td :colspan="editing ? 6 : 5" class="empty-inventory">{{ $t('campaigns.character-sheet.empty-inventory') }}</td></tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<main v-show="activeTab === 'traits'" class="sheet-tab-body">
|
<main v-show="activeTab === 'inventory'" class="sheet-tab-body">
|
||||||
<section class="sheet-panel traits-panel">
|
<section class="sheet-panel inventory-panel">
|
||||||
<h2>{{ $t('campaigns.character-sheet.traits') }}</h2>
|
<div class="panel-title-row">
|
||||||
<textarea v-if="editing" v-model="form.traits" rows="12" :placeholder="$t('campaigns.character-sheet.traits-placeholder')" />
|
<h2>{{ $t('campaigns.character-sheet.inventory') }}</h2>
|
||||||
<p v-else class="sheet-copy">{{ form.traits || $t('campaigns.character-sheet.empty-traits') }}</p>
|
<button v-if="editing" class="sheet-button secondary compact" type="button" @click="addInventoryItem">{{ $t('campaigns.character-sheet.add-item') }}</button>
|
||||||
</section>
|
</div>
|
||||||
</main>
|
<div class="weight-summary">
|
||||||
|
<span>{{ $t('campaigns.character-sheet.carried-weight') }}</span>
|
||||||
|
<strong>{{ carriedWeight.toFixed(1) }} / {{ carryingCapacity }} lb</strong>
|
||||||
|
</div>
|
||||||
|
<div class="weight-track"><div class="weight-fill" :style="{ width: `${carryPercent}%` }" /></div>
|
||||||
|
|
||||||
<main v-show="activeTab === 'spells'" class="sheet-tab-body">
|
<!-- La moneda que el personatge porta a sobre, en les cinc monedes del joc. -->
|
||||||
<section class="sheet-panel spells-panel">
|
<h3>{{ $t('campaigns.character-sheet.currency') }}</h3>
|
||||||
<h2>{{ $t('campaigns.character-sheet.spells') }}</h2>
|
<div class="currency-row">
|
||||||
<textarea v-if="editing" v-model="form.spells" rows="12" :placeholder="$t('campaigns.character-sheet.spells-placeholder')" />
|
<label v-for="unit in currencyUnits" :key="unit" class="currency-field">
|
||||||
<p v-else class="sheet-copy">{{ form.spells || $t('campaigns.character-sheet.empty-spells') }}</p>
|
<span>{{ $t(`campaigns.character-sheet.currency-units.${unit}`) }}</span>
|
||||||
</section>
|
<input v-if="editing" v-model.number="form.currency[unit]" type="number" min="0" :aria-label="$t(`campaigns.character-sheet.currency-units.${unit}`)">
|
||||||
</main>
|
<strong v-else>{{ form.currency[unit] }}</strong>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="inventory-table-wrap">
|
||||||
|
<table class="inventory-table">
|
||||||
|
<thead><tr>
|
||||||
|
<th><span class="sr-only">{{ $t('campaigns.character-sheet.item-icon') }}</span></th>
|
||||||
|
<th class="item-name-cell">{{ $t('campaigns.character-sheet.item-name') }}</th>
|
||||||
|
<th>{{ $t('campaigns.character-sheet.quantity') }}</th>
|
||||||
|
<th>{{ $t('campaigns.character-sheet.weight-each') }}</th>
|
||||||
|
<th>{{ $t('campaigns.character-sheet.total-weight') }}</th>
|
||||||
|
<th v-if="editing"><span class="sr-only">{{ $t('campaigns.character-sheet.actions') }}</span></th>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(item, index) in form.inventory" :key="index">
|
||||||
|
<td class="item-icon-cell">
|
||||||
|
<img v-if="item.icon" :src="resolveImage(item.icon)" :alt="$t('campaigns.character-sheet.item-icon')">
|
||||||
|
<span v-else class="item-icon-blank" aria-hidden="true" />
|
||||||
|
</td>
|
||||||
|
<td class="item-name-cell"><input v-if="editing" v-model="item.name" :aria-label="$t('campaigns.character-sheet.item-name')"><span v-else>{{ item.name }}</span></td>
|
||||||
|
<td><input v-if="editing" v-model.number="item.quantity" type="number" min="1" :aria-label="$t('campaigns.character-sheet.quantity')"><span v-else>{{ item.quantity }}</span></td>
|
||||||
|
<td><input v-if="editing" v-model.number="item.weight" type="number" min="0" step="0.1" :aria-label="$t('campaigns.character-sheet.weight-each')"><span v-else>{{ Number(item.weight).toFixed(1) }} lb</span></td>
|
||||||
|
<td>{{ ((Number(item.quantity) || 0) * (Number(item.weight) || 0)).toFixed(1) }} lb</td>
|
||||||
|
<td v-if="editing"><button class="remove-item" type="button" @click="removeInventoryItem(index)">×</button></td>
|
||||||
|
</tr>
|
||||||
|
<tr v-if="form.inventory.length === 0"><td :colspan="editing ? 6 : 5" class="empty-inventory">{{ $t('campaigns.character-sheet.empty-inventory') }}</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</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>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -550,8 +555,10 @@ async function saveSheet() {
|
|||||||
.sheet-button.primary { background: var(--color-link); color: var(--color-background); border-color: var(--color-link); }
|
.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:disabled { opacity: .55; cursor: wait; }
|
||||||
.sheet-button.compact { padding: 5px 9px; font-size: 12px; }
|
.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; gap: 11px; align-items: start; }
|
/* El marc de la fitxa: la columna del personatge, sempre a la vista, i al seu costat el contingent
|
||||||
.sheet-tab-body { display: block; }
|
de la pestanya oberta. */
|
||||||
|
.sheet-layout { display: grid; grid-template-columns: minmax(200px, 34%) minmax(0, 1fr); gap: 11px; align-items: start; }
|
||||||
|
.sheet-tab-body { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 11px; min-width: 0; }
|
||||||
/* Pestilletes del marc: arrencen del cantó dret de la finestra, per fora del cos, i queden
|
/* Pestilletes del marc: arrencen del cantó dret de la finestra, per fora del cos, i queden
|
||||||
fora del contingent que desfila. Per sota de 760px no hi ha lloc fora (vegeu a sota). */
|
fora del contingent que desfila. Per sota de 760px no hi ha lloc fora (vegeu a sota). */
|
||||||
.sheet-tabs { position: absolute; left: 100%; top: 34px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding-top: 6px; }
|
.sheet-tabs { position: absolute; left: 100%; top: 34px; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding-top: 6px; }
|
||||||
@@ -585,11 +592,9 @@ async function saveSheet() {
|
|||||||
.portrait-controls button:disabled { opacity: .55; cursor: wait; }
|
.portrait-controls button:disabled { opacity: .55; cursor: wait; }
|
||||||
.photo-input { display: none; }
|
.photo-input { display: none; }
|
||||||
/* La columna de la fitxa: la imatge dalt i, just a sota, el que es consulta d'anada i
|
/* La columna de la fitxa: la imatge dalt i, just a sota, el que es consulta d'anada i
|
||||||
tornada — classe d'armadura, velocitat, bonificadors i les barres de cops. */
|
tornada — classe d'armadura, velocitat, bonificadors i les barres de cops. No penja de
|
||||||
.character-column { grid-column: 1; grid-row: 1 / -1; display: flex; flex-direction: column; gap: 11px; min-width: 0; }
|
cap pestanya: es queda al seu lloc mentre se'n canvia. */
|
||||||
.abilities-panel { grid-column: 2 / -1; grid-row: 1; }
|
.character-column { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 11px; min-width: 0; }
|
||||||
.skills-panel { grid-column: 2 / -1; grid-row: 2; }
|
|
||||||
.proficiencies-panel { grid-column: 2 / -1; grid-row: 3; }
|
|
||||||
.ability-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
|
.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-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; }
|
.ability-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; opacity: .75; }
|
||||||
@@ -663,8 +668,8 @@ 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; }
|
.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; }
|
.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) {
|
@media (max-width: 760px) {
|
||||||
.sheet-grid { grid-template-columns: 1fr; grid-template-rows: none; }
|
.sheet-layout { grid-template-columns: 1fr; }
|
||||||
.character-column, .abilities-panel, .skills-panel, .proficiencies-panel { grid-column: 1 / -1; grid-row: auto; }
|
.character-column, .sheet-tab-body { grid-column: 1 / -1; grid-row: auto; }
|
||||||
/* El cantó dret no dona prou per penjar-hi les pestanyes: llavors es queden al marc, per
|
/* El cantó dret no dona prou per penjar-hi les pestanyes: llavors es queden al marc, per
|
||||||
dins, en una filera sota la barra de la finestra. */
|
dins, en una filera sota la barra de la finestra. */
|
||||||
.sheet-tabs { position: static; align-self: stretch; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 6px 8px 0; }
|
.sheet-tabs { position: static; align-self: stretch; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 6px 8px 0; }
|
||||||
|
|||||||
111
tests/character-sheet-persistent-column.test.js
Normal file
111
tests/character-sheet-persistent-column.test.js
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
// Tests for Syndria98/dragonroll#91: the column that opens the character sheet — the portrait with
|
||||||
|
// the armor class, the speed, the bonuses and both pools under it — stays on screen whoever's tab is
|
||||||
|
// open, instead of being the ability scores tab's own content and disappearing when the sheet moves
|
||||||
|
// to the inventory, the traits or the spells.
|
||||||
|
//
|
||||||
|
// The window is a `.vue` file and the repository root installs no dependencies for the frontend, so
|
||||||
|
// the template and the styles are read out of the source the way tests/character-sheet-tabs.test.js
|
||||||
|
// and tests/character-sheet-portrait-column.test.js read them.
|
||||||
|
//
|
||||||
|
// 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 template = /<template>([\s\S]*)<\/template>/.exec(sheetSource)?.[1] ?? "";
|
||||||
|
const TAB_KEYS = ["abilities", "inventory", "traits", "spells"];
|
||||||
|
|
||||||
|
const COLUMN = '<div class="character-column">';
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The column, taken whole: it stands ahead of the tab bodies, which are its siblings.
|
||||||
|
function characterColumn() {
|
||||||
|
const start = template.indexOf(COLUMN);
|
||||||
|
const end = template.indexOf('<main v-show="activeTab');
|
||||||
|
assert.ok(start !== -1 && end > start, "expected the character column ahead of the tab bodies");
|
||||||
|
return template.slice(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The classes wrapping a tag, worked out by walking the blocks of the template in order the way a
|
||||||
|
// browser nests them, so a tab cannot hide the column by wrapping it.
|
||||||
|
function ancestorsOf(needle) {
|
||||||
|
const at = template.indexOf(needle);
|
||||||
|
assert.ok(at !== -1, `expected ${needle} in the template`);
|
||||||
|
const stack = [];
|
||||||
|
for (const match of template.matchAll(/<(\/?)(div|main|section|header|nav)\b([^>]*)>/g)) {
|
||||||
|
if (match.index > at) break;
|
||||||
|
const [, closed, , attrs] = match;
|
||||||
|
if (closed) stack.pop();
|
||||||
|
else if (!attrs.trimEnd().endsWith("/")) {
|
||||||
|
const classes = /\bclass="([^"]*)"/.exec(attrs);
|
||||||
|
stack.push(classes ? classes[1].trim().split(/\s+/) : []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stack.slice(0, -1).map((classes) => classes.join(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
test("the character column belongs to no tab", () => {
|
||||||
|
const column = characterColumn();
|
||||||
|
assert.ok(column.includes('class="sheet-portrait"'), "the portrait is part of the column");
|
||||||
|
assert.ok(column.includes('class="sheet-panel vitals-panel"'), "and so is the panel of readouts and bars");
|
||||||
|
// Nothing toggles the column: no tab decides whether it shows.
|
||||||
|
assert.doesNotMatch(column, /v-show=/, "the column never hides behind a tab");
|
||||||
|
|
||||||
|
for (const key of TAB_KEYS) {
|
||||||
|
const body = tabBody(key);
|
||||||
|
assert.doesNotMatch(body, /class="character-column"/, `the ${key} tab does not own the column`);
|
||||||
|
assert.doesNotMatch(body, /sheet-portrait|vitals-panel/, `the ${key} tab does not hold the column's contents`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the column and the tab that is open stand beside each other", () => {
|
||||||
|
const columnWrappers = ancestorsOf(COLUMN);
|
||||||
|
assert.equal(columnWrappers.at(-1), "sheet-layout", "the column stands in the sheet's own layout");
|
||||||
|
for (const key of TAB_KEYS) {
|
||||||
|
assert.deepEqual(
|
||||||
|
ancestorsOf(`<main v-show="activeTab === '${key}'"`),
|
||||||
|
columnWrappers,
|
||||||
|
`the ${key} tab is a sibling of the column, so it is never wrapped around it`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const layout = /\.sheet-layout\s*\{[^}]*\}/.exec(sheetSource)?.[0] ?? "";
|
||||||
|
assert.match(layout, /display:\s*grid/, "the layout puts the column and the open tab side by side");
|
||||||
|
assert.match(
|
||||||
|
layout,
|
||||||
|
/grid-template-columns:\s*minmax\(200px,\s*34%\)\s+minmax\(0,\s*1fr\)/,
|
||||||
|
"the character keeps its own column and the tab has all the room left"
|
||||||
|
);
|
||||||
|
const columnRule = /\.character-column\s*\{[^}]*\}/.exec(sheetSource)?.[0] ?? "";
|
||||||
|
assert.match(columnRule, /grid-column:\s*1/, "the character stands in the first column");
|
||||||
|
const bodyRule = /\.sheet-tab-body\s*\{[^}]*\}/.exec(sheetSource)?.[0] ?? "";
|
||||||
|
assert.match(bodyRule, /grid-column:\s*2/, "the open tab takes the space beside it");
|
||||||
|
assert.match(bodyRule, /grid-row:\s*1/, "and on the same row, so switching a tab leaves the column where it was");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a narrow window stacks the column over the tab instead of hiding it", () => {
|
||||||
|
const narrow = /@media \(max-width: 760px\)\s*\{([\s\S]*?)\n\}/.exec(sheetSource)?.[1] ?? "";
|
||||||
|
assert.match(narrow, /\.sheet-layout\s*\{[^}]*grid-template-columns:\s*1fr/, "the two columns become one");
|
||||||
|
assert.match(
|
||||||
|
narrow,
|
||||||
|
/\.character-column,\s*\.sheet-tab-body\s*\{[^}]*grid-column:\s*1 \/ -1;[^}]*grid-row:\s*auto/,
|
||||||
|
"the column goes over the tab, it does not go away with it"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("what stays on screen is what the sheet is read for", () => {
|
||||||
|
const column = characterColumn();
|
||||||
|
for (const key of ["armor-class", "speed", "proficiency-bonus", "initiative", "hit-points", "hit-dice"]) {
|
||||||
|
assert.ok(column.includes(`campaigns.character-sheet.${key}`), `the ${key} stays visible from any tab`);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -43,7 +43,7 @@ const normalizeActor = fromSource(script, /function normalizeActor\(actor\) \{[\
|
|||||||
const barPercent = fromSource(script, /function barPercent\(current, max\) \{[\s\S]*?\n\}/);
|
const barPercent = fromSource(script, /function barPercent\(current, max\) \{[\s\S]*?\n\}/);
|
||||||
const barPool = fromSource(actorRouteSource, /function barPool\(existing, value\) \{[\s\S]*?\n\}/);
|
const barPool = fromSource(actorRouteSource, /function barPool\(existing, value\) \{[\s\S]*?\n\}/);
|
||||||
|
|
||||||
// The column that opens the abilities tab: the portrait with everything under it.
|
// The column that stands beside every tab: the portrait with everything under it.
|
||||||
function portraitColumn() {
|
function portraitColumn() {
|
||||||
const start = template.indexOf('<div class="character-column">');
|
const start = template.indexOf('<div class="character-column">');
|
||||||
const end = template.indexOf('<section class="sheet-panel abilities-panel">');
|
const end = template.indexOf('<section class="sheet-panel abilities-panel">');
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ function tabBody(key) {
|
|||||||
|
|
||||||
test("every tab shows only its own content and hides the others", () => {
|
test("every tab shows only its own content and hides the others", () => {
|
||||||
const abilities = tabBody("abilities");
|
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 abilities-panel"/);
|
||||||
assert.match(abilities, /class="sheet-panel proficiencies-panel"/, "the proficiencies ride with the ability scores");
|
assert.match(abilities, /class="sheet-panel proficiencies-panel"/, "the proficiencies ride with the ability scores");
|
||||||
for (const other of ["inventory-panel", "traits-panel", "spells-panel"]) {
|
for (const other of ["inventory-panel", "traits-panel", "spells-panel"]) {
|
||||||
@@ -63,7 +62,12 @@ test("every tab shows only its own content and hides the others", () => {
|
|||||||
for (const [key, panel] of [["inventory", "inventory-panel"], ["traits", "traits-panel"], ["spells", "spells-panel"]]) {
|
for (const [key, panel] of [["inventory", "inventory-panel"], ["traits", "traits-panel"], ["spells", "spells-panel"]]) {
|
||||||
const body = tabBody(key);
|
const body = tabBody(key);
|
||||||
assert.ok(body.includes(panel), `the ${key} tab shows the ${panel}`);
|
assert.ok(body.includes(panel), `the ${key} tab shows the ${panel}`);
|
||||||
assert.doesNotMatch(body, /class="sheet-portrait"/);
|
}
|
||||||
|
|
||||||
|
// #91 took the character column out of the tabs: it stands beside every one of them, so no tab
|
||||||
|
// body holds the portrait (see tests/character-sheet-persistent-column.test.js).
|
||||||
|
for (const key of ["abilities", "inventory", "traits", "spells"]) {
|
||||||
|
assert.doesNotMatch(tabBody(key), /class="sheet-portrait"/, `the portrait is not the ${key} tab's to hide`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the panels are toggled, not unmounted, so editing on one tab and flipping away keeps the draft
|
// the panels are toggled, not unmounted, so editing on one tab and flipping away keeps the draft
|
||||||
|
|||||||
Reference in New Issue
Block a user