From 16e861bd4c16483783cdc0534af614625dd0f775 Mon Sep 17 00:00:00 2001 From: Fawn Date: Mon, 1 Apr 2019 20:47:01 -0400 Subject: created template adding menu --- src/client/views/DocumentDecorations.scss | 72 ++++++++++++------------- src/client/views/DocumentDecorations.tsx | 89 +++++++++++++++++++------------ src/client/views/Templates.tsx | 18 +++++-- src/client/views/nodes/DocumentView.tsx | 21 ++++++-- 4 files changed, 120 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/client/views/DocumentDecorations.scss b/src/client/views/DocumentDecorations.scss index 642d7caf3..f6d332a36 100644 --- a/src/client/views/DocumentDecorations.scss +++ b/src/client/views/DocumentDecorations.scss @@ -70,26 +70,21 @@ // cursor: ew-resize; // } // } -.linkFlyout { - grid-column: 1/4 -} -.linkButton-empty:hover { - background: $main-accent; - transform: scale(1.05); - cursor: pointer; +.documentDecorations-extra { + display: flex; + position: absolute; } -.linkButton-nonempty:hover { - background: $main-accent; - transform: scale(1.05); - cursor: pointer; +.documentDecorations-ex-wrapper { + margin-right: 10px; } -.linkButton-empty { +.linkButton-empty, +.linkButton-nonempty, +.documentDecorations-ex { height: 20px; width: 20px; - margin-top: 10px; border-radius: 50%; opacity: 0.9; pointer-events: auto; @@ -103,34 +98,33 @@ display: flex; justify-content: center; align-items: center; + + &:hover { + background: $main-accent; + transform: scale(1.05); + cursor: pointer; + } } -.linkButton-nonempty { - height: 20px; - width: 20px; - margin-top: 10px; - border-radius: 50%; - opacity: 0.9; - pointer-events: auto; - background-color: $dark-color; - color: $light-color; - text-transform: uppercase; - letter-spacing: 2px; - font-size: 75%; - transition: transform 0.2s; - text-align: center; - display: flex; - justify-content: center; - align-items: center; +.templating-button-wrapper { + position: relative; } -.templating-button { - height: 20px; - width: 20px; - margin-top: 10px; - border-radius: 50%; - opacity: 0.9; - pointer-events: auto; - background-color: red; - cursor: pointer; +#template-list { + position: absolute; + top: 0; + left: 30px; + width: 150px; + line-height: 25px; + max-height: 175px; + font-family: $sans-serif; + font-size: 12px; + background-color: $light-color-secondary; + padding: 2px 12px; + + input { + margin-right: 10px; + } + + } \ No newline at end of file diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 6d60f9740..9fe3cdc75 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -9,7 +9,7 @@ import { props } from "bluebird"; import { DragManager } from "../util/DragManager"; import { LinkMenu } from "./nodes/LinkMenu"; import { ListField } from "../../fields/ListField"; -import { Templates } from "./Templates"; +import { Templates, Template } from "./Templates"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -23,6 +23,7 @@ export class DocumentDecorations extends React.Component { private _resizeBorderWidth = 16; private _linkButton = React.createRef(); @observable private _hidden = false; + @observable private _templatesActive: boolean = false; constructor(props: Readonly<{}>) { super(props) @@ -193,20 +194,18 @@ export class DocumentDecorations extends React.Component { // e.stopPropagation(); // } - addTemplate = (): void => { - console.log("add template"); - let text = ` -
-
- {layout} -
-
- -
-
- `; + toggleTemplate = (event: React.ChangeEvent, template: Template): void => { let view = SelectionManager.SelectedDocuments()[0]; - view.addTemplate(Templates.OuterCaption); + if (event.target.checked) { + view.addTemplate(template); + } else { + view.removeTemplate(template); + } + } + + @action + toggleTemplateActivity = (): void => { + this._templatesActive = !this._templatesActive; } render() { @@ -234,28 +233,52 @@ export class DocumentDecorations extends React.Component {
{linkCount}
); } - return ( -
-
e.preventDefault()}>
-
e.preventDefault()}>
-
e.preventDefault()}>
-
e.preventDefault()}>
-
-
e.preventDefault()}>
-
e.preventDefault()}>
-
e.preventDefault()}>
-
e.preventDefault()}>
-
{linkButton}
+ let templateMenu = !this._templatesActive ? (null) : ( +
    + {Array.from(Object.values(Templates)).map(template => { + return ( +
  • + this.toggleTemplate(event, template)} /> + {template.Name} +
  • + ) + })} +
+ ) + return ( +
+
+
e.preventDefault()}>
+
e.preventDefault()}>
+
e.preventDefault()}>
+
e.preventDefault()}>
+
+
e.preventDefault()}>
+
e.preventDefault()}>
+
e.preventDefault()}>
+
e.preventDefault()}>
-
+
+
+
{linkButton}
-
+
+
this.toggleTemplateActivity()}>T
+ {templateMenu} +
+
+
) } } \ No newline at end of file diff --git a/src/client/views/Templates.tsx b/src/client/views/Templates.tsx index 8260f9414..d717fb778 100644 --- a/src/client/views/Templates.tsx +++ b/src/client/views/Templates.tsx @@ -2,21 +2,30 @@ import { observer } from "mobx-react"; import { observable } from "mobx"; import { action, computed } from "mobx"; import React = require("react"); +import { StringLiteral } from "babel-types"; export class Template { - constructor(layout: string) { + constructor(name: string, layout: string) { + this._name = name; this._layout = layout; } - private _layout: string = ""; + private _name: string; + private _layout: string; + + get Name(): string { + return this._name; + } get Layout(): string { return this._layout; } + } export namespace Templates { - export const OuterCaption = new Template(` + export const OuterCaption = new Template("Outer caption", + `
{layout} @@ -26,7 +35,8 @@ export namespace Templates {
`); - export const InnerCaption = new Template(` + export const InnerCaption = new Template("Inner caption", + `
{layout} diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index f8e5b0277..e5c6859f8 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -94,7 +94,8 @@ export class DocumentView extends React.Component { private _downX: number = 0; private _downY: number = 0; private _reactionDisposer: Opt; - private _templates: Array