Skip to content

Commit

Permalink
add externalThemes config option to connect to CDNs for theme assets
Browse files Browse the repository at this point in the history
  • Loading branch information
frankieali committed Jul 8, 2024
1 parent cb54afa commit d0b917c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/WorldFacade.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const defaultOptions = {
scale: 5, // scale the dice
theme: 'default', // can be a hex color or a pre-defined theme such as 'purpleRock'
preloadThemes: [],
externalThemes: {}, // point to CDN paths
themeColor: '#2e8555', // used for color values or named theme variants - not fully implemented yet // green: #2e8555 // yellow: #feea03
offscreen: true, // use offscreen canvas browser feature for performance improvements - will fallback to false based on feature detection
assetPath: '/assets/dice-box/', // path to 'ammo', 'themes' folders and web workers
Expand Down Expand Up @@ -262,7 +263,12 @@ class WorldFacade {

// fetch the theme config and return a themeData object
async getThemeConfig(theme){
const basePath = `${this.config.origin}${this.config.assetPath}themes/${theme}`
let basePath = `${this.config.origin}${this.config.assetPath}themes/${theme}`

if(this.config.externalThemes[theme]){
basePath = this.config.externalThemes[theme]
}


// fetch the theme.config file
let themeData = await fetch(`${basePath}/theme.config.json`).then(resp => {
Expand Down

0 comments on commit d0b917c

Please sign in to comment.