* Copyright (C) 2021 Red Hat, Inc.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
import cockpit from "cockpit";
import "cockpit-dark-theme";
import React from "react";
import { createRoot } from "react-dom/client";
import { convertToCockpitLang } from "./helpers/language.js";
import { ApplicationWithErrorBoundary } from "./components/app.jsx";
import "./components/app.scss";
import "../pkg/lib/patternfly/patternfly-6-cockpit.scss";
* PF4 overrides need to come after the JSX components imports because
* these are importing CSS stylesheets that we are overriding
* Having the overrides here will ensure that when mini-css-extract-plugin will extract the CSS
* out of the dist/index.js and since it will maintain the order of the imported CSS,
* the overrides will be correctly in the end of our stylesheet.
*/
import "../pkg/lib/patternfly/patternfly-6-overrides.scss";
document.addEventListener("DOMContentLoaded", function () {
cockpit.transport.wait(() => cockpit.hint("ignore_transport_health_check", { data: true }));
const root = createRoot(document.getElementById("app"));
root.render(<ApplicationWithErrorBoundary />);
document.documentElement.setAttribute("dir", cockpit.language_direction);
document.documentElement.setAttribute("lang", convertToCockpitLang({ lang: cockpit.language }));
});
window.addEventListener("cockpit-lang", () => {
document.documentElement.setAttribute("lang", convertToCockpitLang({ lang: cockpit.language }));
if (cockpit.language_direction) {
document.documentElement.setAttribute("dir", cockpit.language_direction);
}
});