Skip to content

Commit

Permalink
impacts
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed May 25, 2024
1 parent be075ef commit 11a0186
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 7 deletions.
31 changes: 25 additions & 6 deletions src/characters/character-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Error rendering character: character file is invalid${character
<article class="iron-vault-character">
<h3 class="name">${md(this.plugin, lens.name.get(raw), file.path)}</h3>
${this.renderStats(charCtx, file)} ${this.renderMeters(charCtx, file)}
${this.renderImpacts(charCtx, file)}
</article>
`;
render(tpl, this.contentEl);
Expand Down Expand Up @@ -147,16 +148,34 @@ Error rendering character: character file is invalid${character
renderImpacts(charCtx: CharacterContext, _file: TFile) {
const lens = charCtx.lens;
const raw = charCtx.character;
const categories: Record<string, Record<string, boolean>> = {};
for (const [impact, value] of Object.entries(lens.impacts.get(raw))) {
const category = lens.ruleset.impacts[impact].category.label;
if (!categories[category]) {
categories[category] = {};
}
categories[category][impact] = value;
}
return html`
<ul class="impacts">
<ul class="impact-categories">
${map(
Object.entries(lens.impacts.get(raw)),
Object.entries(categories),
([impact, value]) => html`
<li>
<dl>
<dt data-value=${impact}>${impact}</dt>
<dd data-value=${value}>${value}</dd>
</dl>
<header>${impact}</header>
<ul class="impacts">
${map(
Object.entries(value),
([impact, value]) => html`
<li>
<dl>
<dt data-value=${impact}>${impact}</dt>
<dd data-value=${value}>${value}</dd>
</dl>
</li>
`,
)}
</ul>
</li>
`,
)}
Expand Down
62 changes: 61 additions & 1 deletion src/characters/css/impacts.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,62 @@
.iron-vault-character .impacts {
.iron-vault-character .impact-categories {
flex-flow: row wrap;
&,
& ul {
padding-inline-start: 0;
display: flex;
align-items: start;
justify-content: start;
gap: 0.4em;
list-style: none;
}
& > li {
border: 2px solid var(--background-modifier-border);
border-radius: 8px;
background-color: var(--background-primary-alt);
margin: 0.5em;
& > header {
font-weight: var(--font-bold);
text-transform: uppercase;
font-size: 0.8em;
width: 100%;
text-align: center;
padding: 0.4em;
border-bottom: 2px solid var(--background-modifier-border);
}
}
& ul {
padding: 0 0.5em;
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
flex-flow: column nowrap;
padding-bottom: 1em;
& > li {
height: 1.4em;
padding: 0;
}
}
& dt {
font-weight: var(--font-semibold);
text-transform: uppercase;
font-size: 0.8em;
cursor: pointer;
&:before {
margin-right: 0.5em;
}
&:has(+ dd[data-value="true"]):before {
content: "⬢";
}
&:has(+ dd[data-value="false"]):before {
content: "⬡";
}
}
& dd {
display: none;
}
& li:before {
/* Some themes (Like ITS Theme) try to be more clever than they deserve
to be with list bullets. Make that b.s. go away. */
display: none;
}
}
2 changes: 2 additions & 0 deletions src/characters/css/meters.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
gap: 1em;
justify-content: center;
align-items: center;
border-bottom: 2px solid var(--background-modifier-border);
padding-bottom: 1em;
& li {
&:before {
/* Some themes (Like ITS Theme) try to be more clever than they deserve
Expand Down

0 comments on commit 11a0186

Please sign in to comment.