diff --git a/module/apps/ArtSidebar.mjs b/module/apps/ArtSidebar.mjs new file mode 100644 index 0000000..3e11dba --- /dev/null +++ b/module/apps/ArtSidebar.mjs @@ -0,0 +1,58 @@ +import { api } from "../api.mjs"; +import { __ID__, filePath } from "../consts.mjs"; + +const { HandlebarsApplicationMixin } = foundry.applications.api; +const { AbstractSidebarTab } = foundry.applications.sidebar; + +export class ArtSidebar extends HandlebarsApplicationMixin(AbstractSidebarTab) { + // #region Options + static tabName = `art`; + + static DEFAULT_OPTIONS = { + classes: [ + __ID__, + `ArtSidebar`, + ], + window: {}, + actions: { + openApp: this.#openApp, + }, + }; + + static PARTS = { + tokens: { + template: filePath(`templates/ArtSidebar/tokens.hbs`), + }, + artists: { + template: filePath(`templates/ArtSidebar/artists.hbs`), + }, + }; + // #endregion Options + + // #region Data Prep + _preparePartContext(partID, ctx) { + switch (partID) { + }; + + return ctx; + }; + + _prepareTokensContext(ctx) {}; + + _prepareArtistsContext(ctx) {}; + // #endregion Data Prep + + // #region Actions + static async #openApp(event, target) { + const { app: appKey, ...options } = target.dataset; + delete options.action; + + if (appKey in api.Apps) { + const app = new api.Apps[appKey](options); + await app.render({ force: true }); + } else { + console.error(`Failed to find app with key: ${appKey}`); + }; + }; + // #endregion Actions +}; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index c6511c8..899a2f8 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -1,8 +1,22 @@ import { api } from "../api.mjs"; +import { ArtSidebar } from "../apps/ArtSidebar.mjs"; import helpers from "../handlebarsHelpers/_index.mjs"; Hooks.on(`init`, () => { globalThis.tb = api; Handlebars.registerHelper(helpers); + + // Art sidebar tab + CONFIG.ui.sidebar.TABS.art = { + active: false, + icon: `fa-solid fa-paintbrush`, + tooltip: `Art`, + }; + CONFIG.ui.art = ArtSidebar; + + // Inject the custom tab right before settings + const temp = CONFIG.ui.sidebar.TABS.settings; + delete CONFIG.ui.sidebar.TABS.settings; + CONFIG.ui.sidebar.TABS.settings = temp; }); diff --git a/styles/apps/ArtSidebar.css b/styles/apps/ArtSidebar.css new file mode 100644 index 0000000..6b4a6ab --- /dev/null +++ b/styles/apps/ArtSidebar.css @@ -0,0 +1,19 @@ +.token-browser.ArtSidebar { + flex-flow: column; + gap: 1.5rem; + padding: 1rem; + + &.active { + display: flex; + } + + > section { + display: flex; + flex-direction: column; + gap: 0.5rem; + } + + h4 { + margin: 0; + } +} diff --git a/styles/main.css b/styles/main.css index d82318f..8dc4d08 100644 --- a/styles/main.css +++ b/styles/main.css @@ -12,4 +12,5 @@ @import url("./apps/common.css") layer(apps); @import url("./apps/ArtBrowser.css") layer(apps); @import url("./apps/ArtistApp.css") layer(apps); +@import url("./apps/ArtSidebar.css") layer(apps); @import url("./apps/ImageApp.css") layer(apps); diff --git a/templates/ArtSidebar/artists.hbs b/templates/ArtSidebar/artists.hbs new file mode 100644 index 0000000..56759b7 --- /dev/null +++ b/templates/ArtSidebar/artists.hbs @@ -0,0 +1,17 @@ +
+

Artists

+ + +
diff --git a/templates/ArtSidebar/tokens.hbs b/templates/ArtSidebar/tokens.hbs new file mode 100644 index 0000000..132b9da --- /dev/null +++ b/templates/ArtSidebar/tokens.hbs @@ -0,0 +1,18 @@ +
+

Tokens

+ + +