UNPKG

@pdf-viewer/react

Version:

A react-pdf-viewer component for React and Next.js. Suitable for react-pdf document.

29 lines (28 loc) 1.47 kB
import { jsxs as d, jsx as t } from "react/jsx-runtime"; import { useCallback as u } from "react"; import { MoonIcon as a } from "../../icons/MoonIcon.js"; import { SunIcon as f } from "../../icons/SunIcon.js"; import { UIButton as h } from "../../ui/Button.js"; import { useDarkModeContext as s } from "../../../contexts/DarkModeContext.js"; import { useToolbarComponentContext as k } from "../../../contexts/ToolbarComponentContext.js"; import { useIconContext as m } from "../../../contexts/IconContext.js"; import c from "../../ui/RPTooltip.js"; import { useLocalizationContext as C } from "../../../contexts/LocalizationContext.js"; const I = () => { const { lightModeIcon: o } = m(); return o || /* @__PURE__ */ t(a, {}); }, x = () => { const { darkModeIcon: o } = m(); return o || /* @__PURE__ */ t(f, {}); }, z = () => { const { darkMode: o, setDarkMode: r } = s(), { themeSwitcher: e = !0 } = k(), { localeMessages: n } = C(), i = o ? n == null ? void 0 : n.themeEnableLightTooltip : n == null ? void 0 : n.themeEnableDarkTooltip, l = u(() => { r((p) => !p); }, [r]); return typeof e != "boolean" ? /* @__PURE__ */ d(c, { content: i, children: [ /* @__PURE__ */ t(e, { darkMode: o, setDarkMode: r }), " " ] }) : e ? /* @__PURE__ */ t(c, { content: i, children: /* @__PURE__ */ t(h, { onClick: l, "aria-label": i, children: o ? /* @__PURE__ */ t(x, {}) : /* @__PURE__ */ t(I, {}) }) }) : null; }; export { z as DarkModeTool };