Skip to content

[Charts] Remove/Hide useDarkMode hook from charts theme service #220432

Open
@nickofthyme

Description

@nickofthyme

In the charts plugin we exposed a useDarkMode hook to make it easy to fetch dark mode from charts instead of also having to import the theme.

/** A React hook for consuming the dark mode value */
public useDarkMode = (): boolean => {
const [value, update] = useState(false);
useEffect(() => {
const s = this.darkModeEnabled$.subscribe((val) => {
update(val.darkMode);
});
return () => s.unsubscribe();
}, []);
return value;
};

In addition we also provided an observable for darkModeEnabled$.

/** An observable boolean for dark mode of kibana */
public get darkModeEnabled$(): Observable<CoreTheme> {
if (!this.theme$) {
throw new Error('ThemeService not initialized');
}
return this.theme$;
}

With changes to correct usage of the theme across kibana in #220141 we deprecated these properties to prevent usage in favor of useKibanaIsDarkMode (later to be useIsDarkMode from eui).

These properties should eventually be hidden in the case of darkModeEnabled$ and removed in the case of useDarkMode.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Team:VisualizationsTeam label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion)technical debtImprovement of the software architecture and operational architecture

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions