Skip to content

Commit 617f514

Browse files
karajosephperrott
authored andcommitted
fix(grid-list): hide overflow on tiles (#1299)
1 parent e160668 commit 617f514

File tree

9 files changed

+44
-64
lines changed

9 files changed

+44
-64
lines changed

src/demo-app/snack-bar/snack-bar-demo.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ <h1>SnackBar demo</h1>
22
<div>
33
<div>Message: <md-input type="text" [(ngModel)]="message"></md-input></div>
44
<div>
5-
<md-checkbox [(ngModel)]="action">Show button</md-checkbox>
6-
<md-input type="text" class="button-label-input"
7-
placeholder="Snack bar action label"
8-
[disabled]="!action"
9-
[(ngModel)]="actionButtonLabel"></md-input>
5+
<md-checkbox [(ngModel)]="action">
6+
<p *ngIf="!action">Show button</p>
7+
<md-input type="text" class="button-label-input"
8+
*ngIf="action"
9+
placeholder="Snack bar action label"
10+
[(ngModel)]="actionButtonLabel"></md-input>
11+
</md-checkbox>
1012
</div>
1113
</div>
1214

src/lib/grid-list/grid-list.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ md-grid-list {
2020
md-grid-tile {
2121
display: block;
2222
position: absolute;
23+
overflow: hidden;
2324

2425
figure {
2526
display: flex;

src/lib/snack-bar/base-snack-bar.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/lib/snack-bar/package.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/lib/snack-bar/simple-snack-bar.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
md-simple-snackbar {
2-
display: flex;
3-
justify-content: space-between;
2+
display: flex;
3+
justify-content: space-between;
44
}
55

66
.md-simple-snackbar-message {

src/lib/snack-bar/simple-snack-bar.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
import {Component} from '@angular/core';
2-
import {BaseSnackBarContent} from './base-snack-bar';
2+
import {MdSnackBarRef} from './snack-bar-ref';
33

44

5+
/**
6+
* A component used to open as the default snack bar, matching material spec.
7+
* This should only be used internally by the snack bar service.
8+
*/
59
@Component({
610
moduleId: module.id,
711
selector: 'simple-snack-bar',
812
templateUrl: 'simple-snack-bar.html',
913
styleUrls: ['simple-snack-bar.css'],
1014
})
11-
export class SimpleSnackBar extends BaseSnackBarContent<SimpleSnackBar> {
15+
export class SimpleSnackBar {
1216
/** The message to be shown in the snack bar. */
1317
message: string;
1418

1519
/** The label for the button in the snack bar. */
1620
action: string;
1721

22+
/** The instance of the component making up the content of the snack bar. */
23+
snackBarRef: MdSnackBarRef<SimpleSnackBar>;
24+
25+
/** Dismisses the snack bar. */
26+
dismiss(): void {
27+
this.snackBarRef.dismiss();
28+
}
29+
1830
/** If the action button should be shown. */
1931
get hasAction(): boolean { return !!this.action; }
2032
}

src/lib/snack-bar/snack-bar-config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import {ViewContainerRef} from '@angular/core';
2+
import {AriaLivePoliteness} from '@angular2-material/core'
23

34

4-
export type SnackBarRole = 'alert' | 'polite';
5-
65
export class MdSnackBarConfig {
7-
/** The aria-role of the snack bar. */
8-
role: SnackBarRole = 'alert';
6+
/** The politeness level for the MdAriaLiveAnnouncer announcement. */
7+
politeness: AriaLivePoliteness = 'assertive';
8+
9+
/** Message to be announced by the MdAriaLiveAnnouncer */
10+
announcementMessage: string;
911

1012
/** The view container to place the overlay for the snack bar into. */
1113
viewContainerRef: ViewContainerRef;

src/lib/snack-bar/snack-bar-ref.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import {Subject} from 'rxjs/Subject';
1010
*/
1111
export class MdSnackBarRef<T> {
1212
/** The instance of the component making up the content of the snack bar. */
13-
readonly instance: T|any;
13+
readonly instance: T;
1414

1515
/** Subject for notifying the user that the snack bar has closed. */
1616
private _afterClosed: Subject<any> = new Subject();
1717

1818
/** If the snack bar is active. */
1919
private _isActive: boolean = true;
2020

21-
constructor(instance: T|any, private _overlayRef: OverlayRef) {
21+
constructor(instance: T, private _overlayRef: OverlayRef) {
2222
// Sets the readonly instance of the snack bar content component.
2323
this.instance = instance;
2424
this.afterDismissed().subscribe(null, null, () => { this._isActive = false; });

src/lib/snack-bar/snack-bar.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import {
55
ComponentRef,
66
} from '@angular/core';
77
import {
8-
Overlay,
9-
OverlayState,
10-
OverlayRef,
118
ComponentType,
129
ComponentPortal,
10+
Overlay,
1311
OverlayModule,
12+
OverlayRef,
13+
OverlayState,
1414
PortalModule,
1515
OVERLAY_PROVIDERS,
16+
MdLiveAnnouncer,
1617
} from '@angular2-material/core';
1718
import {CommonModule} from '@angular/common';
1819
import {MdSnackBarConfig} from './snack-bar-config';
@@ -35,7 +36,8 @@ export class MdSnackBar {
3536
/** A reference to the current snack bar in the view. */
3637
private _snackBarRef: MdSnackBarRef<any>;
3738

38-
constructor(private _overlay: Overlay) {}
39+
constructor(private _overlay: Overlay,
40+
private _live: MdLiveAnnouncer) {}
3941

4042
/**
4143
* Creates and dispatches a snack bar with a custom component for the content, removing any
@@ -48,8 +50,9 @@ export class MdSnackBar {
4850
}
4951
let overlayRef = this._createOverlay();
5052
let snackBarContainer = this._attachSnackBarContainer(overlayRef, config);
51-
52-
return this._attachSnackbarContent(component, snackBarContainer, overlayRef);
53+
let mdSnackBarRef = this._attachSnackbarContent(component, snackBarContainer, overlayRef);
54+
this._live.announce(config.announcementMessage, config.politeness);
55+
return mdSnackBarRef;
5356
}
5457

5558

@@ -58,7 +61,9 @@ export class MdSnackBar {
5861
*/
5962
open(message: string, actionLabel: string,
6063
config: MdSnackBarConfig): MdSnackBarRef<SimpleSnackBar> {
64+
config.announcementMessage = message;
6165
let simpleSnackBarRef = this.openFromComponent(SimpleSnackBar, config);
66+
simpleSnackBarRef.instance.snackBarRef = simpleSnackBarRef;
6267
simpleSnackBarRef.instance.message = message;
6368
simpleSnackBarRef.instance.action = actionLabel;
6469
return simpleSnackBarRef;
@@ -87,7 +92,6 @@ export class MdSnackBar {
8792
let portal = new ComponentPortal(component);
8893
let contentRef = container.attachComponentPortal(portal);
8994
let snackBarRef = <MdSnackBarRef<T>> new MdSnackBarRef(contentRef.instance, overlayRef);
90-
snackBarRef.instance.snackBarRef = snackBarRef;
9195

9296
this._snackBarRef = snackBarRef;
9397
return snackBarRef;
@@ -118,7 +122,7 @@ export class MdSnackBarModule {
118122
static forRoot(): ModuleWithProviders {
119123
return {
120124
ngModule: MdSnackBarModule,
121-
providers: [MdSnackBar, OVERLAY_PROVIDERS]
125+
providers: [MdSnackBar, OVERLAY_PROVIDERS, MdLiveAnnouncer]
122126
};
123127
}
124128
}

0 commit comments

Comments
 (0)