Add basic prototype of frontend with twig
This commit is contained in:
parent
b5c97f7f8e
commit
f0d31654c9
|
@ -7,5 +7,8 @@
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_title": "Spectabular",
|
"default_title": "Spectabular",
|
||||||
"default_popup": "twig/browser-action.html"
|
"default_popup": "twig/browser-action.html"
|
||||||
}
|
},
|
||||||
|
"web_accessible_resources": [
|
||||||
|
"twig/*.html.twig"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import * as twig from "twig";
|
||||||
|
|
||||||
|
const MAIN_TEMPLATE_URI: string = chrome.runtime.getURL("twig/main.html.twig");
|
||||||
|
//Using async:false is fine here because we're just getting the resource from chrome, not a real remote.
|
||||||
|
//Using the `as any` cast here because the @types/twig package is out of date and requires `url` rather than `href`
|
||||||
|
const MAIN_TEMPLATE: twig.Template = twig.twig({href: MAIN_TEMPLATE_URI, async: false} as any);
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
chrome.tabs.query({}, (tabs: chrome.tabs.Tab[]) => {
|
||||||
|
document.querySelector("body").innerHTML = String(MAIN_TEMPLATE.render({tabs}));
|
||||||
|
});
|
||||||
|
});
|
1
src/twig/main.html.twig
Normal file
1
src/twig/main.html.twig
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{% include "tab-list.html.twig" %}
|
7
src/twig/tab-list.html.twig
Normal file
7
src/twig/tab-list.html.twig
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{% block tab_list %}
|
||||||
|
<ul id="tabs">
|
||||||
|
{% for tab in tabs %}
|
||||||
|
<li tab-id={{ tab.id }}>{{ tab.title }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
Loading…
Reference in a new issue