Files
t/ts/main.ts

71 lines
1.8 KiB
TypeScript
Raw Permalink Normal View History

import { addStyleNow, awaitLoaded } from "./document";
2024-12-21 07:26:27 -08:00
import { ElemWrapper } from "./elemwrapper";
2024-12-22 14:59:03 -08:00
import { Highlighter } from "./highlighter";
2024-12-22 10:23:37 -08:00
import { SLCard } from "./slcard";
2024-12-21 21:49:43 -08:00
import { SLIcon } from "./slicon";
2024-12-22 10:23:37 -08:00
import { SLInput } from "./slinput";
2024-12-21 21:42:54 -08:00
import { SLTabGroup } from "./sltabgroup";
2024-12-21 07:17:19 -08:00
2024-12-21 07:26:27 -08:00
async function main() {
2024-12-21 07:17:19 -08:00
const root = new ElemWrapper(document.body);
2024-12-22 16:52:01 -08:00
root.style.fontSize = "12px";
root.style.fontFamily = "var(--sl-font-mono)";
root.style.display = "flex";
root.style.flexDirection = "column";
root.style.alignItems = "center";
2024-12-21 07:17:19 -08:00
2024-12-21 21:42:54 -08:00
const tabGroup = new SLTabGroup();
root.append(tabGroup);
2024-12-21 07:17:19 -08:00
2024-12-21 21:42:54 -08:00
const [tasksTab, tasksPanel] = tabGroup.addTabSet("tasks");
2024-12-22 16:52:01 -08:00
const tasksIcon = new SLIcon("list-task");
tasksIcon.style.fontSize = "20px";
tasksTab.append(tasksIcon);
2024-12-22 10:23:37 -08:00
const tasksCard = new SLCard();
tasksPanel.append(tasksCard);
const tasksInput = new SLInput();
tasksCard.append(tasksInput);
tasksInput.setPill();
2024-12-22 14:59:03 -08:00
2024-12-22 10:23:37 -08:00
const tasksAddIcon = tasksInput.addSuffixIcon("plus-circle");
2024-12-22 14:59:03 -08:00
const highlighter = new Highlighter(tasksAddIcon);
2024-12-22 16:52:01 -08:00
tasksAddIcon.style.cursor = "pointer";
2024-12-22 10:23:37 -08:00
const addTask = () => {
const task = tasksInput.getValue();
if (task.length === 0) {
return;
}
tasksInput.clear();
tasksInput.focus();
2024-12-22 14:59:03 -08:00
highlighter.highlight();
2024-12-22 10:23:37 -08:00
};
tasksAddIcon.addEventListener("click", () => {
addTask();
});
tasksInput.addEventListener("keydown", (e) => {
if ((e as KeyboardEvent).key === "Enter") {
addTask();
}
});
2024-12-21 07:17:19 -08:00
2024-12-21 21:42:54 -08:00
const [tagsTab, tagsPanel] = tabGroup.addTabSet("tags");
2024-12-22 16:52:01 -08:00
const tagsIcon = new SLIcon("tags");
tagsIcon.style.fontSize = "20px";
tagsTab.append(tagsIcon);
}
addStyleNow(`
:not(:defined) {
visibility: hidden;
2024-12-21 21:42:54 -08:00
}
2024-12-22 16:52:01 -08:00
`);
2024-12-21 06:35:49 -08:00
await awaitLoaded();
await main();