diff options
| author | Fawn <fangrui_tong@brown.edu> | 2019-04-22 00:05:35 -0400 |
|---|---|---|
| committer | Fawn <fangrui_tong@brown.edu> | 2019-04-22 00:05:35 -0400 |
| commit | e794b4b38e8ab2f4e7a79f223f9488cc845c724f (patch) | |
| tree | 1d336bd0784463ac13f6505a884d6cbea09c41be /src/client/views/Templates.tsx | |
| parent | 7ceac5f7f4cc8172bde90c2d495da3779901ef84 (diff) | |
mutiple templates can be used
Diffstat (limited to 'src/client/views/Templates.tsx')
| -rw-r--r-- | src/client/views/Templates.tsx | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/src/client/views/Templates.tsx b/src/client/views/Templates.tsx index 3afdc711c..616bc2566 100644 --- a/src/client/views/Templates.tsx +++ b/src/client/views/Templates.tsx @@ -1,57 +1,66 @@ -import { observer } from "mobx-react"; -import { observable } from "mobx"; -import { action, computed } from "mobx"; import React = require("react"); -import { StringLiteral } from "babel-types"; + +export enum TemplatePosition { + InnerTop, + InnerBottom, + InnerRight, + InnerLeft, + OutterTop, + OutterBottom, + OutterRight, + OutterLeft, +} export class Template { - constructor(name: string, layout: string) { + constructor(name: string, position: TemplatePosition, layout: string) { this._name = name; + this._position = position; this._layout = layout; } private _name: string; + private _position: TemplatePosition; private _layout: string; get Name(): string { return this._name; } + get Position(): TemplatePosition { + return this._position; + } + get Layout(): string { return this._layout; } - } export namespace Templates { - export const BasicLayout = new Template("Basic layout", "{layout}"); + // export const BasicLayout = new Template("Basic layout", "{layout}"); - export const OuterCaption = new Template("Outer caption", + export const OuterCaption = new Template("Outer caption", TemplatePosition.OutterBottom, `<div><div style="margin:auto; height:calc(100%); width:100%;">{layout}</div><div style="height:(100% + 50px); width:100%; position:absolute"><FormattedTextBox doc={Document} DocumentViewForField={DocumentView} bindings={bindings} fieldKey={CaptionKey} isSelected={isSelected} select={select} selectOnLoad={SelectOnLoad} isTopMost={isTopMost}/></div></div>` ); - export const InnerCaption = new Template("Inner caption", - `<div> - <div style="margin:auto; height:calc(100% - 50px); width:100%;"> - {layout} - </div> - <div style="height:50px; width:100%; position:absolute"> - <FormattedTextBox doc={Document} DocumentViewForField={DocumentView} bindings={bindings} fieldKey={CaptionKey} isSelected={isSelected} select={select} selectOnLoad={SelectOnLoad} isTopMost={isTopMost}/> - </div> - </div>` + export const InnerCaption = new Template("Inner caption", TemplatePosition.InnerBottom, + `<div><div style="margin:auto; height:calc(100% - 50px); width:100%;">{layout}</div><div style="height:50px; width:100%; position:absolute"><FormattedTextBox doc={Document} DocumentViewForField={DocumentView} bindings={bindings} fieldKey={CaptionKey} isSelected={isSelected} select={select} selectOnLoad={SelectOnLoad} isTopMost={isTopMost}/></div></div>` ); - export const Title = new Template("Title", - `<div> - <div style="margin:auto; height:calc(100% - 50px); width:100%;"> - {layout} - </div> - <div style="height:50px; width:100%; position:absolute; background-color: rgba(0, 0, 0, .6); color: white; padding:12px"> - {Title} - </div> - </div>` + export const SideCaption = new Template("Side caption", TemplatePosition.OutterRight, + `<div><div style="margin:auto; height:100%; width:100%;">{layout}</div><div style="height:100%; width:300px; position:absolute; top: 0; right: -300px;"><FormattedTextBox doc={Document} DocumentViewForField={DocumentView} bindings={bindings} fieldKey={CaptionKey} isSelected={isSelected} select={select} selectOnLoad={SelectOnLoad} isTopMost={isTopMost}/></div> </div>` ); + export const Title = new Template("Title", TemplatePosition.InnerTop, + `<div><div style="margin:auto; height:calc(100% - 50px); width:100%;">{layout}</div><div style="height:50px; width:100%; position:absolute; top: 0; background-color: rgba(0, 0, 0, .6); color: white; padding:12px">{Title}</div></div>` + ); + + export const TemplateList: Template[] = [Title, OuterCaption, InnerCaption, SideCaption]; + + export function sortTemplates(a: Template, b: Template) { + if (a.Position < b.Position) { return -1; } + if (a.Position > b.Position) { return 1; } + return 0; + } } |
