-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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(md-snack-bar): Create initial MdSnackBar. #1296
Conversation
af6db23
to
7f1485a
Compare
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
adf4e9f
to
93db33b
Compare
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
93db33b
to
2978624
Compare
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.
For unit tests, you should be able to do pretty much the same thing as dialog.
padding: 5px; | ||
text-transform: uppercase; | ||
} | ||
} |
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.
Can you refactor this to be like:
md-simple-snackbar {
display: flex;
justify-content: space-between;
}
.md-simple-snackbar-message {
...
}
.md-simple-snackbar-action {
...
}
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.
Done
</div> | ||
</div> | ||
|
||
<button md-raised-button (click)="open()">Open</button> |
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.
OPEN
all caps
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.
Done
<div> | ||
<md-checkbox [(ngModel)]="action">Show button</md-checkbox> | ||
<md-input type="text" class="button-label-input" | ||
placeholder="Button Label" |
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.
placeholder="Snackbar action label"
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.
Done
import {MdSnackBarRef} from './snack-bar-ref'; | ||
|
||
|
||
export class BaseSnackBarContent<T> { |
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.
What's this base class for, since it's only ever inherited by from SimpleSnackbar
?
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.
Custom components used for snack bar content would also need to inherit from BaseSnackBarContent as it defines the MdSnackBarRef attributes on the component as well as a dismiss method to dismiss the snack bar.
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 don't want to require that any component you open in the sidenav inherits / implements anything. Inheritance is especially problematic because your component might already inherit from something else.
All of the end-developer's interactions with the snackbar should be done through the SnackBarRef
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.
Gotcha, I was wanting to make sure that the MdSnackBarRef was available to every component it opens, but that can be the responsibility of the end-dev
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.
In the dialog, we just make the MDDialogRef
available for injection into the component (see DialogInjector
). You don't have to worry about this for now, though.
@@ -0,0 +1,29 @@ | |||
{ | |||
"name": "@angular2-material/snack-bar", | |||
"version": "2.0.0-alpha.8-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.
alpha.8-2 (here and below)
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.
Done
*/ | ||
open(message: string, buttonLabel: string, | ||
config: MdSnackBarConfig): MdSnackBarRef<SimpleSnackBar> { | ||
let simpleSnackBar = this.openFromComponent(SimpleSnackBar, config); |
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.
simpleSnackbarRef
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.
Done
/** | ||
* Creates and dispatches a snack bar. | ||
*/ | ||
open(message: string, buttonLabel: string, |
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.
buttonLabel
> actionLabel
?
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.
Done
* Creates and dispatches a snack bar. | ||
*/ | ||
open(message: string, buttonLabel: string, | ||
config: MdSnackBarConfig): MdSnackBarRef<SimpleSnackBar> { |
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.
config
should be optional
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.
Because the config includes the viewContainerRef, it will always need to be included.
state.positionStrategy = this._overlay.position().global() | ||
.fixed() | ||
.centerHorizontally() | ||
.bottom('0px'); |
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 think you can just do '0'
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.
Done
/** | ||
* Places a new component as the content of the snack bar container. | ||
*/ | ||
private _fillSnackBarContainer<T>(component: ComponentType<T>, |
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.
_attachSnackbarContent
?
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.
Done
2978624
to
9a92003
Compare
import {MdSnackBarRef} from './snack-bar-ref'; | ||
|
||
|
||
export class BaseSnackBarContent<T> { |
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 don't want to require that any component you open in the sidenav inherits / implements anything. Inheritance is especially problematic because your component might already inherit from something else.
All of the end-developer's interactions with the snackbar should be done through the SnackBarRef
"peerDependencies": { | ||
"@angular2-material/core": "2.0.0-alpha.8-2" | ||
} | ||
} |
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.
You can delete this file, we won't need it for alpha.9
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.
Done
@@ -0,0 +1,28 @@ | |||
md-simple-snackbar { | |||
display: flex; |
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.
Too much indent
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.
Done
|
||
export class MdSnackBarConfig { | ||
/** The aria-role of the snack bar. */ | ||
role: SnackBarRole = '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.
'polite'
isn't a valid role
value. This should be used as the politeness that's passed through to the MdLiveAnnouncer
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
a1d68c3
to
ee191f9
Compare
ee191f9
to
617f514
Compare
e6cdd55
to
344b318
Compare
CLAs look good, thanks! |
1 similar comment
CLAs look good, thanks! |
@@ -0,0 +1 @@ | |||
<template portalHost></template> |
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.
Add a wrapper div with the following:
<div aria-live="assertive" aria-atomic="true" role="alert">
Eventually this needs to use MdLiveAnnouncer
, but this can suffice for now.
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.
Added MdLiveAnnouncer, I have role="alert"
, but not the others currently.
c1299ea
to
f715eba
Compare
Tests added. |
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.
LGTM aside from a last few nits
@@ -0,0 +1,3 @@ | |||
.button-label-input { |
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.
Prefix this with demo-
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.
Done.
|
||
let containerElement = overlayContainerElement.querySelector('snack-bar-container'); | ||
|
||
expect(containerElement.getAttribute('role')).toBe('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.
One new thing I want to start doing is adding a message to asserts. This one would be something like
expect(containerElement.getAttribute('role'))
.toBe('alert', 'Expected snackbar container to have role="alert"');
I only found out you could do this last week, and it makes test failures much easier to quickly understand.
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.
Done
snackBarRef.dismiss(); | ||
|
||
expect(dismissed).toBeTruthy(); | ||
expect(overlayContainerElement.innerHTML.length).toBe(0); |
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.
expect(overlayContainer.innerHTML).toBe('')
?
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.
Switched over to checking child node count since that's what we are really trying to check.
f715eba
to
7151d93
Compare
LGTM |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
For #115