Files
custum-hyprpanel/src/components/settings/shared/inputs/image.tsx
Jas Singh 5f72b4f5e1 Workspaces now show up on their appropriate monitors. (#681)
* Workspaces now show up on their appropriate monitors.

* Fixed undefined rules showing up.
2024-12-31 01:33:40 -08:00

36 lines
919 B
TypeScript

import { Gtk } from 'astal/gtk3';
import FileChooserButton from 'src/components/shared/FileChooserButton';
import { Opt } from 'src/lib/option';
const handleFileSet =
<T,>(opt: Opt<T>) =>
(self: Gtk.FileChooserButton): void => {
const uri = self.get_uri();
if (!uri) {
return;
}
try {
const decodedPath = decodeURIComponent(uri.replace('file://', ''));
opt.set(decodedPath as unknown as T);
} catch (error) {
console.error('Failed to decode URI:', error);
}
};
export const ImageInputter = <T extends string | number | boolean | object>({
opt,
}: ImageInputterProps<T>): JSX.Element => {
return (
<FileChooserButton
on_file_set={(self) => {
return handleFileSet(opt)(self);
}}
/>
);
};
interface ImageInputterProps<T> {
opt: Opt<T>;
}