aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Notification/options.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Notification/options.ts')
-rw-r--r--src/lib/Notification/options.ts19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/Notification/options.ts b/src/lib/Notification/options.ts
new file mode 100644
index 00000000..f14e0d25
--- /dev/null
+++ b/src/lib/Notification/options.ts
@@ -0,0 +1,19 @@
+type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
+
+interface Options {
+ heading: string | number;
+ description: string | number | undefined;
+ position: Position;
+ duration: number;
+ id: string;
+}
+
+export const options = (preferences: { [key: string]: number | string }): Options => {
+ return {
+ position: (preferences.position || 'top-right') as Position,
+ duration: Number(preferences.duration || 3000),
+ heading: preferences.heading || 'Notification',
+ description: preferences.description || undefined,
+ id: Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
+ };
+};