mirror of
https://github.com/hay-kot/homebox.git
synced 2025-06-27 14:18:35 +00:00
frontend: cleanup
* dummy commit * cleanup workflows * setup and run eslint * add linter to CI * use eslint for formatting * reorder rules * drop editor config
This commit is contained in:
parent
78fa714297
commit
75c633dcb5
65 changed files with 2048 additions and 641 deletions
|
@ -1,57 +1,55 @@
|
|||
import { useId } from './use-ids';
|
||||
import { useId } from "./use-ids";
|
||||
|
||||
interface Notification {
|
||||
id: string;
|
||||
message: string;
|
||||
type: 'success' | 'error' | 'info';
|
||||
id: string;
|
||||
message: string;
|
||||
type: "success" | "error" | "info";
|
||||
}
|
||||
|
||||
const notifications = ref<Notification[]>([]);
|
||||
|
||||
function addNotification(notification: Notification) {
|
||||
notifications.value.unshift(notification);
|
||||
notifications.value.unshift(notification);
|
||||
|
||||
if (notifications.value.length > 4) {
|
||||
notifications.value.pop();
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
// Remove notification with ID
|
||||
notifications.value = notifications.value.filter(
|
||||
n => n.id !== notification.id
|
||||
);
|
||||
}, 5000);
|
||||
}
|
||||
if (notifications.value.length > 4) {
|
||||
notifications.value.pop();
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
// Remove notification with ID
|
||||
notifications.value = notifications.value.filter(n => n.id !== notification.id);
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
export function useNotifications() {
|
||||
return {
|
||||
notifications,
|
||||
dropNotification: (idx: number) => notifications.value.splice(idx, 1),
|
||||
};
|
||||
return {
|
||||
notifications,
|
||||
dropNotification: (idx: number) => notifications.value.splice(idx, 1),
|
||||
};
|
||||
}
|
||||
|
||||
export function useNotifier() {
|
||||
return {
|
||||
success: (message: string) => {
|
||||
addNotification({
|
||||
id: useId(),
|
||||
message,
|
||||
type: 'success',
|
||||
});
|
||||
},
|
||||
error: (message: string) => {
|
||||
addNotification({
|
||||
id: useId(),
|
||||
message,
|
||||
type: 'error',
|
||||
});
|
||||
},
|
||||
info: (message: string) => {
|
||||
addNotification({
|
||||
id: useId(),
|
||||
message,
|
||||
type: 'info',
|
||||
});
|
||||
},
|
||||
};
|
||||
return {
|
||||
success: (message: string) => {
|
||||
addNotification({
|
||||
id: useId(),
|
||||
message,
|
||||
type: "success",
|
||||
});
|
||||
},
|
||||
error: (message: string) => {
|
||||
addNotification({
|
||||
id: useId(),
|
||||
message,
|
||||
type: "error",
|
||||
});
|
||||
},
|
||||
info: (message: string) => {
|
||||
addNotification({
|
||||
id: useId(),
|
||||
message,
|
||||
type: "info",
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue