caewok / fvtt-walled-templates

Foundry VTT templates that interact with walls
MIT License
9 stars 4 forks source link

Feature Request: Compatibility with Tidy 5e Sheets #121

Open kgar opened 2 months ago

kgar commented 2 months ago

Hello, I'm the author of Tidy 5e Sheets and would like to see if we can work together to establish compatibility between our modules.

Tidy 5e Sheets runs on svelte and handles reactivity a bit differently, so I've been working to provide an API for things like adding tabs that support handlebars templates while still running in svelte.

I have a TypeDoc site here: https://kgar.github.io/foundry-vtt-tidy-5e-sheets/

This is the API function for adding tabs to item sheets: https://kgar.github.io/foundry-vtt-tidy-5e-sheets/classes/Tidy5eSheetsApi.html#registerItemTab

The sample code uses the Handlebars-based tab and allows for supplying a template, specifying or extending the data that is given to a template, whether the tab should be enabled based on the item's data, etc.:

Hooks.once('tidy5e-sheet.ready', (api) => {
  api.registerItemTab(
    new api.models.HandlebarsTab({
      title: 'My Item Tab',
      tabId: 'my-module-id-my-item-tab',
      path: '/modules/my-module-id/my-item-tab.hbs',
      enabled: (data) => data.item.type === 'spell',
      getData: (data) => {
        data['my-extra-data'] = 'Hello, world! 👋';
        return data;
      },
      onRender(params) {
        const myTab = $(params.tabContentsElement);
        myTab.find('.my-control').click(_myHandler.bind(params.app));
      },
    }));
});

I hope we can work it out. We have mutual users that would rejoice!

I've got a cross-post here: https://github.com/kgar/foundry-vtt-tidy-5e-sheets/issues/656