Create use-arm-toast hook for themed notifications
cgen-8a837bccec404388a3778501c434a68f
This commit is contained in:
parent
d06b8656be
commit
70e5dc34ae
1 changed files with 60 additions and 0 deletions
60
client/hooks/use-arm-toast.ts
Normal file
60
client/hooks/use-arm-toast.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { useArmTheme } from "@/contexts/ArmThemeContext";
|
||||
import { aethexToast } from "@/lib/aethex-toast";
|
||||
|
||||
interface ArmToastOptions {
|
||||
title?: string;
|
||||
description?: string;
|
||||
duration?: number;
|
||||
}
|
||||
|
||||
export function useArmToast() {
|
||||
const { theme } = useArmTheme();
|
||||
|
||||
return {
|
||||
/**
|
||||
* Show a toast with the current arm's accent color
|
||||
*/
|
||||
show: (options: ArmToastOptions) => {
|
||||
return aethexToast.arm({
|
||||
...options,
|
||||
accentColor: theme.accentHex,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a success toast with the current arm's accent color
|
||||
*/
|
||||
success: (options: ArmToastOptions) => {
|
||||
return aethexToast.arm({
|
||||
title: options.title || "Success",
|
||||
description: options.description,
|
||||
duration: options.duration || 5000,
|
||||
accentColor: theme.accentHex,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Show an error toast with the current arm's accent color
|
||||
*/
|
||||
error: (options: ArmToastOptions) => {
|
||||
return aethexToast.arm({
|
||||
title: options.title || "Error",
|
||||
description: options.description,
|
||||
duration: options.duration || 5000,
|
||||
accentColor: theme.accentHex,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Show a warning toast with the current arm's accent color
|
||||
*/
|
||||
warning: (options: ArmToastOptions) => {
|
||||
return aethexToast.arm({
|
||||
title: options.title || "Warning",
|
||||
description: options.description,
|
||||
duration: options.duration || 5000,
|
||||
accentColor: theme.accentHex,
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue