-
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
FloRad edited this page Feb 18, 2022
·
7 revisions
Moral Code fires the moralCodeReady
which provides 2 functions
- registerTheme
- registerSheet
Registering a theme can either be done in the moralCodeRead
hook or any time after Foundry's setup
hook is finished
Example:
Hooks.on('moralCodeReady', (api) => {
const myCoolTheme = {
label: 'Some Cool Theme',
class: 'cool-theme',
};
api.registerTheme(myCoolTheme);
});
To avoid CSS collisions please always scope your theme under the parent class moral-code
.moral-code.cool-theme {
//add CSS here
}
Any themes registered that way can then be selected in the Module Settings with the Theme dropdown
Registering a theme can either be done in the moralCodeRead
hook or any time after Foundry's setup
hook is finished
Sheet registration data:
Name | Type | Description |
---|---|---|
system | string | The system that this sheet is used in |
sheetClass | string | The sheet class to look for |
target | string | The selector used to select the element that will be replaced by the moral code button |
classes | string[] (optional) | The class(es) to apply to the button to make it look good. Defaults to ["moral-code"]
|
insert | boolean (optional) | If true , the Moral Code button will be inserted as a standalone button instead of replacing an element |
prepend | boolean (optional) | If true the Moral Code button will be prepended to the target on insert, otherwise it is appended |
Please keep in mind that you need to provide your own css rules. The module only applies the class you have defined.
Example:
Hooks.on('moralCodeReady', (api) => {
const myCoolSheet = {
system: 'my-cool-system',
sheetClass: 'MyCoolSheet',
target: 'some.css.selector',
};
api.registerSheet(myCoolSheet);
});