From 08f607cb8bb0014eaba4633e01fc62339ec22e90 Mon Sep 17 00:00:00 2001 From: Deividas Bakanas Date: Tue, 15 Dec 2015 21:05:00 +0200 Subject: [PATCH 1/3] Definition file added --- .../react-notification-system.d.ts | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 react-notification-system/react-notification-system.d.ts diff --git a/react-notification-system/react-notification-system.d.ts b/react-notification-system/react-notification-system.d.ts new file mode 100644 index 0000000000..52a5d7d988 --- /dev/null +++ b/react-notification-system/react-notification-system.d.ts @@ -0,0 +1,89 @@ +// Type definitions for React Notification System v0.2.6 +// Project: https://www.npmjs.com/package/react-notification-system +// Definitions by: Giedrius Grabauskas , Deividas Bakanas +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module NotificationSystem { + + import React = __React; + + export interface System extends React.Component { + addNotification(notification: Notification): Notification; + removeNotification(notification: Notification): void; + removeNotification(uid: string): void; + } + + export interface CallBackFunction { + (notification: Notification): void; + } + + export interface Notification { + title?: string; + message?: string; + level?: string; + position?: string; + autoDismiss?: number; + dismissible?: boolean; + action?: ActionObject; + onAdd?: CallBackFunction; + onRemove?: CallBackFunction; + uid?: number | string; + } + + export interface ActionObject { + label: string; + callback?: Function; + } + + export interface ContainersStyle { + DefaultStyle: React.CSSProperties; + tl?: React.CSSProperties; + tr?: React.CSSProperties; + tc?: React.CSSProperties; + bl?: React.CSSProperties; + br?: React.CSSProperties; + bc?: React.CSSProperties; + } + + export interface ItemStyle { + DefaultStyle?: React.CSSProperties; + success?: React.CSSProperties; + error?: React.CSSProperties; + warning?: React.CSSProperties; + info?: React.CSSProperties; + } + + export interface WrapperStyle { + DefaultStyle?: React.CSSProperties; + } + + export interface Style { + Wrapper?: any; + Containers?: ContainersStyle; + NotificationItem?: ItemStyle; + Title?: ItemStyle; + MessageWrapper?: WrapperStyle; + Dismiss?: ItemStyle; + Action?: ItemStyle; + ActionWrapper?: WrapperStyle; + } + + export interface Attributes { + noAnimation?: boolean; + ref?: string; + style?: Style | boolean; + } + + + export interface Component { + (): React.ReactElement; + } +} + + +declare module 'react-notification-system' { + var component: NotificationSystem.Component; + export = component; +} From 13a6bf3c0f418dadec4bc4db85866b83ee817636 Mon Sep 17 00:00:00 2001 From: Deividas Bakanas Date: Tue, 15 Dec 2015 21:05:47 +0200 Subject: [PATCH 2/3] Test file added --- .../react-notification-system-test.ts | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 react-notification-system/react-notification-system-test.ts diff --git a/react-notification-system/react-notification-system-test.ts b/react-notification-system/react-notification-system-test.ts new file mode 100644 index 0000000000..07cd8ff2c9 --- /dev/null +++ b/react-notification-system/react-notification-system-test.ts @@ -0,0 +1,62 @@ +/// +/// + +import React = require('react'); +import NotificationSystem = require('react-notification-system'); + + +class MyComponent extends React.Component { + private notificationSystem: NotificationSystem.System = null; + + private notification: NotificationSystem.Notification = { + message: 'Notification message', + level: 'success', + action: { + label: "Button inside this notification", + callback: () => { + this.notificationSystem.removeNotification(this.notification); + } + } + }; + + private addNotification() { + this.notification = this.notificationSystem.addNotification(this.notification); + } + + componentDidMount() { + this.notificationSystem = this.refs['notificationSystem'] as NotificationSystem.System; + this.addNotification(); + } + + render() { + + var style = { + NotificationItem: { // Override the notification item + DefaultStyle: { // Applied to every notification, regardless of the notification level + margin: '10px 5px 2px 1px' + }, + + success: { // Applied only to the success notification item + color: 'red' + } + } + }; + + var attributes: NotificationSystem.Attributes = { + style: { + Containers: { + DefaultStyle: { + margin: '10px 5px 2px 1px' + } + }, + Title: { + success: { + color: 'green' + } + } + } + }; + + return React.createElement(NotificationSystem, { title: "NotificationTitile", style: style, } as NotificationSystem.Attributes); + } +} From acce45cb00a565e797d822f8509b742a26dd72c7 Mon Sep 17 00:00:00 2001 From: Deividas Bakanas Date: Sun, 27 Dec 2015 01:35:59 +0200 Subject: [PATCH 3/3] File renamed react-notification-system-test.ts changed to react-notification-system-tests.ts --- ...fication-system-test.ts => react-notification-system-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename react-notification-system/{react-notification-system-test.ts => react-notification-system-tests.ts} (100%) diff --git a/react-notification-system/react-notification-system-test.ts b/react-notification-system/react-notification-system-tests.ts similarity index 100% rename from react-notification-system/react-notification-system-test.ts rename to react-notification-system/react-notification-system-tests.ts