-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dialog): add dialog content elements (#2090)
* feat(dialog): add dialog content elements Adds the following dialog-specific directives: * `md-dialog-close` - Closes the current dialog. * `md-dialog-title` - Title of a dialog. * `md-dialog-content` - Scrollable content for a dialog. * `md-dialog-actions` - Container for the bottom buttons in a dialog. Fixes #1624. Fixes #2042. * Rename the dialog directives file. * Add the selectors for Material 1 compatibility. * Remove the closeTop method and use the dialogRef instead. * Add an aria-label to the close button and simplify the testing setup. * Remove redundant element roles. * Use the computed value on the dialog title font size. * Remove the letter spacing override on the dialog title. * Add a comment regarding the negative bottom margin on the dialog actions.
- Loading branch information
Showing
11 changed files
with
294 additions
and
74 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
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
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
import {Directive, Input} from '@angular/core'; | ||
import {MdDialogRef} from './dialog-ref'; | ||
|
||
|
||
/** | ||
* Button that will close the current dialog. | ||
*/ | ||
@Directive({ | ||
selector: 'button[md-dialog-close], button[mat-dialog-close]', | ||
host: { | ||
'(click)': 'dialogRef.close()', | ||
'[attr.aria-label]': 'ariaLabel' | ||
} | ||
}) | ||
export class MdDialogClose { | ||
/** Screenreader label for the button. */ | ||
@Input('aria-label') ariaLabel: string = 'Close dialog'; | ||
|
||
constructor(public dialogRef: MdDialogRef<any>) { } | ||
} | ||
|
||
/** | ||
* Title of a dialog element. Stays fixed to the top of the dialog when scrolling. | ||
*/ | ||
@Directive({ | ||
selector: '[md-dialog-title], [mat-dialog-title]' | ||
}) | ||
export class MdDialogTitle { } | ||
|
||
|
||
/** | ||
* Scrollable content container of a dialog. | ||
*/ | ||
@Directive({ | ||
selector: '[md-dialog-content], md-dialog-content, [mat-dialog-content], mat-dialog-content' | ||
}) | ||
export class MdDialogContent { } | ||
|
||
|
||
/** | ||
* Container for the bottom action buttons in a dialog. | ||
* Stays fixed to the bottom when scrolling. | ||
*/ | ||
@Directive({ | ||
selector: '[md-dialog-actions], md-dialog-actions, [mat-dialog-actions], mat-dialog-actions' | ||
}) | ||
export class MdDialogActions { } |
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,54 @@ | ||
@import '../core/style/elevation'; | ||
@import '../core/a11y/a11y'; | ||
|
||
|
||
$md-dialog-padding: 24px !default; | ||
$md-dialog-border-radius: 2px !default; | ||
$md-dialog-max-width: 80vw !default; | ||
$md-dialog-max-height: 65vh !default; | ||
|
||
md-dialog-container { | ||
@include md-elevation(24); | ||
|
||
display: block; | ||
padding: $md-dialog-padding; | ||
border-radius: $md-dialog-border-radius; | ||
box-sizing: border-box; | ||
overflow: auto; | ||
max-width: $md-dialog-max-width; | ||
|
||
// The dialog container should completely fill its parent overlay element. | ||
width: 100%; | ||
height: 100%; | ||
|
||
@include md-high-contrast { | ||
outline: solid 1px; | ||
} | ||
} | ||
|
||
md-dialog-content, [md-dialog-content], mat-dialog-content, [mat-dialog-content] { | ||
display: block; | ||
margin: 0 $md-dialog-padding * -1; | ||
padding: 0 $md-dialog-padding; | ||
max-height: $md-dialog-max-height; | ||
overflow: auto; | ||
} | ||
|
||
[md-dialog-title], [mat-dialog-title] { | ||
font-size: 20px; | ||
font-weight: bold; | ||
margin: 0 0 20px; | ||
display: block; | ||
} | ||
|
||
md-dialog-actions, [md-dialog-actions], mat-dialog-actions, [mat-dialog-actions] { | ||
padding: $md-dialog-padding / 2 0; | ||
display: block; | ||
|
||
&:last-child { | ||
// If the actions are the last element in a dialog, we need to pull them down | ||
// over the dialog padding, in order to avoid the action's padding stacking | ||
// with the dialog's. | ||
margin-bottom: -$md-dialog-padding; | ||
} | ||
} |
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
Oops, something went wrong.