summaryrefslogtreecommitdiff
path: root/src/modules/launcher/util.tsx
blob: 8288588fc00656b710da539fce26676b8e21d25b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { FlowBox } from "@/utils/widgets";
import type { Variable } from "astal";
import { App, Gtk } from "astal/gtk3";

export type Mode = "apps" | "files" | "math";

export interface LauncherContent {
    updateContent(search: string): void;
    handleActivate(search: string): void;
}

export const close = () => App.get_window("launcher")?.hide();

export const limitLength = <T,>(arr: T[], cfg: { maxResults: Variable<number> }) =>
    cfg.maxResults.get() > 0 && arr.length > cfg.maxResults.get() ? arr.slice(0, cfg.maxResults.get()) : arr;

export const ContentBox = () => (
    <FlowBox homogeneous valign={Gtk.Align.START} minChildrenPerLine={2} maxChildrenPerLine={2} />
);