import React from "react"; import classnames from "classnames"; import {detect} from "detect-browser"; import { MdOpenInBrowser, MdSettings, MdLayers, MdHelpOutline, MdFindInPage, MdLanguage, MdSave, MdPublic, MdCode } from "react-icons/md"; import pkgJson from "../../package.json"; //@ts-ignore import maputnikLogo from "maputnik-design/logos/logo-color.svg?inline"; import { withTranslation, type WithTranslation } from "react-i18next"; import { supportedLanguages } from "../i18n"; import type { OnStyleChangedCallback } from "../libs/definitions"; // This is required because of , there isn't another way to detect support that I'm aware of. const browser = detect(); const colorAccessibilityFiltersEnabled = ["chrome", "firefox"].indexOf(browser!.name) > -1; export type ModalTypes = "settings" | "sources" | "open" | "shortcuts" | "export" | "debug" | "globalState" | "codeEditor"; type IconTextProps = { children?: React.ReactNode }; class IconText extends React.Component { render() { return {this.props.children}; } } type ToolbarLinkProps = { className?: string children?: React.ReactNode href?: string }; class ToolbarLink extends React.Component { render() { return {this.props.children} ; } } type ToolbarSelectProps = { children?: React.ReactNode wdKey?: string }; class ToolbarSelect extends React.Component { render() { return
{this.props.children}
; } } type ToolbarActionProps = { children?: React.ReactNode onClick?(...args: unknown[]): unknown wdKey?: string }; class ToolbarAction extends React.Component { render() { return ; } } export type MapState = "map" | "inspect" | "filter-achromatopsia" | "filter-deuteranopia" | "filter-protanopia" | "filter-tritanopia"; type AppToolbarInternalProps = { mapStyle: object inspectModeEnabled: boolean onStyleChanged: OnStyleChangedCallback // A new style has been uploaded onStyleOpen: OnStyleChangedCallback // A dict of source id's and the available source layers sources: object children?: React.ReactNode onToggleModal(modal: ModalTypes): void onSetMapState(mapState: MapState): unknown mapState?: MapState renderer?: string } & WithTranslation; class AppToolbarInternal extends React.Component { state = { isOpen: { settings: false, sources: false, open: false, add: false, export: false, } }; handleSelection(val: MapState) { this.props.onSetMapState(val); } handleLanguageChange(val: string) { this.props.i18n.changeLanguage(val); } onSkip = (target: string) => { if (target === "map") { (document.querySelector(".maplibregl-canvas") as HTMLCanvasElement).focus(); } else { const el = document.querySelector("#skip-target-"+target) as HTMLButtonElement; el.focus(); } }; render() { const t = this.props.t; const views = [ { id: "map", group: "general", title: t("Map"), }, { id: "inspect", group: "general", title: t("Inspect"), disabled: this.props.renderer === "ol", }, { id: "filter-deuteranopia", group: "color-accessibility", title: t("Deuteranopia filter"), disabled: !colorAccessibilityFiltersEnabled, }, { id: "filter-protanopia", group: "color-accessibility", title: t("Protanopia filter"), disabled: !colorAccessibilityFiltersEnabled, }, { id: "filter-tritanopia", group: "color-accessibility", title: t("Tritanopia filter"), disabled: !colorAccessibilityFiltersEnabled, }, { id: "filter-achromatopsia", group: "color-accessibility", title: t("Achromatopsia filter"), disabled: !colorAccessibilityFiltersEnabled, }, ]; const currentView = views.find((view) => { return view.id === this.props.mapState; }); return ; } } const AppToolbar = withTranslation()(AppToolbarInternal); export default AppToolbar;