Added strict type checking to the project. (#236)

* Implement strict typing (WIP).

* changes

* Finish type checks

* Fix notification icon, matugen settings and update tsconfig.

* OSD Styling updates and added the ability to configure OSD duration.
This commit is contained in:
Jas Singh
2024-09-09 00:44:51 -07:00
committed by GitHub
parent 41dbc3829a
commit bb3b3dfdfb
56 changed files with 468 additions and 240 deletions

View File

@@ -1,3 +1,5 @@
import { WINDOW_LAYOUTS } from "globals/window";
import { LayoutFunction, Layouts, PopupWindowProps } from "lib/types/popupwindow";
import { Exclusivity, Transition } from "lib/types/widget";
type Opts = {
@@ -32,7 +34,7 @@ const PopupRevealer = (name: string, child: any, transition = "slide_down" as Tr
}),
);
const Layout = (name: string, child: any, transition: Transition) => ({
const Layout: LayoutFunction = (name: string, child: any, transition: Transition) => ({
center: () =>
Widget.CenterBox(
{},
@@ -150,6 +152,10 @@ const Layout = (name: string, child: any, transition: Transition) => ({
),
});
const isValidLayout = (layout: string): layout is Layouts => {
return WINDOW_LAYOUTS.includes(layout);
};
export default ({
name,
child,
@@ -157,8 +163,12 @@ export default ({
transition,
exclusivity = "ignore" as Exclusivity,
...props
}) =>
Widget.Window({
}: PopupWindowProps) => {
const layoutFn = isValidLayout(layout) ? layout : "center";
const layoutWidget = Layout(name, child, transition)[layoutFn]();
return Widget.Window({
name,
class_names: [name, "popup-window"],
setup: (w) => w.keybind("Escape", () => App.closeWindow(name)),
@@ -167,6 +177,7 @@ export default ({
exclusivity,
layer: "top",
anchor: ["top", "bottom", "right", "left"],
child: Layout(name, child, transition)[layout](),
child: layoutWidget,
...props,
});
}