1
0
Fork 0

Make TransitViewSecret page look prettyer.

This commit is contained in:
Kitteh 2021-05-09 14:48:47 +01:00
parent ba3df3af78
commit c1ce81ba0d
2 changed files with 20 additions and 35 deletions

View file

@ -6,11 +6,10 @@ type optionsFunctionsObject = {
const optionsFunctions: optionsFunctionsObject = { const optionsFunctions: optionsFunctionsObject = {
"class": (e: Element, arg: string | string[]) => { "class": (e: Element, arg: string | string[]) => {
if (Array.isArray(arg)) { if (!Array.isArray(arg)) {
e.classList.add(...arg); arg = String(arg).split(" ");
} else {
e.classList.add(arg);
} }
e.classList.add(...arg);
}, },
"id": (e: Element, arg: string) => e.id = arg, "id": (e: Element, arg: string) => e.id = arg,
"html": (e: Element, arg: string) => e.innerHTML = arg, "html": (e: Element, arg: string) => e.innerHTML = arg,
@ -57,7 +56,7 @@ export function makeElement(elementInfo: ElementInfo): HTMLElement {
return element; return element;
} }
export function setElementAttributes(element: Element, attributes: {[propName: string]: any}): void { export function setElementAttributes(element: Element, attributes: { [propName: string]: any }): void {
for (const key of Object.getOwnPropertyNames(attributes)) { for (const key of Object.getOwnPropertyNames(attributes)) {
element.setAttribute(key, attributes[key]); element.setAttribute(key, attributes[key]);
} }

View file

@ -6,15 +6,6 @@ import i18next from 'i18next';
import { getTransitKey } from "../../api/transit/getTransitKey"; import { getTransitKey } from "../../api/transit/getTransitKey";
import { Tile } from "../../elements/Tile"; import { Tile } from "../../elements/Tile";
type TileParams = {
condition: Boolean;
title: string;
description: string;
icon: string;
iconText: string;
onclick: () => void;
}
export class TransitViewSecretPage extends Page { export class TransitViewSecretPage extends Page {
constructor() { constructor() {
super(); super();
@ -31,29 +22,24 @@ export class TransitViewSecretPage extends Page {
setPageContent(makeElement({ setPageContent(makeElement({
tag: "div", tag: "div",
class: ["uk-list", "uk-width-1-1@s"], class: "uk-child-width-1-1@s uk-child-width-1-2@m uk-grid-small uk-grid-match",
attributes: { "uk-grid": "" }, attributes: { "uk-grid": "" },
children: [ children: [
makeElement({ Tile({
tag: "div", condition: transitKey.supports_encryption,
children: [ title: i18next.t("transit_view_encrypt_text"),
Tile({ description: i18next.t("transit_view_encrypt_description"),
condition: transitKey.supports_encryption, icon: "lock",
title: i18next.t("transit_view_encrypt_text"), iconText: i18next.t("transit_view_encrypt_icon_text"),
description: i18next.t("transit_view_encrypt_description"), onclick: () => { changePage("TRANSIT_ENCRYPT"); }
icon: "lock", }),
iconText: i18next.t("transit_view_encrypt_icon_text"), Tile({
onclick: () => { changePage("TRANSIT_ENCRYPT"); } condition: transitKey.supports_decryption,
}), title: i18next.t("transit_view_decrypt_text"),
Tile({ description: i18next.t("transit_view_decrypt_description"),
condition: transitKey.supports_decryption, icon: "mail",
title: i18next.t("transit_view_decrypt_text"), iconText: i18next.t("transit_view_decrypt_icon_text"),
description: i18next.t("transit_view_decrypt_description"), onclick: () => { changePage("TRANSIT_DECRYPT"); }
icon: "mail",
iconText: i18next.t("transit_view_decrypt_icon_text"),
onclick: () => { changePage("TRANSIT_DECRYPT"); }
}),
]
}), }),
] ]
})); }));