From ce3e2a804cbb6467e4fa1f6267ccb32cd795e2c4 Mon Sep 17 00:00:00 2001 From: Carlos Fernandez Date: Thu, 6 Nov 2025 10:02:22 -0500 Subject: [PATCH] Improve sidebar appearance when labels are long (#1238) --- module/systemRegistration/handlebars.mjs | 1 + styles/less/global/inventory-item.less | 157 +++++++++++------- templates/sheets/actors/adversary/sidebar.hbs | 6 +- templates/sheets/actors/character/sidebar.hbs | 18 +- templates/sheets/actors/companion/details.hbs | 8 +- .../global/partials/inventory-item-V2.hbs | 14 -- .../partials/inventory-item-compact.hbs | 85 ++++++++++ 7 files changed, 185 insertions(+), 104 deletions(-) create mode 100644 templates/sheets/global/partials/inventory-item-compact.hbs diff --git a/module/systemRegistration/handlebars.mjs b/module/systemRegistration/handlebars.mjs index dd19e429..7bc9a8ff 100644 --- a/module/systemRegistration/handlebars.mjs +++ b/module/systemRegistration/handlebars.mjs @@ -1,5 +1,6 @@ export const preloadHandlebarsTemplates = async function () { foundry.applications.handlebars.loadTemplates({ + 'daggerheart.inventory-item-compact': 'systems/daggerheart/templates/sheets/global/partials/inventory-item-compact.hbs', 'daggerheart.inventory-items': 'systems/daggerheart/templates/sheets/global/partials/inventory-fieldset-items-V2.hbs', 'daggerheart.inventory-item': 'systems/daggerheart/templates/sheets/global/partials/inventory-item-V2.hbs' diff --git a/styles/less/global/inventory-item.less b/styles/less/global/inventory-item.less index 1f5840af..50cdf116 100644 --- a/styles/less/global/inventory-item.less +++ b/styles/less/global/inventory-item.less @@ -14,7 +14,7 @@ } .appTheme({}, { - .inventory-item-header .img-portait .roll-img { + .inventory-item .img-portait .roll-img { filter: invert(1); } }); @@ -25,14 +25,12 @@ list-style-type: none; &:not(.single-img) { - .inventory-item-header:hover { - .img-portait:has(.roll-img) { - .roll-img { - opacity: 1; - } - .item-img { - opacity: 0; - } + .img-portait:has(.roll-img):hover { + .roll-img { + opacity: 1; + } + .item-img { + opacity: 0; } } @@ -68,18 +66,15 @@ } } - .inventory-item-header { - display: flex; - align-items: center; - gap: 10px; - cursor: pointer; - border-radius: 3px; - + .inventory-item-header, + &.inventory-item-compact { .img-portait { flex: 0 0 40px; height: 40px; - cursor: pointer; position: relative; + &:has(.roll-img) { + cursor: pointer; + } .item-img, .roll-img { @@ -102,53 +97,6 @@ } } - .item-label { - flex: 1; - align-self: center; - - .item-name { - font-size: var(--font-size-14); - - .expanded-icon { - display: none; - } - } - - .item-tags, - .item-labels { - display: flex; - gap: 10px; - - .tag, - .label { - display: flex; - flex-direction: row; - align-items: center; - font-size: var(--font-size-12); - flex-wrap: wrap; - justify-content: start; - } - - .tag { - padding: 3px 5px; - background: light-dark(@dark-15, @beige-15); - border: 1px solid light-dark(@dark, @beige); - border-radius: 3px; - } - - .label { - gap: 4px; - color: light-dark(@dark-80, @beige-80); - } - } - } - - .item-resource { - flex: 0 0 60px; - display: flex; - align-items: center; - gap: 4px; - } .controls { flex: 0 0 auto; display: flex; @@ -167,6 +115,52 @@ } } + .inventory-item-header { + align-items: center; + border-radius: 3px; + cursor: pointer; + display: flex; + gap: 10px; + + .item-label { + flex: 1; + align-self: center; + + .item-name { + font-size: var(--font-size-14); + + .expanded-icon { + display: none; + } + } + + .item-tags { + display: flex; + gap: 10px; + + .tag { + align-items: center; + background: light-dark(@dark-15, @beige-15); + border-radius: 3px; + border: 1px solid light-dark(@dark, @beige); + display: flex; + flex-direction: row; + flex-wrap: wrap; + font-size: var(--font-size-12); + justify-content: start; + padding: 3px 5px; + } + } + } + + .item-resource { + flex: 0 0 60px; + display: flex; + align-items: center; + gap: 4px; + } + } + .inventory-item-content { > *:not(:last-child) { margin-bottom: 5px; @@ -251,6 +245,41 @@ } } } + + &.inventory-item-compact { + display: grid; + grid-template: + "img name controls" auto + "img labels labels" 1fr + / 40px 1fr min-content; + column-gap: 8px; + + > .img-portait { + grid-area: img; + } + > .item-name { + align-self: end; + line-height: 1; + padding-bottom: 1px; + } + > .controls { + grid-area: controls; + align-self: start; + padding-top: 0.3125rem; + gap: 4px; + margin-bottom: -1px; + } + > .item-labels { + align-self: start; + color: light-dark(@dark-80, @beige-80); + display: flex; + flex-direction: row; + flex-wrap: wrap; + font-size: var(--font-size-12); + gap: 4px; + grid-area: labels; + } + } } .card-item { diff --git a/templates/sheets/actors/adversary/sidebar.hbs b/templates/sheets/actors/adversary/sidebar.hbs index 16a8ea91..fbfa62a3 100644 --- a/templates/sheets/actors/adversary/sidebar.hbs +++ b/templates/sheets/actors/adversary/sidebar.hbs @@ -78,13 +78,9 @@ diff --git a/templates/sheets/actors/character/sidebar.hbs b/templates/sheets/actors/character/sidebar.hbs index 6131104d..77f323de 100644 --- a/templates/sheets/actors/character/sidebar.hbs +++ b/templates/sheets/actors/character/sidebar.hbs @@ -116,24 +116,16 @@