Skip to content

Commit

Permalink
feat: confirmation alert added, closes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
theoomoregbee committed Jan 30, 2018
1 parent 3884ef2 commit 3241ec2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
[![npm](https://img.shields.io/npm/v/@theo4u/ng-alert.svg)](https://www.npmjs.com/package/@theo4u/ng-alert)
[![npm](https://img.shields.io/npm/l/express.svg)]()

This is a simple alert component, to help show different level of alerts and easy configurations on how you want it to act. Oh yea! easy to style to follow your own feel.
This is a simple alert component, to help show different level of alerts and easy configurations on how you want it to act. Also, supports confirmation alert. Oh yea! easy to style to follow your own feel.

![Error Message](/img/error.png)
![Info Message](/img/info.png)
![Warning Message](/img/warning.png)
![Success Message](/img/success.png)
![Confirm Message](/img/confirm.png)

## Installation
```sh
Expand Down Expand Up @@ -42,7 +43,12 @@ imports: [
export interface IMessage {
type: MessageType,
message: string,
title?: string
title?: string,
buttons?: Array<{
label: string,
action?: Function,
css?: string
}>
}
```
`type` can be `MessageType.info`, `MessageType.success`, `MessageType.error` or `MessageType.warning`
Expand Down Expand Up @@ -70,6 +76,13 @@ From any location withing your app, just push the new messages with `NgAlertServ
import { NgAlertService, IMessage, MessageType, CloseType } from '@theo4u/ng-alert';
```

## Confirmation Alert
It can also serve as a confirmation alert, if `buttons` properties of `IMessage` is passed in, which is an array
* **label**: the text to show for your button
* **action**: the action to perform when the button is clicked
* **css**: your custom css to pass in, since its just a plain `<button></button>`


## Example Usage
Check [app.component.ts](./src/app/app.component.ts)

Expand Down
Binary file added img/confirm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class AppComponent implements OnInit, OnDestroy {
label: 'Continue',
css: 'continue',
action: () => {
alert('something happened');
console.log('someting about me');
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/app/modules/ng-alert/ng-alert.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';

export enum MessageType {
success = 'success',
error = 'error',
info = 'info',
warning = 'warning'
error = 'error',
info = 'info',
warning = 'warning'
}

export interface IMessage {
type: MessageType;
message: string;
title?: string;
buttons?: Array<{
label: string,
action?: Function,
css?: string
}>;
buttons?: Array<{
label: string,
action?: Function,
css?: string
}>;
}

export enum CloseType {
Expand Down

0 comments on commit 3241ec2

Please sign in to comment.