UNPKG

@gravity-ui/graph

Version:

Modern graph editor component

45 lines (44 loc) 1.62 kB
import StyleObserver from "style-observer"; import { Layer, LayerContext } from "../../services/Layer"; import type { CSSVariablesLayerProps, CSSVariablesLayerState } from "./types"; /** * CSSVariablesLayer: Synchronizes CSS variables with graph colors and constants * * Creates an empty HTML div with specified CSS class and monitors CSS variable changes * using style-observer package. Automatically maps CSS variables to TGraphColors and * TGraphConstants and applies changes via graph.setColors() and graph.setConstants(). */ export declare class CSSVariablesLayer extends Layer<CSSVariablesLayerProps, LayerContext, CSSVariablesLayerState> { state: CSSVariablesLayerState; private containerElement; private styleObserver; constructor(props: CSSVariablesLayerProps); protected propsChanged(nextProps: CSSVariablesLayerProps): void; protected afterInit(): void; protected unmount(): void; /** * Creates the container HTML element with specified CSS class */ private createContainerElement; /** * Removes the container element from DOM */ private removeContainerElement; protected createStyleObserver(): StyleObserver; /** * Starts observing CSS variable changes using style-observer */ private startObserving; /** * Stops observing CSS variable changes */ private stopObserving; /** * Handles CSS variable changes from style-observer */ private handleCSSVariableChanges; /** * Applies CSS variable changes to graph colors and constants */ private applyChangesToGraph; }