nixos-configs/modules/ags/gtk4/widget/subclasses/stack.ts
matt1432 e7accbd7bd
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags4): write own ConstructProps to exclude props
2025-01-15 18:17:27 -05:00

30 lines
845 B
TypeScript

import { register } from 'astal';
import { Gtk } from 'astal/gtk4';
import astalify, { type AstalifyProps, type ConstructProps } from '../astalify';
export type StackProps = ConstructProps<
StackClass,
Gtk.Stack.ConstructorProps & AstalifyProps
>;
@register({ GTypeName: 'Stack' })
export class StackClass extends astalify(Gtk.Stack) {
constructor({ cssName = 'stack', ...props }: StackProps = {}) {
super({ cssName, ...props });
}
setChildren(self: StackClass, children: Gtk.Widget[]) {
for (const child of children) {
if (child.name !== '' && child.name !== null) {
self.add_named(child, child.name);
}
else {
self.add_child(child);
}
}
}
}
export const Stack = (props?: StackProps) => new StackClass(props);