diff options
author | kotontrion <[email protected]> | 2024-11-16 12:40:07 +0100 |
---|---|---|
committer | kotontrion <[email protected]> | 2024-11-16 12:40:07 +0100 |
commit | 1351db8d5b80c7521e808f81c91977a5dd2d9d34 (patch) | |
tree | a1469ed4aaca0f1f42e6d9a9251f5ccc9ff8bf78 /examples | |
parent | e674e8f6e49e74edde795e012adbfe0fcfd8d729 (diff) | |
parent | 433984c5830aac3fcde66ffff93d0dc7e5e69366 (diff) |
Merge branch 'main' into feat/tray-gtk4
Diffstat (limited to 'examples')
-rw-r--r-- | examples/js/applauncher/widget/Applauncher.scss | 14 | ||||
-rw-r--r-- | examples/js/applauncher/widget/Applauncher.tsx | 34 | ||||
-rw-r--r-- | examples/js/simple-bar/README.md | 1 | ||||
-rw-r--r-- | examples/lua/simple-bar/README.md | 1 | ||||
-rw-r--r-- | examples/py/simple-bar/README.md | 1 | ||||
-rw-r--r-- | examples/vala/simple-bar/README.md | 1 |
6 files changed, 38 insertions, 14 deletions
diff --git a/examples/js/applauncher/widget/Applauncher.scss b/examples/js/applauncher/widget/Applauncher.scss index 86c5e87..ae2453d 100644 --- a/examples/js/applauncher/widget/Applauncher.scss +++ b/examples/js/applauncher/widget/Applauncher.scss @@ -41,5 +41,19 @@ window#launcher { color: gtkalpha($fg-color, .8); } } + + box.not-found { + padding: 1rem; + + icon { + font-size: 6em; + color: gtkalpha($fg-color, .7); + } + + label { + color: gtkalpha($fg-color, .9); + font-size: 1.2em; + } + } } } diff --git a/examples/js/applauncher/widget/Applauncher.tsx b/examples/js/applauncher/widget/Applauncher.tsx index d92b5e3..c7bac68 100644 --- a/examples/js/applauncher/widget/Applauncher.tsx +++ b/examples/js/applauncher/widget/Applauncher.tsx @@ -4,8 +4,14 @@ import { Variable } from "astal" const MAX_ITEMS = 8 +function hide() { + App.get_window("launcher")!.hide() +} + function AppButton({ app }: { app: Apps.Application }) { - return <button className="AppButton" onClicked={() => app.launch()}> + return <button + className="AppButton" + onClicked={() => { hide(); app.launch() }}> <box> <icon icon={app.iconName} /> <box valign={Gtk.Align.CENTER} vertical> @@ -27,12 +33,14 @@ function AppButton({ app }: { app: Apps.Application }) { } export default function Applauncher() { + const { CENTER } = Gtk.Align 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)) + const text = Variable("") + const list = text(text => apps.fuzzy_query(text).slice(0, MAX_ITEMS)) + const onEnter = () => { + apps.fuzzy_query(text.get())?.[0].launch() + hide() } return <window @@ -41,7 +49,7 @@ export default function Applauncher() { exclusivity={Astal.Exclusivity.IGNORE} keymode={Astal.Keymode.ON_DEMAND} application={App} - onShow={() => list.set(apps.get_list().slice(0, MAX_ITEMS))} + onShow={() => text.set("")} onKeyPressEvent={function (self, event: Gdk.Event) { if (event.get_keyval()[1] === Gdk.KEY_Escape) self.hide() @@ -53,16 +61,22 @@ export default function Applauncher() { <box widthRequest={500} className="Applauncher" vertical> <entry placeholderText="Search" - onChanged={({ text }) => search(text)} + text={text()} + onChanged={self => text.set(self.text)} + onActivate={onEnter} /> <box spacing={6} vertical> - {list(list => list.map(app => ( + {list.as(list => list.map(app => ( <AppButton app={app} /> )))} </box> - <box visible={list(l => l.length === 0)}> + <box + halign={CENTER} + className="not-found" + vertical + visible={list.as(l => l.length === 0)}> <icon icon="system-search-symbolic" /> - No match found + <label label="No match found" /> </box> </box> <eventbox expand onClick={hide} /> diff --git a/examples/js/simple-bar/README.md b/examples/js/simple-bar/README.md index 6488d14..f92b20e 100644 --- a/examples/js/simple-bar/README.md +++ b/examples/js/simple-bar/README.md @@ -4,7 +4,6 @@ A simple bar for Hyprland using -- [Audio library](https://aylur.github.io/astal/guide/libraries/audio). - [Battery library](https://aylur.github.io/astal/guide/libraries/battery). - [Hyprland library](https://aylur.github.io/astal/guide/libraries/hyprland). - [Mpris library](https://aylur.github.io/astal/guide/libraries/mpris). diff --git a/examples/lua/simple-bar/README.md b/examples/lua/simple-bar/README.md index bcc6bba..48cc27c 100644 --- a/examples/lua/simple-bar/README.md +++ b/examples/lua/simple-bar/README.md @@ -4,7 +4,6 @@ A simple bar for Hyprland using -- [Audio library](https://aylur.github.io/astal/guide/libraries/audio). - [Battery library](https://aylur.github.io/astal/guide/libraries/battery). - [Hyprland library](https://aylur.github.io/astal/guide/libraries/hyprland). - [Mpris library](https://aylur.github.io/astal/guide/libraries/mpris). diff --git a/examples/py/simple-bar/README.md b/examples/py/simple-bar/README.md index bcc6bba..48cc27c 100644 --- a/examples/py/simple-bar/README.md +++ b/examples/py/simple-bar/README.md @@ -4,7 +4,6 @@ A simple bar for Hyprland using -- [Audio library](https://aylur.github.io/astal/guide/libraries/audio). - [Battery library](https://aylur.github.io/astal/guide/libraries/battery). - [Hyprland library](https://aylur.github.io/astal/guide/libraries/hyprland). - [Mpris library](https://aylur.github.io/astal/guide/libraries/mpris). diff --git a/examples/vala/simple-bar/README.md b/examples/vala/simple-bar/README.md index bcc6bba..48cc27c 100644 --- a/examples/vala/simple-bar/README.md +++ b/examples/vala/simple-bar/README.md @@ -4,7 +4,6 @@ A simple bar for Hyprland using -- [Audio library](https://aylur.github.io/astal/guide/libraries/audio). - [Battery library](https://aylur.github.io/astal/guide/libraries/battery). - [Hyprland library](https://aylur.github.io/astal/guide/libraries/hyprland). - [Mpris library](https://aylur.github.io/astal/guide/libraries/mpris). |