Comments (6)
Proof of concept via world script macro does indeed work as intended:
Hooks.on('tidy5e-sheet.renderActorSheet', (sheet, element, data) => {
element
.querySelector(`[data-tidy-sheet-part="resources-container"]`)
?.insertAdjacentHTML(
'afterbegin',
`<div style="display: contents;" data-tidy-render-scheme="handlebars">
<h2 type="button" style="width: 100%;">Resources for ${data.actor.name}</h2>
</div>`
);
});
from foundry-vtt-tidy-5e-sheets.
Beginning API / runtime work...
from foundry-vtt-tidy-5e-sheets.
An initial look at registering "Inject Anywhere" content:
const api = game.modules.get('tidy5e-sheet').api ?? game.modules.get('tidy5e-sheet-kgar').api;
api.registerCharacterContent(
api.getSheetPartSelector(api.constants.SHEET_PARTS.RESOURCE),
'afterbegin',
new api.models.HtmlContent({
html: `<span class="test-emoji" style="cursor: pointer; position: absolute; bottom: 0; right: 1rem;">ð</span>`,
onRender({ app, element, data }) {
element
.querySelectorAll('.test-emoji')
.forEach((el) =>
el.addEventListener(
'click',
(ev) => (ev.currentTarget.innerHTML = 'ð')
)
);
},
})
);
from foundry-vtt-tidy-5e-sheets.
I'm still working on the actual function parameters. I am thinking of offering these options at first:
- a highly structured option for those who want to render HTML / Handlebars and do not have complex requirements; this approach basically leverages the API of
insertAdjacentHTML()
- an option where I prepare the markup (rendering Handlebars templates with data, putting the dynamic wrapper around the resulting HTML) but give it over to the user to distribute however they please via a callback
from foundry-vtt-tidy-5e-sheets.
Updated preview of the API - adding an icon next to the actor sheet name field:
Hooks.once("tidy5e-sheet.ready", (api) => {
api.registerActorContent(
new api.models.HtmlContent({
html: `<a title="Example Button" class="my-custom-button"><i class="fas fa-user"></i></a>`,
injectParams: {
selector: api.getSheetPartSelector(
api.constants.SHEET_PARTS.NAME_CONTAINER
),
position: "beforebegin",
},
onContentReady: (params) => {
console.log("content ready to render", params);
console.log("my content", params.content);
},
onRender: (params) => {
params.element
.querySelector(".my-custom-button")
.addEventListener("click", () => alert("ðĪš"));
},
})
);
});
from foundry-vtt-tidy-5e-sheets.
Closing as completed.
from foundry-vtt-tidy-5e-sheets.
Related Issues (20)
- bug: Contained Items do not show on the Favorites section
- compat: Monk's Sound Enhancements
- style: (dnd5e 3.0.x) Using More Stock Icons HOT 2
- Lazy Money Compatability HOT 3
- bug: Opening Tidy Sheets too early triggers an error in some setups HOT 1
- bug: weight in Inventory undefinied HOT 14
- bug: Rarity Colors of Inventory HOT 2
- style/theme: Threat Color Theming and Capacity/Encumbrance Threat coloring
- feat: Account for Unidentified Items in Item Filters HOT 1
- feat: GM Option - Item Identification Permission HOT 1
- feat: Resurface critical filters to utility toolbar HOT 1
- bug: Container Panel Missing in Firefox HOT 1
- compatibility: Illandril's Token Tooltips
- bug: Pressing enter on the character sheet opens a container HOT 1
- style: Capitalization Inconsistency HOT 1
- feat: GM / Owner Tools
- bug: Ammo Tracker Not Switching Ammo Properly Anymore HOT 1
- Dark Theme: Item text headings unreadable HOT 2
- bug: Some Unidentified items have Undefined Unidentified Names HOT 1
- style: Improve Ammo Switcher Placement
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
ð Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ððð
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google âĪïļ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foundry-vtt-tidy-5e-sheets.