Skip to content

Commit d66abac

Browse files
authored
Merge pull request #23 from kuanyui/master
Add type definitions for TypeScript.
2 parents 622e5fb + 6dd4ae1 commit d66abac

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

index.d.ts

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
declare module 'node-snackbar' {
2+
export = Snackbar
3+
}
4+
5+
declare namespace Snackbar {
6+
function show (options: SnackbarOptions): void
7+
}
8+
9+
interface SnackbarOptions {
10+
/** The text to displae inside the notification. (default: null) */
11+
text?: string
12+
/** Text color of the notification text. (default: '#FFFFFF') */
13+
textColor?: string
14+
/** The position the notification will show. Refer to the examples above for possible positions. (default: bottom-left) */
15+
pos?: 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-left' | 'top-center' | 'top-right'
16+
/** Add a custom class to the notification for custom styling. (default: null) */
17+
customClass?: string
18+
/**
19+
* Width of the notification. Used to shrink/expand window as you wish.
20+
* Accepted value is same as HTMLElement.style.width
21+
* (default: 'auto')
22+
*/
23+
width?: string
24+
/** to show the action buton or not. (default: true) */
25+
showAction?: boolean
26+
/** Text to display as the action button. (default: 'Dismiss') */
27+
actionText?: string
28+
/** Text color of the action button. (default: '#4CAF50') */
29+
actionTextColor?: string
30+
/** Background color of the notification window. (default: '#323232') */
31+
backgroundColor?: string
32+
/**
33+
* Time in milliseconds the notification is displayed before fading out.
34+
* Passing 0 or null as value will cause the notification to be permanent until dismissed by clicking the button.
35+
* (default: 5000)
36+
*/
37+
duration?: number
38+
/** Default action closes the notification. */
39+
onActionClick?: (element: HTMLElement) => void
40+
/** Event fired when the notification has closed. */
41+
onClose?: (element: HTMLElement) => void
42+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.14",
44
"description": "Notifications insipired by Google Material Design",
55
"main": "src/js/snackbar.js",
6+
"types": "index.d.ts",
67
"devDependencies": {
78
"grunt": "^0.4.5",
89
"grunt-contrib-clean": "^0.7.0",

0 commit comments

Comments
 (0)