Skip to content

Commit

Permalink
feat(divider): move divider out of mat-list
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
CaerusKaru committed Nov 9, 2017
1 parent dbd64b6 commit 29ddec1
Show file tree
Hide file tree
Showing 28 changed files with 414 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/src/lib/chips/** @tinayuangao
/src/lib/datepicker/** @mmalerba
/src/lib/dialog/** @jelbourn @crisbeto
/src/lib/divider/** @jelbourn @crisbeto
/src/lib/expansion/** @josephperrott @jelbourn
/src/lib/form-field/** @mmalerba
/src/lib/grid-list/** @kara @jelbourn
Expand Down
17 changes: 17 additions & 0 deletions src/demo-app/card/card-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@
</mat-card-footer>
</mat-card>

<mat-card>
<mat-card-subtitle>Subtitle</mat-card-subtitle>
<mat-card-title>Card with title, footer, and inset-divider</mat-card-title>
<mat-card-content>
<p>This is supporting text.</p>
<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>
</mat-card-content>
<mat-divider [inset]="true"></mat-divider>
<mat-card-actions>
<button mat-button>LIKE</button>
<button mat-button>SHARE</button>
</mat-card-actions>
<mat-card-footer>
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
</mat-card-footer>
</mat-card>

<mat-card>
<img mat-card-image src="https://material.angularjs.org/latest/img/washedout.png">
<mat-card-title>Content Title</mat-card-title>
Expand Down
2 changes: 2 additions & 0 deletions src/demo-app/demo-material-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
MatChipsModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatFormFieldModule,
MatGridListModule,
Expand Down Expand Up @@ -55,6 +56,7 @@ import {PortalModule} from '@angular/cdk/portal';
MatTableModule,
MatDatepickerModule,
MatDialogModule,
MatDividerModule,
MatExpansionModule,
MatFormFieldModule,
MatGridListModule,
Expand Down
3 changes: 2 additions & 1 deletion src/demo-app/list/list-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ <h3 mat-line>{{contact.name}}</h3>

<mat-list>
<h3 mat-subheader>Today</h3>
<mat-list-item *ngFor="let message of messages">
<mat-list-item *ngFor="let message of messages; last as last">
<img mat-list-avatar [src]="message.image" alt="Image of {{message.from}}">
<h4 mat-line>{{message.from}}</h4>
<p mat-line>
<span>{{message.subject}} -- </span>
<span class="demo-secondary-text">{{message.message}}</span>
</p>
<mat-divider [inset]="true" *ngIf="!last"></mat-divider>
</mat-list-item>
<mat-divider></mat-divider>
<mat-list-item *ngFor="let message of messages">
Expand Down
18 changes: 18 additions & 0 deletions src/demo-app/menu/menu-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
</button>
</mat-menu>
</div>
<div class="menu-section">
<p>Menu with divider</p>

<mat-toolbar>
<button mat-icon-button [matMenuTriggerFor]="divider" aria-label="Open basic menu">
<mat-icon>more_vert</mat-icon>
</button>
</mat-toolbar>

<mat-menu #divider="matMenu">
<ng-container *ngFor="let item of items; last as last">
<button mat-menu-item [disabled]="item.disabled">
{{ item.text }}
</button>
<mat-divider *ngIf="!last"></mat-divider>
</ng-container>
</mat-menu>
</div>
<div class="menu-section">
<p>Nested menu</p>

Expand Down
1 change: 1 addition & 0 deletions src/demo-app/system-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ System.config({
'@angular/material/core': 'dist/packages/material/core/index.js',
'@angular/material/datepicker': 'dist/packages/material/datepicker/index.js',
'@angular/material/dialog': 'dist/packages/material/dialog/index.js',
'@angular/material/divider': 'dist/packages/material/divider/index.js',
'@angular/material/expansion': 'dist/packages/material/expansion/index.js',
'@angular/material/form-field': 'dist/packages/material/form-field/index.js',
'@angular/material/grid-list': 'dist/packages/material/grid-list/index.js',
Expand Down
2 changes: 2 additions & 0 deletions src/e2e-app/e2e-app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
MatButtonModule,
MatCheckboxModule,
MatDialogModule,
MatDividerModule,
MatFormFieldModule,
MatGridListModule,
MatIconModule,
Expand Down Expand Up @@ -50,6 +51,7 @@ import {ReactiveFormsModule} from '@angular/forms';
MatButtonModule,
MatCheckboxModule,
MatDialogModule,
MatDividerModule,
MatFormFieldModule,
MatGridListModule,
MatIconModule,
Expand Down
1 change: 1 addition & 0 deletions src/e2e-app/system-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ System.config({
'@angular/material/core': 'dist/bundles/material-core.umd.js',
'@angular/material/datepicker': 'dist/bundles/material-datepicker.umd.js',
'@angular/material/dialog': 'dist/bundles/material-dialog.umd.js',
'@angular/material/divider': 'dist/bundles/material-divider.umd.js',
'@angular/material/expansion': 'dist/bundles/material-expansion.umd.js',
'@angular/material/form-field': 'dist/bundles/material-form-field.umd.js',
'@angular/material/grid-list': 'dist/bundles/material-grid-list.umd.js',
Expand Down
2 changes: 2 additions & 0 deletions src/lib/core/theming/_all-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@import '../../table/table-theme';
@import '../../datepicker/datepicker-theme';
@import '../../dialog/dialog-theme';
@import '../../divider/divider-theme';
@import '../../expansion/expansion-theme';
@import '../../grid-list/grid-list-theme';
@import '../../icon/icon-theme';
Expand Down Expand Up @@ -43,6 +44,7 @@
@include mat-table-theme($theme);
@include mat-datepicker-theme($theme);
@include mat-dialog-theme($theme);
@include mat-divider-theme($theme);
@include mat-expansion-panel-theme($theme);
@include mat-form-field-theme($theme);
@include mat-grid-list-theme($theme);
Expand Down
1 change: 1 addition & 0 deletions src/lib/divider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please see the official documentation at https://material.angular.io/components/component/divider
15 changes: 15 additions & 0 deletions src/lib/divider/_divider-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import '../core/theming/palette';
@import '../core/theming/theming';


@mixin mat-divider-theme($theme) {
$foreground: map-get($theme, foreground);

.mat-divider {
border-top-color: mat-color($foreground, divider);
}

.mat-divider-vertical {
border-right-color: mat-color($foreground, divider);
}
}
25 changes: 25 additions & 0 deletions src/lib/divider/divider-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {MatCommonModule} from '@angular/material/core';
import {MatDivider} from './divider';


@NgModule({
imports: [MatCommonModule, CommonModule],
exports: [
MatDivider,
MatCommonModule,
],
declarations: [
MatDivider,
],
})
export class MatDividerModule {}
64 changes: 64 additions & 0 deletions src/lib/divider/divider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
`<mat-divider>` is a container component that wraps and formats a series of line items. As the base
list component, it provides Material Design styling, but no behavior of its own.

<!-- example(divider-overview) -->


### Simple divider

An `<mat-divider>` element can be used on its own to create a vertical line styled with a Material theme

```html
<mat-divider></mat-divider>
```

Here are the available global options:

| Name | Type | Values | Description |
| --------------- | ------- | ----------- | ----------------------------------------- |
| inset | boolean | true, false | Whether the divider is an inset divider |
| vertical | boolean | true, false | Whether the divider is a vertical divider |


### Inset divider

Add the `inset` attribute in order to set whether or not the divider is an inset divider.

```html
<mat-divider [inset]="true"></mat-divider>
```

### Vertical divider

Add the `vertical` attribute in order to set whether or not the divider is vertically-oriented.

```html
<mat-divider [vertical]="true"></mat-divider>
```


### Lists with inset dividers

Dividers can be added to lists as a means of separating content into distinct sections.
Inset dividers can also be added to provide the appearance of distinct elements in a list without cluttering content
like avatar images or icons. If combining both, please make sure to avoid adding an inset divider to the last element
in a list, because it will overlap with the section divider.

```html
<mat-list>
<h3 mat-subheader>Folders</h3>
<mat-list-item *ngFor="let folder of folders; last as last">
<mat-icon mat-list-icon>folder</mat-icon>
<h4 mat-line>{{folder.name}}</h4>
<p mat-line class="demo-2"> {{folder.updated}} </p>
<mat-divider [inset]="true" *ngIf="!last"></mat-divider>
</mat-list-item>
<mat-divider></mat-divider>
<h3 md-subheader>Notes</h3>
<mat-list-item *ngFor="let note of notes">
<mat-icon md-list-icon>note</mat-icon>
<h4 md-line>{{note.name}}</h4>
<p md-line class="demo-2"> {{note.updated}} </p>
</mat-list-item>
</mat-list>
```
66 changes: 66 additions & 0 deletions src/lib/divider/divider.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
.mat-divider {
display: block;
margin: 0;
border-top-width: 1px;
border-top-style: solid;

&.mat-divider-vertical {
border-top: 0;
border-right-width: 1px;
border-right-style: solid;
position: static;
width: auto;
}

&.mat-divider-inset {
margin-left: 80px;
[dir='rtl'] & {
margin-left: auto;
margin-right: 80px;
}
}
}

.mat-list-item {
.mat-divider {
position: absolute;
bottom: 0;

left: 0;
[dir='rtl'] & {
left: auto;
right: 0;
}

width: 100%;
&.mat-divider-inset {
left: 72px;
[dir='rtl'] & {
left: auto;
right: 72px;
}

width: calc(100% - 72px);
margin: 0;
}
}
}

.mat-card {
.mat-divider {
position: absolute;

left: 0;
[dir='rtl'] & {
left: auto;
right: 0;
}

width: 100%;

&.mat-divider-inset {
position: static;
margin: 0;
}
}
}
Loading

0 comments on commit 29ddec1

Please sign in to comment.