mapcomplete/UI/Base/ScrollableFullScreen.ts

40 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-01-08 01:13:44 +00:00
import {UIElement} from "../UIElement";
import Svg from "../../Svg";
import State from "../../State";
import Combine from "./Combine";
2021-01-08 15:49:42 +00:00
import Ornament from "./Ornament";
2021-01-08 01:13:44 +00:00
/**
* Wraps some contents into a panel that scrolls the content _under_ the title
*/
2021-01-08 23:03:21 +00:00
export default class ScrollableFullScreen extends UIElement {
2021-01-21 22:39:31 +00:00
private _component: UIElement;
2021-01-08 23:03:21 +00:00
2021-01-08 01:13:44 +00:00
constructor(title: UIElement, content: UIElement) {
super();
2021-01-21 22:39:31 +00:00
const returnToTheMap = Svg.back_ui().onClick(() => {
2021-01-08 01:13:44 +00:00
State.state.fullScreenMessage.setData(undefined);
State.state.selectedElement.setData(undefined);
2021-01-21 22:39:31 +00:00
}).SetClass("block sm:hidden mb-2 bg-blue-50 rounded-full w-12 h-12 p-1.5")
2021-01-24 21:20:54 +00:00
title.SetClass("block w-full")
2021-01-24 21:20:54 +00:00
2021-01-21 22:39:31 +00:00
const ornament = new Combine([new Ornament().SetStyle("height:5em;")]).SetClass("sm:hidden")
2021-01-08 23:03:21 +00:00
2021-01-08 01:13:44 +00:00
this._component = new Combine([
2021-01-21 22:39:31 +00:00
new Combine([returnToTheMap, title])
.AddClass("border-b-2 border-black shadow sm:shadow-none z-50 bg-white p-2 pb-0 sm:p-0 flex overflow-x-hidden flex-shrink-0 max-h-20vh"),
new Combine(["<span>", content, "</span>", ornament])
2021-01-21 22:39:31 +00:00
.SetClass("block p-2 sm:pt-4 w-full max-h-screen landscape:max-h-screen overflow-y-auto overflow-x-hidden"),
2021-01-08 15:49:42 +00:00
// We add an ornament which takes around 5em. This is in order to make sure the Web UI doesn't hide
2021-01-21 22:39:31 +00:00
]).SetClass("block flex flex-col fixed max-h-screen sm:max-h-65vh sm:relative top-0 left-0 right-0");
2021-01-08 23:03:21 +00:00
2021-01-08 01:13:44 +00:00
}
2021-01-08 23:03:21 +00:00
2021-01-08 01:13:44 +00:00
InnerRender(): string {
return this._component.Render();
}
}