refs #14080 Merge branch 'origin/14080-cwl-graphs'
[arvados-workbench2.git] / src / lib / cwl-svg / utils / dynamic-stylesheet.ts
1 import {Workflow} from "..";
2
3 export class DynamicStylesheet {
4     private styleElement: HTMLStyleElement;
5     private scopedSelector: string;
6     private innerStyle = "";
7
8     constructor(workflow: Workflow) {
9
10         this.styleElement      = document.createElement("style");
11         this.styleElement.type = "text/css";
12
13         this.scopedSelector = `svg.${workflow.svgID}`;
14
15         document.getElementsByTagName("head")[0].appendChild(this.styleElement);
16     }
17
18     remove() {
19         this.styleElement.remove();
20     }
21
22     set(style: string) {
23         this.innerStyle = style;
24
25         this.styleElement.innerHTML = `
26             ${this.scopedSelector} {
27                 ${this.innerStyle}
28             }
29         `
30     }
31
32
33
34
35 }