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

fix(divider): add inset styles for icons and lists in cards #9242

Merged
merged 1 commit into from
Jan 31, 2018

Conversation

CaerusKaru
Copy link
Member

  • Add mixin to dynamically apply inset divider offset based on
    the precursor in the list item
  • Add inset divider example using icons as precursor

Fixes #9233

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 5, 2018
@CaerusKaru
Copy link
Member Author

Circle CI build error is unrelated to this PR

cc @jelbourn @crisbeto

// 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;
Copy link
Member

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?

Copy link
Member Author

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

$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) {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved

@@ -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;
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member

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.

left: auto;
right: $mat-list-item-inset-divider-offset;
}
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.

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.

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

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Perfect, will add

@@ -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;
Copy link
Member

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.

}

.mat-divider {
position: absolute;
position: absolute !important; // this is done to override card inset styles
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 using !important, perhaps the selector can be made more specific or the card one can be less specific?

Copy link
Member Author

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

@CaerusKaru CaerusKaru force-pushed the div-fix branch 8 times, most recently from b6536fc to 2f35ebe Compare January 6, 2018 21:51
@CaerusKaru
Copy link
Member Author

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

@crisbeto
Copy link
Member

crisbeto commented Jan 8, 2018

I'm not too sure about that error @CaerusKaru, my guess is that you'd need to add another item to the deps array.

@CaerusKaru
Copy link
Member Author

@crisbeto I tried adding the divider scss rule to the deps array, but that's what Bazel is complaining about. @jelbourn Any thoughts?

@CaerusKaru CaerusKaru force-pushed the div-fix branch 5 times, most recently from 1401968 to b864c92 Compare January 8, 2018 21:50
@CaerusKaru
Copy link
Member Author

@crisbeto I fixed the Bazel issues and rebased with master. Ready for review again.

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jan 9, 2018
@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Jan 9, 2018
* Add mixin to dynamically apply inset divider offset based on
  the precursor in the list item
* Add inset divider example using icons as precursor
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(mat-divider): wrong styling
5 participants