Skip to content

Commit 21351ce

Browse files
committed
example: styling data-values via CSS
1 parent 6b36513 commit 21351ce

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

exampleVault/.obsidian/snippets/meta-bind-customization.css

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,35 @@
66
/* A snippet that turns a button green */
77
.mb-button.green-button > button {
88
background: var(--color-green);
9-
}
9+
}
10+
11+
/* A snippets that adds icons after an inlineSelector */
12+
.mb-input .dnd5e-skill-prof {
13+
&::after {
14+
content: '';
15+
display: inline-block;
16+
margin-left: 0.2em;
17+
width: 1.5em;
18+
aspect-ratio: 1;
19+
vertical-align: middle;
20+
mask-size: contain;
21+
mask-position: center;
22+
mask-repeat: no-repeat;
23+
}
24+
&[data-internal-value~="0"]::after {
25+
mask-image: url('data:image/svg+xml,<svg version="1.1" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="2.5" fill="none" stroke="black" stroke-width="0.75"/></svg>');
26+
background-color: var(--text-faint);
27+
}
28+
&[data-internal-value~="0.5"]::after {
29+
mask-image: url('data:image/svg+xml,<svg version="1.1" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="2.5" fill="none" stroke="black" stroke-width=".75"/><path transform="rotate(45,5,5)" d="m5 7.5s-2.5-1.1-2.5-2.5 2.2-2.5 2.2-2.5"/></svg>');
30+
background-color: var(--text-normal);
31+
}
32+
&[data-internal-value~="1"]::after {
33+
mask-image: url('data:image/svg+xml,<svg version="1.1" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="2.5" stroke="black" stroke-width=".75"/></svg>');
34+
background-color: var(--color-accent);
35+
}
36+
&[data-internal-value~="2"]::after {
37+
mask-image: url('data:image/svg+xml,<svg version="1.1" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="5" r="2.5"/><circle cx="5" cy="5" r="4" fill="none" stroke="black" stroke-width=".75"/></svg>');
38+
background-color: var(--color-accent);
39+
}
40+
}

exampleVault/Advanced Examples/DnD 5e Ability Scores and Modifiers.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ CON: 11
55
INT: 12
66
WIS: 14
77
CHR: 11
8+
PROF_mod: 5
9+
proficiency:
10+
acrobatics: 2
11+
arcana: 1
12+
deception: 0.5
813
---
914

1015
This example calculates a DnD character's ability modifiers from the ability scores and displays it all in a list.
@@ -39,3 +44,17 @@ VIEW[ floor(({CHR} - 10) / 2) ][math(hidden):memory^CHR_mod]
3944
- INT: `VIEW[**{INT}**][text(renderMarkdown)]` (`VIEW[ concat(isPositive({memory^INT_mod}) ? '+' : '', string({memory^INT_mod})) ][math]`)
4045
- WIS: `VIEW[**{WIS}**][text(renderMarkdown)]` (`VIEW[ concat(isPositive({memory^WIS_mod}) ? '+' : '', string({memory^WIS_mod})) ][math]`)
4146
- CHR: `VIEW[**{CHR}**][text(renderMarkdown)]` (`VIEW[ concat(isPositive({memory^CHR_mod}) ? '+' : '', string({memory^CHR_mod})) ][math]`)
47+
48+
## Skill modifiers
49+
50+
If we want to calculate the skill modifiers for a character, while also taking into account it's proficiency, we can leverage the `inlineSelect` Input to map the proficiency types to numerical values while still having a nice, editable interface.
51+
We can additionally style the input depending on the currently selected value, to get helpful visual indicators.
52+
53+
#### Here you can see an example of how it could work
54+
55+
First we need to set the proficiency modifier: `INPUT[number:PROF_mod]`
56+
57+
`INPUT[inlineSelect(option(0,not proficienct), option(0.5,half proficienct), option(1,proficient), option(2,experties), defaultValue(0), class(dnd5e-skill-prof)):proficiency.acrobatics]` Acrobatics (DEX) `VIEW[floor({proficiency.acrobatics}*{PROF_mod})+{memory^DEX_mod}]`
58+
`INPUT[inlineSelect(option(0,not proficienct), option(0.5,half proficienct), option(1,proficient), option(2,experties), defaultValue(0), class(dnd5e-skill-prof)):proficiency.arcana]` Arcana (INT) `VIEW[floor({proficiency.arcana}*{PROF_mod})+{memory^INT_mod}]`
59+
`INPUT[inlineSelect(option(0,not proficienct), option(0.5,half proficienct), option(1,proficient), option(2,experties), defaultValue(0), class(dnd5e-skill-prof)):proficiency.deception]` Deception (CHR) `VIEW[floor({proficiency.deception}*{PROF_mod})+{memory^CHR_mod}]`
60+
`INPUT[inlineSelect(option(0,not proficienct), option(0.5,half proficienct), option(1,proficient), option(2,experties), defaultValue(0), class(dnd5e-skill-prof)):proficiency.perception]` Perception (WIS) `VIEW[floor({proficiency.perception}*{PROF_mod})+{memory^WIS_mod}]`

0 commit comments

Comments
 (0)