-
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
fix(divider): add inset styles for icons and lists in cards #9242
Conversation
src/lib/list/list.scss
Outdated
// size of the parent class (e.g. avatar vs icon) | ||
@mixin mat-inset-divider-offset($offset) { | ||
$mat-list-item-inset-divider-offset: #{(2 * $mat-list-side-padding) + $offset}; | ||
left: $mat-list-item-inset-divider-offset; |
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.
Why is this one using left
/right
, whereas the default divider styles are using margin-left
/margin-right
?
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.
Changed, the reason was that it was legacy from AngularJS Material
src/lib/list/list.scss
Outdated
$mat-list-item-inset-divider-offset: 72px; | ||
// This mixin provides the correct offset for an inset divider based on the | ||
// size of the parent class (e.g. avatar vs icon) | ||
@mixin mat-inset-divider-offset($offset) { |
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.
The mixin should live somewhere in the divider module since it could be used in other modules that consume 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.
Moved
src/lib/list/list.scss
Outdated
@@ -27,7 +28,18 @@ $mat-dense-three-line-height: 76px; | |||
$mat-dense-multi-line-padding: 16px; | |||
$mat-dense-list-icon-size: 20px; | |||
|
|||
$mat-list-item-inset-divider-offset: 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.
Removing this is a breaking change, even though it isn't being used anywhere.
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.
Since mat-divider
hasn't been merged into the minor version yet, can we still remove it? Happy to keep it as a placeholder otherwise
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 could still be used from when the divider was in the list module.
src/lib/list/list.scss
Outdated
left: auto; | ||
right: $mat-list-item-inset-divider-offset; | ||
} | ||
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.
The position: absolute
is defined in the parent rule above, you don't have to add it to .mat-divider-inset
. Also the nesting here isn't necessary.
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 was present to override a similar position: static
in the mat-card
styles. I added an !important
tag instead with a note for why it's there. I can add the nested structure back if you prefer to not have !important
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.
In that case it can at least use a comment about why the nesting was necessary.
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.
Perfect, will add
src/lib/list/list.scss
Outdated
@@ -27,7 +28,18 @@ $mat-dense-three-line-height: 76px; | |||
$mat-dense-multi-line-padding: 16px; | |||
$mat-dense-list-icon-size: 20px; | |||
|
|||
$mat-list-item-inset-divider-offset: 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.
It could still be used from when the divider was in the list module.
src/lib/list/list.scss
Outdated
} | ||
|
||
.mat-divider { | ||
position: absolute; | ||
position: absolute !important; // this is done to override card inset styles |
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 using !important
, perhaps the selector can be made more specific or the card one can be less specific?
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.
The original nesting was the way to make it more specific. I don't think that modifying the card styles will be as elegant. I'll add back the nesting for now unless you have an alternative suggestion
b6536fc
to
2f35ebe
Compare
@crisbeto I'm not entirely sure why the Bazel build is failing on Circle CI (I know it's because it doesn't like how I'm including the divider style file). Do you know what's going on? |
I'm not too sure about that error @CaerusKaru, my guess is that you'd need to add another item to the |
1401968
to
b864c92
Compare
@crisbeto I fixed the Bazel issues and rebased with master. Ready for review again. |
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
* Add mixin to dynamically apply inset divider offset based on the precursor in the list item * Add inset divider example using icons as precursor
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
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. |
the precursor in the list item
Fixes #9233