-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(toast): Toast implementation #3103
Conversation
918d638
to
62fe8f7
Compare
Codecov Report
@@ Coverage Diff @@
## master #3103 +/- ##
==========================================
+ Coverage 92.03% 92.09% +0.05%
==========================================
Files 91 94 +3
Lines 3052 3087 +35
Branches 504 508 +4
==========================================
+ Hits 2809 2843 +34
Misses 179 179
- Partials 64 65 +1
Continue to review full report at Codecov.
|
ecc1d58
to
7350230
Compare
demo/src/app/components/toast/overview/toast-overview.component.html
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR @benouat ! I let a couple of comments in my review, mainly typo fixes.
demo/src/app/components/toast/overview/toast-overview.component.html
Outdated
Show resolved
Hide resolved
demo/src/app/components/toast/overview/toast-overview.component.html
Outdated
Show resolved
Hide resolved
demo/src/app/components/toast/overview/toast-overview.component.html
Outdated
Show resolved
Hide resolved
demo/src/app/components/toast/demos/custom-header/toast-custom-header.html
Outdated
Show resolved
Hide resolved
I'm not also 100% sure that letting the widget visibility managed only by the developer is a good thing. I mean, for some use cases, it can render thing more complex than expected. For example, what about a stateless message, as something the app wants to display a notification few seconds, and let the widget 'die' by itself. As a developer, I would expect something like:
... and that's it ! I need more time to thing about it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @benouat!
Looks good as a starting API and we'll see if we need a service later.
Left some comments and most notably the big ones are:
- we should have a demo where clicking on the cross would close the toast (simple one)
- in the overview we should state somewhere early in the beginning that it's up to you to position toasts (like bootstrap does)
- some tests will become invalid if you simplify autohide
Cheers,
Max
package.json
Outdated
@@ -81,7 +81,7 @@ | |||
"@types/marked": "^0.6.1", | |||
"@types/node": "~8.9.4", | |||
"@types/prismjs": "^1.9.0", | |||
"bootstrap": "4.0.0", | |||
"bootstrap": "4.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't forget to remove from this commit before merging. Same for yarn.lock
changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused... this change is dependant on that. without bootstrap@4.2.1
toast won't work... I really don't like to bump this version in another commit...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean we have several other PRs waiting that need BS 4.2 or 4.3. We won't bump BS in all of them I guess.
Just wanted to have a separate commit/PR with the bump of dependencies. Locally when testing/reviewing it's not a problem to bump it manually.
demo/src/app/components/toast/overview/toast-overview.component.html
Outdated
Show resolved
Hide resolved
demo/src/app/components/toast/overview/toast-overview.component.html
Outdated
Show resolved
Hide resolved
|
||
it('should emit hide output after default delay (500ms)', fakeAsync(() => { | ||
const fixture = createTestComponent(`<ngb-toast header="header" (hide)="hide()">body</ngb-toast>`); | ||
tick(500); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check that is wasn't emitted before ? Same for the next test
src/toast/toast-config.ts
Outdated
@@ -0,0 +1,40 @@ | |||
import {Injectable} from '@angular/core'; | |||
|
|||
export type AriaLiveValue = 'polite' | 'alert'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't see much utility in this type personally.
- it is used only in this file
- it makes documentation more complex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed it, but I have to duplicate the type info for Typescript to be happy.
For example, I am not keen about ariaLive: 'polite' | 'alert' = 'polite';
either... but without it does not compile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@peterblazejewicz @fbasso @maxokorokov thanks to all of you for your reviews!
I'll open another PR to change slightly the big demo. I'll update the danger toast to be |
Implementation of twbs/bootstrap##22980
My final attempt at implementing Bootstrap Toast
The PR basically introduce:
<ngb-toast>
component. it just render bootstrap markup, with some inputs, and one single output that emit after a given delay in ms.NgbToastConfig
to override any of the default config values used to initialise above inputs.DISCLAIMER: this PR only introduce a declarative way of creating a toast. Don't look around for any
NgbToastService
, there is none! I did not implement it on purpose. If you really think it should be done, I am just waiting, go come challenge me !! 😆