Docs: add stack offset for featureSwitches and booleanSwitch

This commit is contained in:
Pieter Vander Vennet 2023-07-28 00:46:02 +02:00
parent 9d23f80539
commit 5269481afc
3 changed files with 21 additions and 24 deletions

View file

@ -1,32 +1,26 @@
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig" import LayoutConfig from "../Models/ThemeConfig/LayoutConfig"
import { QueryParameters } from "./Web/QueryParameters" import {QueryParameters} from "./Web/QueryParameters"
import { AllKnownLayouts } from "../Customizations/AllKnownLayouts" import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"
import { FixedUiElement } from "../UI/Base/FixedUiElement" import {FixedUiElement} from "../UI/Base/FixedUiElement"
import { Utils } from "../Utils" import {Utils} from "../Utils"
import Combine from "../UI/Base/Combine" import Combine from "../UI/Base/Combine"
import { SubtleButton } from "../UI/Base/SubtleButton" import {SubtleButton} from "../UI/Base/SubtleButton"
import BaseUIElement from "../UI/BaseUIElement" import BaseUIElement from "../UI/BaseUIElement"
import { UIEventSource } from "./UIEventSource" import {UIEventSource} from "./UIEventSource"
import { LocalStorageSource } from "./Web/LocalStorageSource" import {LocalStorageSource} from "./Web/LocalStorageSource"
import LZString from "lz-string" import LZString from "lz-string"
import { FixLegacyTheme } from "../Models/ThemeConfig/Conversion/LegacyJsonConvert" import {FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"
import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson" import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"
import known_layers from "../assets/generated/known_layers.json" import known_layers from "../assets/generated/known_layers.json"
import { PrepareTheme } from "../Models/ThemeConfig/Conversion/PrepareTheme" import {PrepareTheme} from "../Models/ThemeConfig/Conversion/PrepareTheme"
import licenses from "../assets/generated/license_info.json" import licenses from "../assets/generated/license_info.json"
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig" import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig"
import { FixImages } from "../Models/ThemeConfig/Conversion/FixImages" import {FixImages} from "../Models/ThemeConfig/Conversion/FixImages"
import Svg from "../Svg" import Svg from "../Svg"
import questions from "../assets/generated/layers/questions.json" import questions from "../assets/generated/layers/questions.json"
import { import {DoesImageExist, PrevalidateTheme, ValidateThemeAndLayers,} from "../Models/ThemeConfig/Conversion/Validation"
DoesImageExist, import {DesugaringContext} from "../Models/ThemeConfig/Conversion/Conversion"
PrevalidateTheme, import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson"
ValidateTagRenderings,
ValidateThemeAndLayers,
} from "../Models/ThemeConfig/Conversion/Validation"
import { DesugaringContext } from "../Models/ThemeConfig/Conversion/Conversion"
import { RewriteSpecial } from "../Models/ThemeConfig/Conversion/PrepareLayer"
import { TagRenderingConfigJson } from "../Models/ThemeConfig/Json/TagRenderingConfigJson"
import Hash from "./Web/Hash" import Hash from "./Web/Hash"
export default class DetermineLayout { export default class DetermineLayout {

View file

@ -10,7 +10,7 @@ import { Utils } from "../../Utils"
class FeatureSwitchUtils { class FeatureSwitchUtils {
static initSwitch(key: string, deflt: boolean, documentation: string): UIEventSource<boolean> { static initSwitch(key: string, deflt: boolean, documentation: string): UIEventSource<boolean> {
const defaultValue = deflt const defaultValue = deflt
const queryParam = QueryParameters.GetQueryParameter(key, "" + defaultValue, documentation) const queryParam = QueryParameters.GetQueryParameter(key, "" + defaultValue, documentation, {stackOffset: -1})
// It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened // It takes the current layout, extracts the default value for this query parameter. A query parameter event source is then retrieved and flattened
return queryParam.sync( return queryParam.sync(

View file

@ -17,14 +17,17 @@ export class QueryParameters {
public static GetQueryParameter( public static GetQueryParameter(
key: string, key: string,
deflt: string, deflt: string,
documentation?: string documentation?: string,
options?: {
stackOffset?: number
}
): UIEventSource<string> { ): UIEventSource<string> {
if (!this.initialized) { if (!this.initialized) {
this.init() this.init()
} }
if (Utils.runningFromConsole) { if (Utils.runningFromConsole) {
const location = Utils.getLocationInCode(-1) const location = Utils.getLocationInCode(-1 + (options?.stackOffset ?? 0))
documentation += documentation +=
"\n\nThis documentation is defined in the source code at [" + "\n\nThis documentation is defined in the source code at [" +
@ -63,7 +66,7 @@ export class QueryParameters {
documentation?: string documentation?: string
): UIEventSource<boolean> { ): UIEventSource<boolean> {
return UIEventSource.asBoolean( return UIEventSource.asBoolean(
QueryParameters.GetQueryParameter(key, "" + deflt, documentation) QueryParameters.GetQueryParameter(key, "" + deflt, documentation, {stackOffset: -1})
) )
} }