1
0
Fork 0

Add typing to Margin.ts and MarginInline.ts.

This commit is contained in:
Kitteh 2021-05-08 00:38:02 +01:00
parent 3bfba4d3fc
commit e712af95de
12 changed files with 16 additions and 18 deletions

View file

@ -1,4 +1,4 @@
import { MarginInline } from "./MarginInline.js"; import { MarginInline } from "./MarginInline";
import { addClipboardNotifications } from "../pageUtils"; import { addClipboardNotifications } from "../pageUtils";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import ClipboardJS from "clipboard"; import ClipboardJS from "clipboard";

View file

@ -1,10 +1,9 @@
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
export function Margin(children, options = {}) { export function Margin(children: null | Element | (Element | null[])): Element {
return makeElement({ return makeElement({
tag: "div", tag: "div",
class: "uk-margin", class: "uk-margin",
children: children, children: children
...options
}); });
} }

View file

@ -1,6 +1,6 @@
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
export function MarginInline(children, marginOptions = {}, inlineOptions = {}) { export function MarginInline(children: null | Element | (Element | null[])): Element {
return makeElement({ return makeElement({
tag: "div", tag: "div",
class: "uk-margin", class: "uk-margin",
@ -8,8 +8,6 @@ export function MarginInline(children, marginOptions = {}, inlineOptions = {}) {
tag: "div", tag: "div",
class: "uk-inline", class: "uk-inline",
children: children, children: children,
...inlineOptions,
}), }),
...marginOptions,
}); });
} }

View file

@ -1,4 +1,4 @@
import { Margin } from "./Margin.js"; import { Margin } from "./Margin";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import QrScanner from 'qr-scanner'; import QrScanner from 'qr-scanner';

View file

@ -17,7 +17,7 @@ const optionsFunctions: optionsFunctionsObject = {
"onclick": (e: HTMLButtonElement, arg: any) => e.onclick = arg, "onclick": (e: HTMLButtonElement, arg: any) => e.onclick = arg,
"attributes": setElementAttributes, "attributes": setElementAttributes,
"text": (e: HTMLParagraphElement, arg: string) => e.innerText = arg, "text": (e: HTMLParagraphElement, arg: string) => e.innerText = arg,
"children": (e: Element, arg: null | Element | (Element | null[])) => { "children": (e: Element, arg: Element | Element[]) => {
if (Array.isArray(arg)) { if (Array.isArray(arg)) {
arg.forEach(child => { arg.forEach(child => {
if (child != null) e.appendChild(child); if (child != null) e.appendChild(child);
@ -38,6 +38,7 @@ interface ElementInfo {
attributes?: { attributes?: {
[propName: string]: any [propName: string]: any
}; };
children?: Element | Element[];
text?: string; text?: string;
thenRun?: (e: Element) => void; thenRun?: (e: Element) => void;
[propName: string]: any; [propName: string]: any;

View file

@ -1,5 +1,5 @@
import { Margin } from "../elements/Margin.js"; import { Margin } from "../elements/Margin";
import { MarginInline } from "../elements/MarginInline.js"; import { MarginInline } from "../elements/MarginInline";
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { changePage, setErrorText, setPageContent } from "../pageUtils"; import { changePage, setErrorText, setPageContent } from "../pageUtils";
import { lookupSelf } from "../api/lookupSelf"; import { lookupSelf } from "../api/lookupSelf";

View file

@ -1,5 +1,5 @@
import { CopyableInputBox } from "../elements/CopyableInputBox"; import { CopyableInputBox } from "../elements/CopyableInputBox";
import { Margin } from "../elements/Margin.js"; import { Margin } from "../elements/Margin";
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { setPageContent } from "../pageUtils"; import { setPageContent } from "../pageUtils";

View file

@ -1,4 +1,4 @@
import { Margin } from "../elements/Margin.js"; import { Margin } from "../elements/Margin";
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { changePage, setPageContent } from "../pageUtils"; import { changePage, setPageContent } from "../pageUtils";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";

View file

@ -1,5 +1,5 @@
import { Margin } from "../../elements/Margin.js"; import { Margin } from "../../elements/Margin";
import { MarginInline } from "../../elements/MarginInline.js"; import { MarginInline } from "../../elements/MarginInline";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { addNewTOTP } from "../../api/addNewTOTP"; import { addNewTOTP } from "../../api/addNewTOTP";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";

View file

@ -1,5 +1,5 @@
import { CopyableModal } from "../../elements/CopyableModal"; import { CopyableModal } from "../../elements/CopyableModal";
import { Margin } from "../../elements/Margin.js"; import { Margin } from "../../elements/Margin";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";

View file

@ -1,5 +1,5 @@
import { CopyableModal } from "../../elements/CopyableModal"; import { CopyableModal } from "../../elements/CopyableModal";
import { Margin } from "../../elements/Margin.js"; import { Margin } from "../../elements/Margin";
import { Page } from "../../types/Page"; import { Page } from "../../types/Page";
import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils"; import { changePage, setErrorText, setPageContent, setTitleElement } from "../../pageUtils";
import { makeElement } from "../../htmlUtils"; import { makeElement } from "../../htmlUtils";

View file

@ -1,4 +1,4 @@
import { MarginInline } from "../elements/MarginInline.js"; import { MarginInline } from "../elements/MarginInline";
import { Page } from "../types/Page"; import { Page } from "../types/Page";
import { QRScanner } from "../elements/QRScanner.js"; import { QRScanner } from "../elements/QRScanner.js";
import { changePage, setErrorText, setPageContent } from "../pageUtils"; import { changePage, setErrorText, setPageContent } from "../pageUtils";