From 779ec440e209b01d3a44f9377af78653d197fdc8 Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 7 Nov 2024 02:40:47 +0000 Subject: example: applauncher --- examples/js/applauncher/widget/Applauncher.tsx | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 examples/js/applauncher/widget/Applauncher.tsx (limited to 'examples/js/applauncher/widget/Applauncher.tsx') diff --git a/examples/js/applauncher/widget/Applauncher.tsx b/examples/js/applauncher/widget/Applauncher.tsx new file mode 100644 index 0000000..d92b5e3 --- /dev/null +++ b/examples/js/applauncher/widget/Applauncher.tsx @@ -0,0 +1,73 @@ +import Apps from "gi://AstalApps" +import { App, Astal, Gdk, Gtk } from "astal/gtk3" +import { Variable } from "astal" + +const MAX_ITEMS = 8 + +function AppButton({ app }: { app: Apps.Application }) { + return +} + +export default function Applauncher() { + const apps = new Apps.Apps() + const list = Variable(apps.get_list().slice(0, MAX_ITEMS)) + const hide = () => App.get_window("launcher")!.hide() + + function search(text: string) { + list.set(apps.fuzzy_query(text).slice(0, MAX_ITEMS)) + } + + return list.set(apps.get_list().slice(0, MAX_ITEMS))} + onKeyPressEvent={function (self, event: Gdk.Event) { + if (event.get_keyval()[1] === Gdk.KEY_Escape) + self.hide() + }}> + + + + + + search(text)} + /> + + {list(list => list.map(app => ( + + )))} + + l.length === 0)}> + + No match found + + + + + + + +} -- cgit v1.2.3