Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "always"
},
"source.fixAll.eslint": "always"
},
"js/ts.tsdk.path": "node_modules/typescript/lib"
}
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) Scott Cooper <scttcper@gmail.com>
Copyright (c) OpenNG contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
110 changes: 50 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<div align="center">
<img src="https://raw.githubusercontent.com/scttcper/ngx-toastr/master/misc/documentation-assets/ngx-toastr-example.png" width="300" alt="Angular Toastr">
<img src="https://raw.githubusercontent.com/openng-org/ngx-toastr/master/misc/documentation-assets/ngx-toastr-example.png" width="300" alt="Angular Toastr">
<br>
<h1>ngx-toastr</h1>
<h1>@openng/ngx-toastr</h1>
<br>
<a href="https://www.npmjs.org/package/ngx-toastr">
<img src="https://badge.fury.io/js/ngx-toastr.svg" alt="npm">
<a href="https://www.npmjs.com/package/@openng/ngx-toastr">
<img src="https://badge.fury.io/js/%40openng%2Fngx-toastr.svg" alt="npm">
</a>
<a href="https://codecov.io/github/scttcper/ngx-toastr">
<img src="https://img.shields.io/codecov/c/github/scttcper/ngx-toastr.svg" alt="codecov">
<a href="https://codecov.io/github/openng-org/ngx-toastr">
<img src="https://img.shields.io/codecov/c/github/openng-org/ngx-toastr.svg" alt="codecov">
</a>
<br>
<br>
</div>

DEMO: https://ngx-toastr.vercel.app
DEMO: <https://ngx-toastr.vercel.app>

> [!NOTE]
> `@openng/ngx-toastr` is an OpenNG-maintained fork of the original
> [`ngx-toastr`](https://github.com/scttcper/ngx-toastr) project.

## Features

Expand All @@ -22,63 +26,58 @@ DEMO: https://ngx-toastr.vercel.app
- No use of `@angular/animations`
- AoT compilation and lazy loading compatible
- Component inheritance for custom toasts
- SystemJS/UMD rollup bundle
- Output toasts to an optional target directive

## Dependencies

Latest version available for each version of Angular
Latest version available for each version of Angular:

| `@openng/ngx-toastr` | Angular |
|----------------------|---------|
| 1.x | 21.x |

| ngx-toastr | Angular |
| --------------- | --------------- |
| 13.2.1 | 10.x 11.x |
| 14.3.0 | 12.x 13.x |
| 15.2.2 | 14.x. |
| 16.2.0 | 15.x |
| 17.0.2 | 16.x |
| 18.x 19x | >= 17.x < 23.x |
| current | >= 20.x |
(For older versions, see the original `ngx-toastr`.)

## Install

```bash
npm install ngx-toastr --save
npm install @openng/ngx-toastr --save
```

## Setup

**step 1:** add css

- copy
[toast css](/src/lib/toastr.css)
[toast css](https://github.com/openng-org/ngx-toastr/blob/master/projects/ngx-toastr/src/lib/toastr.css)
to your project.
- If you are using sass you can import the css.

```scss
// regular style toast
@import 'ngx-toastr/toastr';
@import '@openng/ngx-toastr/toastr';

// bootstrap style toast
// or import a bootstrap 4 alert styled design (SASS ONLY)
// should be after your bootstrap imports, it uses bs4 variables, mixins, functions
@import 'ngx-toastr/toastr-bs4-alert';
@import '@openng/ngx-toastr/toastr-bs4-alert';

// if you'd like to use it without importing all of bootstrap it requires
@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';
@import 'bootstrap/scss/mixins';
// bootstrap 4
@import 'ngx-toastr/toastr-bs4-alert';
@import '@openng/ngx-toastr/toastr-bs4-alert';
// boostrap 5
@import 'ngx-toastr/toastr-bs5-alert';
@import '@openng/ngx-toastr/toastr-bs5-alert';
```

- If you are using angular-cli you can add it to your angular.json

```ts
"styles": [
"styles.scss",
"node_modules/ngx-toastr/toastr.css" // try adding '../' if you're using angular cli before 6
"node_modules/@openng/ngx-toastr/toastr.css"
]
```

Expand All @@ -87,7 +86,7 @@ npm install ngx-toastr --save
- Module based

```typescript
import { ToastrModule } from 'ngx-toastr';
import { ToastrModule } from '@openng/ngx-toastr';

@NgModule({
imports: [
Expand All @@ -103,7 +102,7 @@ class MainModule {}

```typescript
import { AppComponent } from './src/app.component';
import { provideToastr } from 'ngx-toastr';
import { provideToastr } from '@openng/ngx-toastr';

bootstrapApplication(AppComponent, {
providers: [
Expand All @@ -115,7 +114,7 @@ bootstrapApplication(AppComponent, {
## Use

```typescript
import { ToastrService } from 'ngx-toastr';
import { ToastrService } from '@openng/ngx-toastr';
import { inject } from '@angular/core';

@Component({...})
Expand All @@ -136,7 +135,7 @@ There are **individual options** and **global options**.

Passed to `ToastrService.success/error/warning/info/show()`

| Option | Type | Default | Description
| Option | Type | Default | Description |
| ----------------- | ------------------------------ | ------------------------------ | ------------------------------------------------- |
| toastComponent | Component | Toast | Angular component that will be used |
| closeButton | boolean | false | Show close button |
Expand Down Expand Up @@ -173,7 +172,7 @@ All [individual options](#individual-options) can be overridden in the global
options to affect all toasts. In addition, global options include the following
options:

| Option | Type | Default | Description |
| Option | Type | Default | Description |
| ----------------------- | ------- | ---------------------------------- | ------------------------------------------------------------------ |
| maxOpened | number | 0 | Max toasts opened. Toasts will be queued. 0 is unlimited |
| autoDismiss | boolean | false | Dismiss current toast when max is reached |
Expand Down Expand Up @@ -215,7 +214,7 @@ imports: [

```typescript
import { AppComponent } from './src/app.component';
import { provideToastr } from 'ngx-toastr';
import { provideToastr } from '@openng/ngx-toastr';

bootstrapApplication(AppComponent, {
providers: [
Expand All @@ -228,8 +227,7 @@ bootstrapApplication(AppComponent, {
});
```


### Toastr Service methods return:
### Toastr Service methods return

```typescript
export interface ActiveToast {
Expand Down Expand Up @@ -264,7 +262,7 @@ the container it is announced by screen readers.

```typescript
import { NgModule } from '@angular/core';
import { ToastrModule, ToastContainerDirective } from 'ngx-toastr';
import { ToastrModule, ToastContainerDirective } from '@openng/ngx-toastr';
import { AppComponent } from './app.component';

@NgModule({
Expand All @@ -283,7 +281,7 @@ Add a div with `toastContainer` directive on it.

```typescript
import { Component, OnInit, viewChild, inject } from '@angular/core';
import { ToastContainerDirective, ToastrService } from 'ngx-toastr';
import { ToastContainerDirective, ToastrService } from '@openng/ngx-toastr';

@Component({
selector: 'app-root',
Expand Down Expand Up @@ -319,34 +317,20 @@ toastrService.clear(toastId?: number);

Remove and destroy a single toast by id

```
```ts
toastrService.remove(toastId: number);
```

## SystemJS

If you are using SystemJS, you should also adjust your configuration to point to
the UMD bundle.

In your SystemJS config file, `map` needs to tell the System loader where to
look for `ngx-toastr`:

```js
map: {
'ngx-toastr': 'node_modules/ngx-toastr/bundles/ngx-toastr.umd.min.js',
}
```

## Setup Without Animations

If you do not want animations you can override the default
If you do not want animations you can override the default
toast component in the global config to use
`ToastNoAnimation` instead of the default one.

In your main module (ex: `app.module.ts`)

```typescript
import { ToastrModule, ToastNoAnimation, ToastNoAnimationModule } from 'ngx-toastr';
import { ToastrModule, ToastNoAnimation, ToastNoAnimationModule } from '@openng/ngx-toastr';

@NgModule({
imports: [
Expand All @@ -363,10 +347,10 @@ That's it! No animations.
## Using A Custom Toast

Create your toast component extending Toast see the demo's pink toast for an example
https://github.com/scttcper/ngx-toastr/blob/master/src/app/pink.toast.ts
<https://github.com/openng-org/ngx-toastr/blob/master/src/app/pink-toast/pink-toast.component.ts>

```typescript
import { ToastrModule } from 'ngx-toastr';
import { ToastrModule } from '@openng/ngx-toastr';

@NgModule({
imports: [
Expand All @@ -393,12 +377,13 @@ ngOnInit() {
```

2. Change default icons (check, warning sign, etc)\
Overwrite the css background-image: https://github.com/scttcper/ngx-toastr/blob/master/src/lib/toastr.css.
Overwrite the css background-image: <https://github.com/openng-org/ngx-toastr/blob/master/projects/ngx-toastr/src/lib/toastr.css>.
3. How do I use this in an ErrorHandler?\
See: https://github.com/scttcper/ngx-toastr/issues/179.
See: <https://github.com/scttcper/ngx-toastr/issues/179>.
4. How can I translate messages?\
See: https://github.com/scttcper/ngx-toastr/issues/201.
See: <https://github.com/scttcper/ngx-toastr/issues/201>.
5. How to handle toastr click/tap action?

```ts
showToaster() {
this.toastr.success('Hello world!', 'Toastr fun!')
Expand All @@ -411,12 +396,15 @@ ngOnInit() {
console.log('Toastr clicked');
}
```

6. How to customize styling without overridding defaults?\
Add multiple CSS classes separated by a space:

```ts
toastClass: 'yourclass ngx-toastr'
```
See: https://github.com/scttcper/ngx-toastr/issues/594.

See: <https://github.com/scttcper/ngx-toastr/issues/594>.

## Previous Works

Expand All @@ -430,5 +418,7 @@ MIT

---

> GitHub [@scttcper](https://github.com/scttcper) &nbsp;&middot;&nbsp;
> Twitter [@scttcper](https://twitter.com/scttcper)
Maintained by [OpenNG](https://www.openng.org/).

Originally created by GitHub [@scttcper](https://github.com/scttcper) &nbsp;&middot;&nbsp;
Twitter [@scttcper](https://twitter.com/scttcper)
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"packageManager": "npm@11.7.0",
"repository": {
"type": "git",
"url": "https://github.com/scttcper/ngx-toastr"
"url": "https://github.com/openng-org/ngx-toastr"
},
"license": "MIT",
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions projects/ngx-toastr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-toastr",
"version": "0.0.1",
"name": "@openng/ngx-toastr",
"version": "0.0.0-development",
"license": "MIT",
"peerDependencies": {
"@angular/common": "^21.0.0",
Expand All @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/scttcper/ngx-toastr"
"url": "https://github.com/openng-org/ngx-toastr"
},
"exports": {
"./toastr": {
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-toastr/src/lib/toastr/toast.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const DefaultGlobalConfig: GlobalConfig = {
*
* @example
* ```ts
* import { provideToastr } from 'ngx-toastr';
* import { provideToastr } from '@openng/ngx-toastr';
*
* bootstrap(AppComponent, {
* providers: [
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-toastr/src/public-api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Public API Surface of ngx-toastr
* Public API Surface of @openng/ngx-toastr
*/

export * from './lib';
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ToastNoAnimationModule } from 'ngx-toastr';
import { ToastNoAnimationModule } from '@openng/ngx-toastr';
import { FooterComponent } from './footer/footer.component';
import { HeaderComponent } from './header/header.component';
import { HomeComponent } from './home/home.component';
Expand Down
2 changes: 1 addition & 1 deletion src/app/bootstrap-toast/bootstrap-toast.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { Toast } from 'ngx-toastr';
import { Toast } from '@openng/ngx-toastr';

@Component({
selector: '[bootstrap-toast-component]',
Expand Down
4 changes: 2 additions & 2 deletions src/app/footer/footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Component, VERSION } from '@angular/core';
<footer class="footer mb-4 mt-5">
Angular {{ version }}
<br />
<a href="https://github.com/scttcper/ngx-toastr/blob/master/LICENSE">MIT license</a>
<a href="https://github.com/openng-org/ngx-toastr/blob/master/LICENSE">MIT license</a>
-
<a href="https://github.com/scttcper/ngx-toastr">Source</a>
<a href="https://github.com/openng-org/ngx-toastr">Source</a>
</footer>
`,
styles: [
Expand Down
4 changes: 2 additions & 2 deletions src/app/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { GhButtonModule } from '@ctrl/ngx-github-buttons';
selector: 'app-header',
template: `
<header class="header mt-5 text-center">
<h1>Angular Toastr</h1>
<h1>@openng/ngx-toastr</h1>
<p style="color: #777" class="mb-1">Easy Toasts for Angular</p>
<gh-button user="scttcper" repo="ngx-toastr" [count]="true"></gh-button>
<gh-button user="openng-org" repo="ngx-toastr" [count]="true"></gh-button>
</header>
`,
imports: [GhButtonModule],
Expand Down
Loading
Loading