useVariableModes
useVariableModes() provides headless state and actions for a variable mode control, such as a frame's theme: the collections a mode can be set for on the selection, or on the current page when nothing is selected, and the mode each one shows.
Usage
ts
import { useVariableModes } from '@open-pencil/vue/controls/variable-modes'
const { choices, applied, setMode } = useVariableModes()choiceslists every collection with more than one mode for pages and layers that hold others (frames, groups, sections, components, and instances), so a theme can be chosen before anything inside binds its variables; for other layers, only those whose variables they use, through their own bindings or variables those alias. Each has itsmodes, itsvalue(the mode set on every target,MIXEDwhen they differ, ornullfor Auto), and theinheritedmode the targets show without one of their own.appliedis the part ofchoiceswith a mode set on at least one target.setMode(collectionId, modeId)sets the mode on every target in one undo step;nullclears it, so the targets inherit their parent's mode again.
variableModeChoices(editor, nodes) and setVariableMode(editor, nodes, collectionId, modeId) do the same for any layers, outside a component.