aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Notification/options.ts
blob: 3ccb20b92c6742077ea140b27cb38c95db52faab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';

export 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)
  };
};