This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-web/src/navigate/NavigatorPlugin.ts

34 lines
1002 B
TypeScript
Raw Normal View History

2019-12-26 17:09:03 +08:00
import { DoricPlugin } from "../DoricPlugin";
import { DoricElement } from "../DoricElement";
2019-12-26 17:18:26 +08:00
import { NavigationElement } from "./NavigationElement";
2019-12-26 17:09:03 +08:00
export class NavigatorPlugin extends DoricPlugin {
navigation: NavigationElement | undefined = document.getElementsByTagName('doric-navigation')[0] as (NavigationElement | undefined)
push(args: {
scheme: string,
config?: {
alias?: string,
extra?: string,
}
}) {
if (this.navigation) {
const div = new DoricElement
div.src = args.scheme
div.alias = args.config?.alias || args.scheme
this.navigation.push(div)
return Promise.resolve()
} else {
return Promise.reject('Not implemented')
}
}
pop() {
if (this.navigation) {
this.navigation.pop()
return Promise.resolve()
} else {
return Promise.reject('Not implemented')
}
}
}