import Command from "@web-atoms/core/dist/core/Command"; import XNode from "@web-atoms/core/dist/core/XNode"; import styled from "@web-atoms/core/dist/style/styled"; import { ContentPage, Drawer } from "@web-atoms/web-controls/dist/mobile-app/MobileApp"; import PageNavigator from "@web-atoms/web-controls/dist/PageNavigator"; import HomePage from "../pages/home/HomePage"; import logo from "../../images/logo.png"; import MDPage from "../pages/markdown/MDPage"; import AppCommands from "../commands/AppCommands"; import Route from "@web-atoms/core/dist/core/Route"; const menuCss = styled.css ` cursor: pointer; padding: 5px 10px 5px 10px; border-radius: 10px; text-decoration: none; color: var(--link-color); &:hover { background-color: lightgreen; text-decoration: underline; } `.installLocal(); interface IMenuItem { label: string; icon?: string; command?: Command; commandLink?: Command; openPage?: typeof ContentPage; pushPage?: typeof ContentPage; pageParameter?: any; href?: string; } const MenuItem = ({ label, icon = "", command, commandLink, openPage, pushPage, pageParameter, href }: IMenuItem) => { if (commandLink) { return {icon && } {label} ; } if (href) { return {icon && } {label} ; } return
command ? command.dispatch() : ( pushPage ? PageNavigator.pushPage(pushPage, pageParameter) : PageNavigator.openPage(openPage, pageParameter) )}> { icon && }
; }; const MDMenu = ({label, url}) => MenuItem({ label, openPage: MDPage, pageParameter: { label, url } }); const css = styled.css ` width: 200px; `.installLocal(); export default class AppMenu extends Drawer { public async init() { this.renderer =
; } } Route.encodeUrl = (url) => { if (/(webatoms\.in)|(^\#)/i.test(location.href)) { return url; } return "#!" + url; };