Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 21, 2017

Conversation

CaerusKaru
Copy link
Member

@CaerusKaru CaerusKaru commented Jul 19, 2017

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
Copy link

Gustav0ar commented Jul 21, 2017

@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
Member Author

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

@Gustav0ar
Copy link

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

@@ -22,6 +22,7 @@ <h3 mat-line>{{contact.name}}</h3>
</mat-list-item>
</mat-list>

<<<<<<< HEAD
Copy link
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
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 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
Member

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

@CaerusKaru
Copy link
Member Author

Thanks @crisbeto, rebased and ready for review.

Copy link

@ghost ghost left a comment

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.

<mat-divider [inset]="true"></mat-divider>
<mat-card-actions>
<button md-button>LIKE</button>
<button md-button>SHARE</button>
Copy link

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.

@@ -31,6 +31,7 @@ <h4 mat-line>{{message.from}}</h4>
<span>{{message.subject}} -- </span>
<span class="demo-secondary-text">{{message.message}}</span>
</p>
<mat-divider [inset]="true" *ngIf="!last"></mat-divider>
Copy link

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

| 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
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
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
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
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
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
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
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
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');
});

Copy link
Member Author

@CaerusKaru CaerusKaru Nov 10, 2017

Choose a reason for hiding this comment

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

Great suggestions, added

}));

it('should not apply any additional class to a list without lines', () => {
const fixture = TestBed.createComponent(MatDividerBase);
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Will add

* found in the LICENSE file at https://angular.io/license
*/

import {
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Will move


.mat-list-item {
.mat-divider {
position: absolute;
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Will fix

border-top: 0;
border-right-width: 1px;
border-right-style: solid;
position: static;
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Removed

}

&.mat-divider-inset {
margin-left: 80px;
Copy link
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
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
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?

}

&.mat-divider-inset {
margin-left: 80px;
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Done

.mat-divider {
display: block;
margin: 0;
border-top-width: 1px;
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Done

}
}

.mat-list-item {
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Will add

export class MatDivider {
/** Whether the divider is vertically aligned. */
@Input() get vertical(): boolean { return this._vertical; }
set vertical(value: boolean) {
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Fixed

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
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
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -16,6 +16,20 @@ $mat-card-header-size: 40px !default;
padding: $mat-card-default-padding;
border-radius: $mat-card-border-radius;

.mat-divider {
Copy link
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
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -116,6 +118,26 @@ $mat-dense-list-icon-size: 20px;
border-radius: 50%;
padding: 4px;
}

.mat-divider {
Copy link
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
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
Copy link
Member

@josephperrott josephperrott left a comment

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

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