mapcomplete/UI/Base/Img.ts

20 lines
495 B
TypeScript
Raw Normal View History

2021-01-06 01:21:50 +00:00
import Constants from "../../Models/Constants";
import {Utils} from "../../Utils";
2021-01-02 23:19:42 +00:00
export default class Img {
2020-11-06 02:17:27 +00:00
public static runningFromConsole = false;
2020-11-05 11:28:02 +00:00
static AsData(source:string){
2021-01-06 01:21:50 +00:00
if(Utils.runningFromConsole){
2020-11-06 02:17:27 +00:00
return source;
}
2020-11-05 11:28:02 +00:00
return `data:image/svg+xml;base64,${(btoa(source))}`;
}
2021-01-21 22:39:31 +00:00
static AsImageElement(source: string, css_class: string = ""): string{
return `<img class="${css_class}" alt="" src="${Img.AsData(source)}">`;
2020-11-05 11:28:02 +00:00
}
}