From 46702582415d10dd3d9addeccb6e1e6739c53a22 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 15 Jul 2022 17:27:51 -0500 Subject: [PATCH] Moved section into its own interface --- src/data/common.tsx | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/data/common.tsx b/src/data/common.tsx index 27cf420..d44b91d 100644 --- a/src/data/common.tsx +++ b/src/data/common.tsx @@ -232,28 +232,30 @@ export function createLayerTreeNode( }) as unknown as LayerTreeNode; } +/** An option object for a modifier display as a single section. **/ +export interface Section { + /** The header for this modifier. **/ + title: string; + /** A subtitle for this modifier, e.g. to explain the context for the modifier. **/ + subtitle?: string; + /** The modifier to be displaying in this section. **/ + modifier: WithRequired; + /** The base value being modified. **/ + base?: Computable; + /** The unit of measurement for the base. **/ + unit?: string; + /** The label to call the base amount. Defaults to "Base". **/ + baseText?: Computable; + /** Whether or not this section should be currently visible to the player. **/ + visible?: Computable; +} + /** * Takes an array of modifier "sections", and creates a JSXFunction that can render all those sections, and allow each section to be collapsed. * Also returns a list of persistent refs that are used to control which sections are currently collapsed. - * @param sections An array of options objects for each section to display. - * @param sections.title The header for this modifier. - * @param sections.subtitle A subtitle for this modifier, e.g. to explain the context for the modifier. - * @param sections.modifier The modifier to be displaying in this section. - * @param sections.base The base value being modified. - * @param sections.unit The unit of measurement for the base. - * @param sections.baseText The label to call the base amount. - * @param sections.visible Whether or not this section should be currently visible to the player. */ export function createCollapsibleModifierSections( - sections: { - title: string; - subtitle?: string; - modifier: WithRequired; - base?: Computable; - unit?: string; - baseText?: Computable; - visible?: Computable; - }[] + sections: Section[] ): [JSXFunction, Persistent[]] { const processedBase = sections.map(s => convertComputable(s.base)); const processedBaseText = sections.map(s => convertComputable(s.baseText));