Skip to content

Commit

Permalink
fix(material-experimental/mdc-dialog): make align attr into an input …
Browse files Browse the repository at this point in the history
…of dialog actions directive

Fixes multiple issues, such as self-documentation of the align attribute, type checking, better
bindings, and IDE support. Because align is not standard for HTMLDivElement, it doesn't make much
sense to assume end users to know they can use the align attribute.

Fixes #18479 for material-experimental
  • Loading branch information
PooSham committed Jan 4, 2021
1 parent c101f7f commit 462d407
Show file tree
Hide file tree
Showing 5 changed files with 1,112 additions and 1,213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,13 @@ export class MatDialogContent {
*/
@Directive({
selector: `[mat-dialog-actions], mat-dialog-actions, [matDialogActions]`,
host: {'class': 'mat-mdc-dialog-actions mdc-dialog__actions'}
host: {
'class': 'mat-mdc-dialog-actions mdc-dialog__actions',
'[class.mat-mdc-dialog-actions-align-center]': 'align === "center"',
'[class.mat-mdc-dialog-actions-align-end]': 'align === "end"'}
})
export class MatDialogActions {
@Input() align?: 'center' | 'end' = undefined;
}


Expand Down
10 changes: 5 additions & 5 deletions src/material-experimental/mdc-dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ $mat-dialog-button-horizontal-margin: 8px !default;
// aligns actions at the end of the container.
justify-content: start;

&[align='end'] {
justify-content: flex-end;
}

&[align='center'] {
// .align-center and .align-end are set by directive input "align"
&.mat-mdc-dialog-actions-align-center, &[align='center'] {
justify-content: center;
}
&.mat-mdc-dialog-actions-align-end, &[align='end'] {
justify-content: flex-end;
}

// MDC applies horizontal margin to buttons that have an explicit `mdc-dialog__button`
// class applied. We can't set this class for projected buttons that consumers of the
Expand Down
Loading

0 comments on commit 462d407

Please sign in to comment.