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(card): Add theme mixins; remove content layouts #2025

Merged
merged 74 commits into from
Jan 26, 2018

Conversation

acdvorak
Copy link
Contributor

@acdvorak acdvorak commented Jan 20, 2018

BREAKING CHANGE: All CSS classes for content layouts have been removed. Clients should decide what kind of layout is best for their specific use case. Dark theme CSS classes have been removed; use the Sass mixin or custom CSS instead.

Fixes #1126

Updated README to match best practices.

Removed classes (12)

  • mdc-card--theme-dark
  • mdc-card__primary
  • mdc-card__title
  • mdc-card__title--large
  • mdc-card__subtitle
  • mdc-card__supporting-text
  • mdc-card__media-item
  • mdc-card__media-item--1dot5x
  • mdc-card__media-item--2x
  • mdc-card__media-item--3x
  • mdc-card__actions--vertical
  • mdc-card__horizontal-block

New classes (8)

  • mdc-card__media--square
  • mdc-card__media--16-9
  • mdc-card__media-content
  • mdc-card__actions--full-bleed
  • mdc-card__action-buttons
  • mdc-card__action-icons
  • mdc-card__action--button
  • mdc-card__action--icon

New mixins (3)

  • mdc-card-fill-color($color)
  • mdc-card-corner-radius($radius)
  • mdc-card-media-aspect-ratio($x, $y)

Screenshot (edited)

Annotated screenshot of new Card demo page

@codecov-io
Copy link

codecov-io commented Jan 20, 2018

Codecov Report

Merging #2025 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2025   +/-   ##
=======================================
  Coverage   99.43%   99.43%           
=======================================
  Files          84       84           
  Lines        3720     3720           
  Branches      486      486           
=======================================
  Hits         3699     3699           
  Misses         21       21

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c5018e...52e13ed. Read the comment docs.

acdvorak added a commit that referenced this pull request Jan 22, 2018
# INCLUDES #2025

## DO NOT MERGE until #2025 is merged first
acdvorak added a commit that referenced this pull request Jan 23, 2018
# INCLUDES #2025

## DO NOT MERGE until #2025 is merged first
demos/card.scss Outdated
@include mdc-ripple-radius;
@include mdc-states;

&:not([data-mdc-ripple-is-unbounded]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to just apply these styles to .demo-card-article instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Potentially, but if we ever decide to add another card example that uses
demo-card__ripple-surface on a different element, it won't get the benefit of the
IE/Edge workaround (position: relative).

data-toggle-off='{"content": "favorite_border", "label": "Add to favorites"}'>
favorite_border
</i>
<i class="material-icons mdc-card__action mdc-card__action--icon mdc-ripple-surface"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do something to make the padding of these consistent with the icon-toggle? They currently mismatch (and I'm fixing the unbounded ripple size in #2092 which will make the icon-toggle ripple the correct size).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@kfranqueiro kfranqueiro left a comment

Choose a reason for hiding this comment

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

RTL introduces a fun problem to your asymmetric rounded corners...

image

I'm unsure whether we'd want border radii to actually swap for RTL, but otherwise the case for the internals is less straightforward than inherit the way you set it up.

@acdvorak
Copy link
Contributor Author

Good catch on the RTL corner radius. Fixed it in the demo.


@mixin mdc-card-box-sizing_ {
&,
&::before,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need the ::before and ::after selectors on every single thing this mixin is applied to? I would only expect it to be needed on before/after for __action and possibly card itself assuming we have ripples on the whole card at some point.

Copy link
Contributor Author

@acdvorak acdvorak Jan 26, 2018

Choose a reason for hiding this comment

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

There's no direct need for it in mdc-card ATM.

However, per #1455, I'd like to try to start consistently applying border-box to all of our elements (and pseudo elements) so that there are no more surprises (for us or our clients).

I can't tell you how many times I've gone to add padding to something in MDC Web and had it end up bigger than I expected because of stupid content-box. I want to get to a place where we can just assume that all of our elements have a sane box-sizing by default (i.e., border-box), unless we specifically override it for some reason.

WDYT?

Copy link
Contributor

@kfranqueiro kfranqueiro Jan 26, 2018

Choose a reason for hiding this comment

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

I guess, but most of our elements don't have ::before and ::after unless they have ripples, which is why I thought that in particular seemed excessive. Keep in mind how much CSS this is adding because we're including this mixin multiple times, and it's being expanded to a full selector.

Maybe add a parameter to this mixin to conditionalize the inclusion of before/after in the selector? (There's an example of how to conditionalize the selector in the focus state styles in mdc-ripple/_mixins)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed offline: Libraries/frameworks generally should not mess with ::before and ::after unless absolutely necessary (e.g., mdc-ripple). This is to prevent conflicts with other libraries and client code which might also set styles on the pseudos.

Removed the mdc-card-box-sizing_ mixin and directly applied box-sizing: border-box to each element individually.

}
}

@mixin mdc-card-column-layout_($display: flex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of the display parameter existing if we never set it and we pretty much assume it's flex given the presence of flex-direction, anyway?

Actually, do we even need this mixin? AFAICT these styles don't affect anything on __media and __media-content so they're only actually needed once, on mdc-card...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed! Good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants