-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Conversation
e7d1a42
to
7c93bf2
Compare
@CaerusKaru in divider.scss you need to add: Otherwise the color will be black and not following the standard |
@Gustav0ar the color is set in _divider-theme.scss |
Ah, ok, my bad. I missed reviewing that file |
src/demo-app/list/list-demo.html
Outdated
@@ -22,6 +22,7 @@ <h3 mat-line>{{contact.name}}</h3> | |||
</mat-list-item> | |||
</mat-list> | |||
|
|||
<<<<<<< HEAD |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
917ce22
to
7da32ed
Compare
01aea89
to
06dd188
Compare
b8ed704
to
8647d64
Compare
@CaerusKaru if you rebase from master the errors should be resolved. |
Thanks @crisbeto, rebased and ready for review. |
There was a problem hiding this 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.
src/demo-app/card/card-demo.html
Outdated
<mat-divider [inset]="true"></mat-divider> | ||
<mat-card-actions> | ||
<button md-button>LIKE</button> | ||
<button md-button>SHARE</button> |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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
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 | |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/lib/divider/divider.md
Outdated
`<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) --> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
f5985ae
to
d55f5d4
Compare
}); | ||
}); | ||
|
||
@Component({ |
There was a problem hiding this comment.
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');
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great suggestions, added
src/lib/divider/divider.spec.ts
Outdated
})); | ||
|
||
it('should not apply any additional class to a list without lines', () => { | ||
const fixture = TestBed.createComponent(MatDividerBase); |
There was a problem hiding this comment.
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);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add
src/lib/divider/divider.ts
Outdated
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { |
There was a problem hiding this comment.
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';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will move
src/lib/divider/divider.scss
Outdated
|
||
.mat-list-item { | ||
.mat-divider { | ||
position: absolute; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix
src/lib/divider/divider.scss
Outdated
border-top: 0; | ||
border-right-width: 1px; | ||
border-right-style: solid; | ||
position: static; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
src/lib/divider/divider.scss
Outdated
} | ||
|
||
&.mat-divider-inset { | ||
margin-left: 80px; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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?
src/lib/divider/divider.scss
Outdated
} | ||
|
||
&.mat-divider-inset { | ||
margin-left: 80px; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/lib/divider/divider.scss
Outdated
.mat-divider { | ||
display: block; | ||
margin: 0; | ||
border-top-width: 1px; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/lib/divider/divider.scss
Outdated
} | ||
} | ||
|
||
.mat-list-item { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
bc1c86b
to
9ee8778
Compare
src/lib/divider/divider.md
Outdated
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
6da04fa
to
eeec51f
Compare
@@ -16,6 +16,20 @@ $mat-card-header-size: 40px !default; | |||
padding: $mat-card-default-padding; | |||
border-radius: $mat-card-border-radius; | |||
|
|||
.mat-divider { |
There was a problem hiding this comment.
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;
}
}
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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;
}
}
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Moves
mat-divider
out ofMatListModule
, replaced with temporary import to prevent breaking changes. Also includes support for inset and vertical dividers.Fixes #5524.
Fixes #2017.