-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c637f0f
commit 99f8f57
Showing
8 changed files
with
55 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="pix-toast-container"> | ||
{{#if this.pixToast.content}} | ||
<PixToast | ||
@message={{this.pixToast.content.message}} | ||
@ariaLabelForCloseButton={{this.pixToast.content.ariaLabel}} | ||
/> | ||
{{/if}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Component from '@glimmer/component'; | ||
import { service } from '@ember/service'; | ||
|
||
export default class PixToastContainer extends Component { | ||
@service pixToast; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,65 @@ | ||
import Service from '@ember/service'; | ||
import { A } from '@ember/array'; | ||
import EmberObject from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class ToastService extends Service { | ||
content = A(); | ||
@tracked content= undefined; | ||
|
||
addNotification(options) { | ||
if (!options.message) { | ||
throw new Error('No notification message provided'); | ||
} | ||
|
||
const notification = EmberObject.create({ | ||
const toast = EmberObject.create({ | ||
ariaLabel: options.ariaLabel, | ||
message: options.message, | ||
type: options.type || 'success', | ||
onClick: options.onClick, | ||
htmlContent: options.htmlContent || false, | ||
}); | ||
|
||
this.content.pushObject(notification); | ||
this.content = toast; | ||
|
||
return notification; | ||
return toast; | ||
} | ||
|
||
sendErrorNotification(message, options) { | ||
sendErrorNotification({ message, options }) { | ||
return this.addNotification({ | ||
...options, | ||
message, | ||
type: 'error', | ||
}); | ||
} | ||
|
||
sendSuccessNotification(message, options) { | ||
sendSuccessNotification({ message, options }) { | ||
return this.addNotification({ | ||
...options, | ||
message, | ||
type: 'success', | ||
}); | ||
} | ||
|
||
sendInformationNotification(message, options) { | ||
sendInformationNotification({ message, options }) { | ||
return this.addNotification({ | ||
...options, | ||
message, | ||
type: 'information', | ||
}); | ||
} | ||
|
||
sendWarningNotification(message, options) { | ||
sendWarningNotification({ message, options }) { | ||
return this.addNotification({ | ||
...options, | ||
message, | ||
type: 'warning', | ||
}); | ||
} | ||
|
||
removeNotification(notification) { | ||
if (!notification) { | ||
removeNotification(toast) { | ||
if (!toast) { | ||
return; | ||
} | ||
|
||
notification.set('dismiss', true); | ||
toast.destroy(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@1024pix/pix-ui/components/pix-toast-container'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters