nixos-configs/nixosModules/ags/v2/widgets/applauncher/app-item.tsx

66 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-10-28 14:45:10 -04:00
import { Gtk, Widget } from 'astal/gtk3';
2024-10-18 00:44:45 -04:00
import { register } from 'astal/gobject';
/* Types */
2024-10-22 13:09:39 -04:00
import AstalApps from 'gi://AstalApps';
2024-10-18 00:44:45 -04:00
type AppItemProps = Widget.BoxProps & {
app: AstalApps.Application
};
@register()
export class AppItem extends Widget.Box {
readonly app: AstalApps.Application;
constructor({
app,
hexpand = true,
className = '',
...rest
}: AppItemProps) {
super({
...rest,
className: `app ${className}`,
hexpand,
});
this.app = app;
const icon = (
2024-10-28 14:45:10 -04:00
<icon
icon={this.app.iconName}
2024-10-28 14:45:10 -04:00
css="font-size: 42px; margin-right: 25px;"
/>
);
2024-10-18 00:44:45 -04:00
const textBox = (
<box
vertical
>
<label
className="title"
label={app.name}
xalign={0}
truncate
valign={Gtk.Align.CENTER}
/>
{app.description !== '' && (
<label
className="description"
label={app.description}
wrap
xalign={0}
justify={Gtk.Justification.LEFT}
valign={Gtk.Align.CENTER}
/>
)}
</box>
);
this.add(icon);
this.add(textBox);
}
}
export default AppItem;