43 lines
1.7 KiB
JavaScript
43 lines
1.7 KiB
JavaScript
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
|
|
|
import { visibleComponents } from '@/utils/defaults';
|
|
|
|
/**
|
|
* Initiates the Accumulator class and generates a complete config object
|
|
* Self-executing function, returns the full user config as a JSON object
|
|
*/
|
|
export const config = (() => {
|
|
const Accumulator = new ConfigAccumulator();
|
|
return Accumulator.config();
|
|
})();
|
|
|
|
/**
|
|
* Generates an object containing booleans indicating which
|
|
* components should be hidden. This enables the user to hide
|
|
* parts of the page and disable functionality that they don't need/ want
|
|
* All options fallback on the values defined in the defaults
|
|
* @param {object} appConfig The full app config
|
|
* @returns {object} result
|
|
*/
|
|
export const componentVisibility = (appConfig) => {
|
|
// Get users choice from app config
|
|
const usersChoice = appConfig.hideComponents || {};
|
|
// Checks if value is defined, and is a boolean
|
|
const isThere = (userValue) => typeof userValue === 'boolean';
|
|
// For each option, return users choice (if specified), else use the default
|
|
return {
|
|
pageTitle: isThere(usersChoice.hideHeading)
|
|
? !usersChoice.hideHeading : visibleComponents.pageTitle,
|
|
navigation: isThere(usersChoice.hideNav)
|
|
? !usersChoice.hideNav : visibleComponents.navigation,
|
|
searchBar: isThere(usersChoice.hideSearch)
|
|
? !usersChoice.hideSearch : visibleComponents.searchBar,
|
|
settings: isThere(usersChoice.hideSettings)
|
|
? !usersChoice.hideSettings : visibleComponents.settings,
|
|
footer: isThere(usersChoice.hideFooter)
|
|
? !usersChoice.hideFooter : visibleComponents.footer,
|
|
splashScreen: isThere(usersChoice.hideSplashScreen)
|
|
? !usersChoice.hideSplashScreen : visibleComponents.splashScreen,
|
|
};
|
|
};
|