Skip to content

feat(divider): move divider out of mat-list - #5862

Merged
josephperrott merged 1 commit into
angular:masterfrom
CaerusKaru:divider
Dec 21, 2017
Merged

josephperrott merged 1 commit into
angular:masterfrom
CaerusKaru:divider

Conversation

@CaerusKaru

@CaerusKaru CaerusKaru commented Jul 19, 2017 •

Copy link
Copy Markdown
Member

Moves mat-divider out of MatListModule, replaced with temporary import to prevent breaking changes. Also includes support for inset and vertical dividers.

Fixes #5524.
Fixes #2017.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 19, 2017
@CaerusKaru
CaerusKaru force-pushed the divider branch 3 times, most recently from e7d1a42 to 7c93bf2 Compare July 19, 2017 07:07
@Gustav0ar

Gustav0ar commented Jul 21, 2017 •

Copy link
Copy Markdown

@CaerusKaru in divider.scss you need to add:
&.mat-divider-vertical {
border-right-color: rgba(0, 0, 0, 0.12);
}

Otherwise the color will be black and not following the standard

@CaerusKaru

Copy link
Copy Markdown
Member Author

@Gustav0ar the color is set in _divider-theme.scss

@Gustav0ar

Copy link
Copy Markdown

Ah, ok, my bad. I missed reviewing that file

Comment thread src/demo-app/list/list-demo.html Outdated
</mat-list-item>
</mat-list>

<<<<<<< HEAD

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you forgot to remove this? Also in line 43.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved, thanks for the catch. I rebased and for some reason Git missed this.

@CaerusKaru CaerusKaru changed the title feat(divider): move divider out of md-list feat(divider): move divider out of mat-list Oct 12, 2017
@CaerusKaru
CaerusKaru force-pushed the divider branch 2 times, most recently from 917ce22 to 7da32ed Compare October 12, 2017 04:39
@CaerusKaru
CaerusKaru requested a review from amcdnl as a code owner October 12, 2017 04:39
@CaerusKaru
CaerusKaru force-pushed the divider branch 4 times, most recently from 01aea89 to 06dd188 Compare October 12, 2017 05:50
@CaerusKaru
CaerusKaru force-pushed the divider branch 2 times, most recently from b8ed704 to 8647d64 Compare October 21, 2017 00:33
@crisbeto

Copy link
Copy Markdown
Member

@CaerusKaru if you rebase from master the errors should be resolved.

@CaerusKaru

Copy link
Copy Markdown
Member Author

Thanks @crisbeto, rebased and ready for review.

@ghost ghost left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two nits.
And what about adding a example for the matMenu to the demo app? Just for the sake of completeness.

Comment thread src/demo-app/card/card-demo.html Outdated
</mat-card-content>
<mat-divider [inset]="true"></mat-divider>
<mat-card-actions>
<button md-button>LIKE</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two should be mat-button.

<span>{{message.subject}} -- </span>
<span class="demo-secondary-text">{{message.message}}</span>
</p>
<mat-divider [inset]="true" *ngIf="!last"></mat-divider>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to bind last to a local variable: *ngFor="let message of messages; last as last"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, this got cut from a previous commit when rebased, good catch

Comment thread src/lib/divider/divider.md Outdated
| 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 |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the values column is covered by them both having boolean type. Further, I'm not sure this table is even necessary, since it will be available on the api page.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally pulled from list, but now I see it's been removed. Will fix.

`<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) -->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be a divider example?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean in the material-examples directory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that the prose is wrong here, will correct.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It would probably be good to add one in with this PR anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@CaerusKaru
CaerusKaru force-pushed the divider branch 3 times, most recently from f5985ae to d55f5d4 Compare November 9, 2017 20:45
});
});

@Component({

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than creating a number of Components that have to be recompiled on every run, can you create a single Component that is altered through attributes for tests?

We have found a bottleneck in our tests comes from having to recompile many components on each test run.

@Component({
  template: `<mat-divider [inset]="inset" [vertical]="vertical"></mat-divider>`
})
class MatDividerTestComponent {
  vertical: boolean;
  inset: boolean;
}

Then in tests you would do:

it('should apply a vertical class', () => {
  fixture.componentInstance.vertical = true;
  fixture.detechChanges();

  expect(divider.nativeElement.className).toContain('mat-divider-vertical');
});

@CaerusKaru CaerusKaru Nov 10, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestions, added

Comment thread src/lib/divider/divider.spec.ts Outdated
}));

it('should not apply any additional class to a list without lines', () => {
const fixture = TestBed.createComponent(MatDividerBase);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling TestBed.createComponent in every test, set up a beforeEach block to do this setup.

let fixture: ComponentFixture;

beforeEach(() => {
fixture = TestBed.createComponent(MatDividerTestComponent);
});

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add

Comment thread src/lib/divider/divider.ts Outdated
* found in the LICENSE file at https://angular.io/license
*/

import {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put one import per line if it doesn't fit on a single line:

import {
  ChangeDetectionStrategy,
  Component,
  Input,
  ViewEncapsulation
} from '@angular/core';

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move

Comment thread src/lib/divider/divider.scss Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be inconsistent spacing between attributes, can you make the spacing more consistent?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix

Comment thread src/lib/divider/divider.scss Outdated
border-top: 0;
border-right-width: 1px;
border-right-style: solid;
position: static;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

position: static and width: auto should not be necessary as these are the default values on any custom element.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment thread src/lib/divider/divider.scss Outdated
}

&.mat-divider-inset {
margin-left: 80px;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this 80px size come from? Can you put in a comment explaining it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It came from AngularJS Material found here. baseline-grid = 8.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have an explanation for it, I couldn't find one in the original repo. Is there any way you can reach out to the internal UX team to find verification/justification?

Comment thread src/lib/divider/divider.scss Outdated
}

&.mat-divider-inset {
margin-left: 80px;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the inset's margin size, can you move the value (80px) into a variable at the top of the file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/lib/divider/divider.scss Outdated
.mat-divider {
display: block;
margin: 0;
border-top-width: 1px;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the dividers line width (based on the border width), can you move the value (1px) into a variable at the top of the file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread src/lib/divider/divider.scss Outdated
}
}

.mat-list-item {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rules specific to other components should be in the the respective component since it is an override specifically for the component.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add

Comment thread src/lib/divider/divider.ts Outdated
export class MatDivider {
/** Whether the divider is vertically aligned. */
@Input() get vertical(): boolean { return this._vertical; }
set vertical(value: boolean) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for both setter methods, you should be able to move them to a single line which might be a bit more readable.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@CaerusKaru
CaerusKaru force-pushed the divider branch 3 times, most recently from bc1c86b to 9ee8778 Compare November 10, 2017 01:31
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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

If combining both, please mMake sure to avoid adding an inset divider to the last element in a list, because it will overlap with the section divider

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/lib/card/card.scss
padding: $mat-card-default-padding;
border-radius: $mat-card-border-radius;

.mat-divider {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you separate the attributes from the rules here?

.mat-divider {
  position: absolute;
  left: 0;
  width: 100%;

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread src/lib/list/list.scss
padding: 4px;
}

.mat-divider {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you separate the attributes from the rules here?

.mat-divider {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;

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

  &.mat-divider-inset {
    left: $mat-list-item-inset-divider-offset;
    width: calc(100% - #{$mat-list-item-inset-divider-offset});
    margin: 0;

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

- 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

@josephperrott josephperrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@josephperrott josephperrott added merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Dec 13, 2017
@josephperrott

Copy link
Copy Markdown
Member

Caretaker Note: This change should be entirely transparent to end users, but we should take careful note on it to be sure that nothing changes as it is swapping out internal component usage.

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(divider): move divider out of mat-list please add md-divider to md-menu

9 participants