Add the ability to load icons and set up some icons
This commit is contained in:
parent
7c8315260f
commit
227029ffcd
4 changed files with 60 additions and 0 deletions
3
assets/caret-right.svg
Normal file
3
assets/caret-right.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<svg width="100%" height="100%" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="m82.137 50.016c-0.003907 2.6133-1.1172 5.1055-3.0664 6.8477l-44.16 40.445c-1.8984 1.75-4.3867 2.7227-6.9688 2.7266-1.4727 0-2.9297-0.30859-4.2773-0.90234-3.5078-1.4531-5.7969-4.875-5.8008-8.668v-80.93c0.019531-3.7812 2.3047-7.1875 5.8008-8.6367 3.7734-1.6836 8.1836-0.98047 11.246 1.793l44.172 40.457c1.9492 1.75 3.0625 4.25 3.0547 6.8672z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 464 B |
6
assets/garbage-bin.svg
Normal file
6
assets/garbage-bin.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<svg width="100%" height="100%" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" fill="currentColor">
|
||||||
|
<g>
|
||||||
|
<path d="m82.199 25.301h-64.398c-1.3008 0-2.3008 1.1016-2.1992 2.3984l7.5 62.398c0.5 4.1992 4.1016 7.3984 8.3984 7.3984h37c4.3008 0 7.8984-3.1992 8.3984-7.3984l7.5-62.398c0.10156-1.3008-0.89844-2.3984-2.1992-2.3984zm-45.301 57.699h-0.19922c-1.1992 0-2.1992-0.89844-2.3008-2.1016l-4.1016-38.699c-0.10156-1.3008 0.80078-2.3984 2.1016-2.5 1.3008-0.10156 2.3984 0.80078 2.5 2.1016l4.1016 38.699c0.10156 1.3008-0.80078 2.3984-2.1016 2.5zm15.402-2.3008c0 1.3008-1 2.3008-2.3008 2.3008s-2.3008-1-2.3008-2.3008v-38.699c0-1.3008 1-2.3008 2.3008-2.3008s2.3008 1 2.3008 2.3008zm13.301 0.30078c-0.10156 1.1992-1.1016 2.1016-2.3008 2.1016h-0.19922c-1.3008-0.10156-2.1992-1.3008-2.1016-2.5l4.1016-38.699c0.10156-1.3008 1.3008-2.1992 2.5-2.1016 1.3008 0.10156 2.1992 1.3008 2.1016 2.5z"/>
|
||||||
|
<path d="m86.602 10.801h-19.301l-4.6016-6.3984c-0.80078-1.1992-2.1992-1.8984-3.6992-1.8984l-18-0.003906c-1.5 0-2.8008 0.69922-3.6992 1.8984l-4.6016 6.3984-19.301 0.003906c-2.3984 0-4.3008 1.8984-4.3008 4.3008 0 2.3984 1.8984 4.3008 4.3008 4.3008h73.199c2.3984 0 4.3008-1.8984 4.3008-4.3008 0-2.4023-1.8984-4.3008-4.2969-4.3008z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
5
assets/sources.txt
Normal file
5
assets/sources.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
Amer Alamer
|
||||||
|
caret-right.svg (https://thenounproject.com/icon/arrow-caret-right-1143917/)
|
||||||
|
|
||||||
|
Alice Design:
|
||||||
|
garbage-bin.svg (https://thenounproject.com/icon/garbage-2025492/)
|
||||||
|
|
@ -20,7 +20,14 @@ export const partials = [
|
||||||
`actors/char-sheet-mvp/panels/weapons.pc.hbs`,
|
`actors/char-sheet-mvp/panels/weapons.pc.hbs`,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const icons = [
|
||||||
|
`caret-right.svg`,
|
||||||
|
`garbage-bin.svg`,
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
export async function registerHandlebarsHelpers() {
|
export async function registerHandlebarsHelpers() {
|
||||||
|
console.log(Handlebars)
|
||||||
Handlebars.registerHelper(helpers);
|
Handlebars.registerHelper(helpers);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,3 +58,42 @@ export async function preloadHandlebarsTemplates() {
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
return loadTemplates(paths);
|
return loadTemplates(paths);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all of the icons that are needed in the handlebars templating to make
|
||||||
|
* the sheet look nicer.
|
||||||
|
*
|
||||||
|
* @returns An object containing icon names to the corresponding HTML data for
|
||||||
|
* displaying the icon
|
||||||
|
*/
|
||||||
|
export async function preloadIcons() {
|
||||||
|
console.groupCollapsed(`.dungeon | Loading icons for handlebars`);
|
||||||
|
const pathPrefix = `systems/dotdungeon/assets/`
|
||||||
|
const parsedIcons = {};
|
||||||
|
|
||||||
|
for (const icon of icons) {
|
||||||
|
const iconName = icon.slice(0, -4);
|
||||||
|
if (icon.endsWith(`.svg`)) {
|
||||||
|
try {
|
||||||
|
const response = await fetchWithTimeout(`${pathPrefix}${icon}`);
|
||||||
|
if (response.status !== 200) { continue };
|
||||||
|
const svgData = await response.text();
|
||||||
|
parsedIcons[iconName] = svgData;
|
||||||
|
console.debug(`Loaded icon: ${icon}`);
|
||||||
|
} catch {
|
||||||
|
console.error(`Failed to fetch/parse icon: ${icon}`);
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else if (icon.endsWith(`.png`)) {
|
||||||
|
parsedIcons[iconName] = `<img alt="" src="${pathPrefix}${icon}">`;
|
||||||
|
console.debug(`Loaded icon: ${icon}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.warn(`Icon "${icon}" failed to be handled by a loader`)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
console.groupEnd();
|
||||||
|
return parsedIcons;
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue