Throw some initial version of code at the wall for the tabbed character sheet
This commit is contained in:
parent
eb6d7fee94
commit
b72f22380f
10 changed files with 213 additions and 2 deletions
|
|
@ -1,12 +1,16 @@
|
|||
import { handlebarsLocalizer, localizer } from "../utils/Localizer.mjs";
|
||||
import { formFields } from "./inputs/formFields.mjs";
|
||||
import { options } from "./options.mjs";
|
||||
import { toAttributes } from "./toAttributes.mjs";
|
||||
import { toClasses } from "./toClasses.mjs";
|
||||
|
||||
export default {
|
||||
// #region Complex
|
||||
"rc-formFields": formFields,
|
||||
"rc-i18n": handlebarsLocalizer,
|
||||
"rc-options": options,
|
||||
"rc-toAttributes": toAttributes,
|
||||
"rc-toClasses": toClasses,
|
||||
|
||||
// #region Simple
|
||||
"rc-empty-state": (v) => v ?? localizer(`RipCrypt.common.empty`),
|
||||
|
|
|
|||
13
module/handlebarHelpers/toAttributes.mjs
Normal file
13
module/handlebarHelpers/toAttributes.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Allows converting an object of <attribute names, value> into HTML
|
||||
* attribute-value pairs that can be inserted into the DOM
|
||||
*
|
||||
* @param {Record<string, any>} obj The object of attributes to their value
|
||||
*/
|
||||
export function toAttributes(obj = {}) {
|
||||
let attributes = [];
|
||||
for (const [ attr, value] of Object.entries(obj)) {
|
||||
attributes.push(`${attr}=${Handlebars.escapeExpression(value)}`);
|
||||
};
|
||||
return new Handlebars.SafeString(attributes.join(` `));
|
||||
};
|
||||
14
module/handlebarHelpers/toClasses.mjs
Normal file
14
module/handlebarHelpers/toClasses.mjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Allows converting an object of <class names, boolean-likes> into an HTML-compatible class list.
|
||||
*
|
||||
* @param {Record<string, any>} obj The object of class names to boolean-like values for if that class should be included.
|
||||
*/
|
||||
export function toClasses(obj = {}) {
|
||||
let classes = [];
|
||||
for (const [ klass, include ] of Object.entries(obj)) {
|
||||
if (include) {
|
||||
classes.push(klass);
|
||||
};
|
||||
};
|
||||
return new Handlebars.SafeString(classes.join(` `));
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue