Skip to content

Commit dddd4cd

Browse files
committed
feat(divider): move divider out of mat-list
- Creates an independent mat-divider component - Adds inset capability with special accomodations for mat-list-item - Adds vertical option - Removed mat-divider from MatListModule with temporary import to prevent breaking changes - Added styling for dividers in cards - Add demos for use in list, card, and menu
1 parent dbd64b6 commit dddd4cd

28 files changed

+417
-41
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/src/lib/chips/** @tinayuangao
99
/src/lib/datepicker/** @mmalerba
1010
/src/lib/dialog/** @jelbourn @crisbeto
11+
/src/lib/divider/** @jelbourn @crisbeto
1112
/src/lib/expansion/** @josephperrott @jelbourn
1213
/src/lib/form-field/** @mmalerba
1314
/src/lib/grid-list/** @kara @jelbourn

src/demo-app/card/card-demo.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@
2727
</mat-card-footer>
2828
</mat-card>
2929

30+
<mat-card>
31+
<mat-card-subtitle>Subtitle</mat-card-subtitle>
32+
<mat-card-title>Card with title, footer, and inset-divider</mat-card-title>
33+
<mat-card-content>
34+
<p>This is supporting text.</p>
35+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
36+
</mat-card-content>
37+
<mat-divider [inset]="true"></mat-divider>
38+
<mat-card-actions>
39+
<button mat-button>LIKE</button>
40+
<button mat-button>SHARE</button>
41+
</mat-card-actions>
42+
<mat-card-footer>
43+
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
44+
</mat-card-footer>
45+
</mat-card>
46+
3047
<mat-card>
3148
<img mat-card-image src="https://material.angularjs.org/latest/img/washedout.png">
3249
<mat-card-title>Content Title</mat-card-title>

src/demo-app/demo-material-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
MatChipsModule,
99
MatDatepickerModule,
1010
MatDialogModule,
11+
MatDividerModule,
1112
MatExpansionModule,
1213
MatFormFieldModule,
1314
MatGridListModule,
@@ -55,6 +56,7 @@ import {PortalModule} from '@angular/cdk/portal';
5556
MatTableModule,
5657
MatDatepickerModule,
5758
MatDialogModule,
59+
MatDividerModule,
5860
MatExpansionModule,
5961
MatFormFieldModule,
6062
MatGridListModule,

src/demo-app/list/list-demo.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ <h3 mat-line>{{contact.name}}</h3>
2424

2525
<mat-list>
2626
<h3 mat-subheader>Today</h3>
27-
<mat-list-item *ngFor="let message of messages">
27+
<mat-list-item *ngFor="let message of messages; last as last">
2828
<img mat-list-avatar [src]="message.image" alt="Image of {{message.from}}">
2929
<h4 mat-line>{{message.from}}</h4>
3030
<p mat-line>
3131
<span>{{message.subject}} -- </span>
3232
<span class="demo-secondary-text">{{message.message}}</span>
3333
</p>
34+
<mat-divider [inset]="true" *ngIf="!last"></mat-divider>
3435
</mat-list-item>
3536
<mat-divider></mat-divider>
3637
<mat-list-item *ngFor="let message of messages">

src/demo-app/menu/menu-demo.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@
1414
</button>
1515
</mat-menu>
1616
</div>
17+
<div class="menu-section">
18+
<p>Menu with divider</p>
19+
20+
<mat-toolbar>
21+
<button mat-icon-button [matMenuTriggerFor]="divider" aria-label="Open basic menu">
22+
<mat-icon>more_vert</mat-icon>
23+
</button>
24+
</mat-toolbar>
25+
26+
<mat-menu #divider="matMenu">
27+
<ng-container *ngFor="let item of items; last as last">
28+
<button mat-menu-item [disabled]="item.disabled">
29+
{{ item.text }}
30+
</button>
31+
<mat-divider *ngIf="!last"></mat-divider>
32+
</ng-container>
33+
</mat-menu>
34+
</div>
1735
<div class="menu-section">
1836
<p>Nested menu</p>
1937

src/demo-app/system-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ System.config({
5656
'@angular/material/core': 'dist/packages/material/core/index.js',
5757
'@angular/material/datepicker': 'dist/packages/material/datepicker/index.js',
5858
'@angular/material/dialog': 'dist/packages/material/dialog/index.js',
59+
'@angular/material/divider': 'dist/packages/material/divider/index.js',
5960
'@angular/material/expansion': 'dist/packages/material/expansion/index.js',
6061
'@angular/material/form-field': 'dist/packages/material/form-field/index.js',
6162
'@angular/material/grid-list': 'dist/packages/material/grid-list/index.js',

src/e2e-app/e2e-app-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
MatButtonModule,
2424
MatCheckboxModule,
2525
MatDialogModule,
26+
MatDividerModule,
2627
MatFormFieldModule,
2728
MatGridListModule,
2829
MatIconModule,
@@ -50,6 +51,7 @@ import {ReactiveFormsModule} from '@angular/forms';
5051
MatButtonModule,
5152
MatCheckboxModule,
5253
MatDialogModule,
54+
MatDividerModule,
5355
MatFormFieldModule,
5456
MatGridListModule,
5557
MatIconModule,

src/e2e-app/system-config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ System.config({
5656
'@angular/material/core': 'dist/bundles/material-core.umd.js',
5757
'@angular/material/datepicker': 'dist/bundles/material-datepicker.umd.js',
5858
'@angular/material/dialog': 'dist/bundles/material-dialog.umd.js',
59+
'@angular/material/divider': 'dist/bundles/material-divider.umd.js',
5960
'@angular/material/expansion': 'dist/bundles/material-expansion.umd.js',
6061
'@angular/material/form-field': 'dist/bundles/material-form-field.umd.js',
6162
'@angular/material/grid-list': 'dist/bundles/material-grid-list.umd.js',

src/lib/core/theming/_all-theme.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@import '../../table/table-theme';
1010
@import '../../datepicker/datepicker-theme';
1111
@import '../../dialog/dialog-theme';
12+
@import '../../divider/divider-theme';
1213
@import '../../expansion/expansion-theme';
1314
@import '../../grid-list/grid-list-theme';
1415
@import '../../icon/icon-theme';
@@ -43,6 +44,7 @@
4344
@include mat-table-theme($theme);
4445
@include mat-datepicker-theme($theme);
4546
@include mat-dialog-theme($theme);
47+
@include mat-divider-theme($theme);
4648
@include mat-expansion-panel-theme($theme);
4749
@include mat-form-field-theme($theme);
4850
@include mat-grid-list-theme($theme);

src/lib/divider/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please see the official documentation at https://material.angular.io/components/component/divider

src/lib/divider/_divider-theme.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import '../core/theming/palette';
2+
@import '../core/theming/theming';
3+
4+
5+
@mixin mat-divider-theme($theme) {
6+
$foreground: map-get($theme, foreground);
7+
8+
.mat-divider {
9+
border-top-color: mat-color($foreground, divider);
10+
}
11+
12+
.mat-divider-vertical {
13+
border-right-color: mat-color($foreground, divider);
14+
}
15+
}

src/lib/divider/divider-module.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {NgModule} from '@angular/core';
10+
import {CommonModule} from '@angular/common';
11+
import {MatCommonModule} from '@angular/material/core';
12+
import {MatDivider} from './divider';
13+
14+
15+
@NgModule({
16+
imports: [MatCommonModule, CommonModule],
17+
exports: [
18+
MatDivider,
19+
MatCommonModule,
20+
],
21+
declarations: [
22+
MatDivider,
23+
],
24+
})
25+
export class MatDividerModule {}

src/lib/divider/divider.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
`<mat-divider>` is a container component that wraps and formats a series of line items. As the base
2+
list component, it provides Material Design styling, but no behavior of its own.
3+
4+
<!-- example(divider-overview) -->
5+
6+
7+
### Simple divider
8+
9+
An `<mat-divider>` element can be used on its own to create a vertical line styled with a Material theme
10+
11+
```html
12+
<mat-divider></mat-divider>
13+
```
14+
15+
Here are the available global options:
16+
17+
| Name | Type | Values | Description |
18+
| --------------- | ------- | ----------- | ----------------------------------------- |
19+
| inset | boolean | true, false | Whether the divider is an inset divider |
20+
| vertical | boolean | true, false | Whether the divider is a vertical divider |
21+
22+
23+
### Inset divider
24+
25+
Add the `inset` attribute in order to set whether or not the divider is an inset divider.
26+
27+
```html
28+
<mat-divider [inset]="true"></mat-divider>
29+
```
30+
31+
### Vertical divider
32+
33+
Add the `vertical` attribute in order to set whether or not the divider is vertically-oriented.
34+
35+
```html
36+
<mat-divider [vertical]="true"></mat-divider>
37+
```
38+
39+
40+
### Lists with inset dividers
41+
42+
Dividers can be added to lists as a means of separating content into distinct sections.
43+
Inset dividers can also be added to provide the appearance of distinct elements in a list without cluttering content
44+
like avatar images or icons. If combining both, please make sure to avoid adding an inset divider to the last element
45+
in a list, because it will overlap with the section divider.
46+
47+
```html
48+
<mat-list>
49+
<h3 mat-subheader>Folders</h3>
50+
<mat-list-item *ngFor="let folder of folders; last as last">
51+
<mat-icon mat-list-icon>folder</mat-icon>
52+
<h4 mat-line>{{folder.name}}</h4>
53+
<p mat-line class="demo-2"> {{folder.updated}} </p>
54+
<mat-divider [inset]="true" *ngIf="!last"></mat-divider>
55+
</mat-list-item>
56+
<mat-divider></mat-divider>
57+
<h3 md-subheader>Notes</h3>
58+
<mat-list-item *ngFor="let note of notes">
59+
<mat-icon md-list-icon>note</mat-icon>
60+
<h4 md-line>{{note.name}}</h4>
61+
<p md-line class="demo-2"> {{note.updated}} </p>
62+
</mat-list-item>
63+
</mat-list>
64+
```

src/lib/divider/divider.scss

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
.mat-divider {
2+
display: block;
3+
margin: 0;
4+
border-top-width: 1px;
5+
border-top-style: solid;
6+
7+
&.mat-divider-vertical {
8+
border-top: 0;
9+
border-right-width: 1px;
10+
border-right-style: solid;
11+
position: static;
12+
width: auto;
13+
}
14+
15+
&.mat-divider-inset {
16+
margin-left: 80px;
17+
[dir='rtl'] & {
18+
margin-left: auto;
19+
margin-right: 80px;
20+
}
21+
}
22+
}
23+
24+
.mat-list-item {
25+
.mat-divider {
26+
position: absolute;
27+
bottom: 0;
28+
29+
left: 0;
30+
[dir='rtl'] & {
31+
left: auto;
32+
right: 0;
33+
}
34+
35+
width: 100%;
36+
&.mat-divider-inset {
37+
left: 72px;
38+
[dir='rtl'] & {
39+
left: auto;
40+
right: 72px;
41+
}
42+
43+
width: calc(100% - 72px);
44+
margin: 0;
45+
}
46+
}
47+
}
48+
49+
.mat-card {
50+
.mat-divider {
51+
position: absolute;
52+
53+
left: 0;
54+
[dir='rtl'] & {
55+
left: auto;
56+
right: 0;
57+
}
58+
59+
width: 100%;
60+
61+
&.mat-divider-inset {
62+
position: static;
63+
margin: 0;
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)