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 primary action element with hover, focused, and pressed states #2039

Merged
merged 99 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from 89 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
f9e256f
chore(card): Remove layouts (WIP)
acdvorak Jan 18, 2018
d7c537f
WIP: Add __action-buttons and __action-icons classes
acdvorak Jan 18, 2018
1cbe378
WIP: Refactoring
acdvorak Jan 18, 2018
d3bace3
WIP: Add __media classes, rename other classes
acdvorak Jan 18, 2018
51fa44d
WIP: Rename classes
acdvorak Jan 18, 2018
d363411
WIP: Refactoring and add "Share" action icon
acdvorak Jan 18, 2018
4c08741
feat(base): shouldBubble now defaults to `true`
acdvorak Jan 19, 2018
aac2ca2
WIP: Spec alignment
acdvorak Jan 19, 2018
3604c49
WIP: Add example of a "small" card
acdvorak Jan 19, 2018
da234a4
WIP: Add music album example
acdvorak Jan 19, 2018
059a325
WIP: Rename class, reorder styles
acdvorak Jan 19, 2018
b6a5993
WIP: Add margin between buttons and icons
acdvorak Jan 19, 2018
e27c1c1
WIP: Start updating README
acdvorak Jan 19, 2018
e41ddbf
Merge branch 'master' into chore/card/remove-layouts
acdvorak Jan 20, 2018
bb574cc
WIP: Update cards on theme demo page
acdvorak Jan 20, 2018
0bcb922
WIP: Fix example card background colors
acdvorak Jan 20, 2018
aeaa446
WIP: Add mixins; refactor
acdvorak Jan 20, 2018
482dbe8
WIP: Update README
acdvorak Jan 20, 2018
06c0920
WIP: Set elevation color automatically
acdvorak Jan 20, 2018
1750a9f
WIP: Removed unused CSS class
acdvorak Jan 20, 2018
c9b6278
Revert "feat(base): shouldBubble now defaults to `true`"
acdvorak Jan 20, 2018
86f2083
Merge remote-tracking branch 'origin/master' into chore/card/remove-l…
acdvorak Jan 22, 2018
6fb8e12
WIP: __media inherits border-radius from card; add radius mixin
acdvorak Jan 22, 2018
0cb61b0
WIP: Remove mdc-card-corner-radius mixin
acdvorak Jan 23, 2018
3997ad8
feat(card): Add `mdc-card__primary-action` with states
acdvorak Jan 23, 2018
4bbfd02
Revert "WIP: Remove mdc-card-corner-radius mixin"
acdvorak Jan 23, 2018
dc4c5c3
WIP: Rename `__action-bar` to `__actions` for backward compatibility
acdvorak Jan 23, 2018
6f4acb8
WIP: Reorder mixins
acdvorak Jan 23, 2018
6836c5e
Merge remote-tracking branch 'origin/master' into chore/card/remove-l…
acdvorak Jan 23, 2018
1f32dcd
WIP: Don't override elevation color
acdvorak Jan 23, 2018
974edd6
Merge remote-tracking branch 'origin/master' into chore/card/remove-l…
acdvorak Jan 24, 2018
8ce2bac
WIP: Minor cleanup
acdvorak Jan 24, 2018
5a72bf1
Merge branch 'master' into chore/card/remove-layouts
acdvorak Jan 24, 2018
6c5970f
WIP: Fix ripple overflow bug in IE 11 and Edge on demo page
acdvorak Jan 24, 2018
dafbd04
WIP: Don't wrap icons in mdc-button
acdvorak Jan 24, 2018
8f0db4d
WIP: Use # and preventDefault instead of "javascript:" links
acdvorak Jan 24, 2018
9fdced1
WIP: Don't use event delegation for a single element
acdvorak Jan 24, 2018
45e98de
WIP: Remove TODO
acdvorak Jan 24, 2018
414c981
WIP: Replace javascript: with # in readme example
acdvorak Jan 24, 2018
87980a4
WIP: Clarify that `mdc-card` is mandatory
acdvorak Jan 24, 2018
c0f4e51
WIP: Rename mixin params
acdvorak Jan 24, 2018
b7627db
WIP: Rewording
acdvorak Jan 24, 2018
49469c0
WIP: Refactoring
acdvorak Jan 24, 2018
24b794b
WIP: Fix button margins
acdvorak Jan 25, 2018
fa9073b
WIP: Add __action--button class to avoid violating BEM
acdvorak Jan 25, 2018
420a1ec
WIP: Fix action button margins
acdvorak Jan 25, 2018
ff57974
WIP: Remove unnecessary <span> element and use correct aria attr
acdvorak Jan 25, 2018
f4731c1
WIP: Semantic HTML: Use <div> instead of <section> for card areas
acdvorak Jan 25, 2018
70e7c49
WIP: Always use mdc-card__action--button class on buttons
acdvorak Jan 25, 2018
3364d96
WIP: Update wording in README
acdvorak Jan 25, 2018
75f81dc
WIP: Simplify example in README
acdvorak Jan 25, 2018
137b74d
WIP: Clean up README
acdvorak Jan 25, 2018
7c0f775
WIP: Set `box-sizing: border-box` and `display: flex` on all elements
acdvorak Jan 25, 2018
51de056
WIP: Set `color` explicitly on `__action--icon` rather than inheritin…
acdvorak Jan 25, 2018
689290d
WIP: Use <div> instead of <section>
acdvorak Jan 25, 2018
1503a2f
WIP: Simplify icon-only action row example
acdvorak Jan 25, 2018
90840cf
WIP: Refactor `align-items: center` into `mdc-card-row-layout_` mixin
acdvorak Jan 25, 2018
0a81243
Merge remote-tracking branch 'origin/master' into chore/card/remove-l…
acdvorak Jan 25, 2018
3c5f572
WIP: Reorder ready.js import in <head>
acdvorak Jan 25, 2018
fc36930
WIP: Remove preventDefault for dummy links
acdvorak Jan 25, 2018
f177ce0
WIP: Import common.js
acdvorak Jan 25, 2018
25a70ca
WIP: Update theme demo page markup
acdvorak Jan 25, 2018
3a74182
WIP: Simplify theme demo page example
acdvorak Jan 25, 2018
d26281d
Merge remote-tracking branch 'origin/master' into chore/card/remove-l…
acdvorak Jan 25, 2018
8e24e56
WIP: Add `user-select: none` to `mdc-card__action`
acdvorak Jan 25, 2018
cf07755
WIP: Use padding instead of margin on __action--icon
acdvorak Jan 25, 2018
4ed5f6a
WIP: Fix import and remove unneeded class
acdvorak Jan 25, 2018
d36e518
WIP: Fix action bar height by applying negative margin to all __actio…
acdvorak Jan 25, 2018
2576113
Merge branch 'chore/card/remove-layouts' into feat/card/states
acdvorak Jan 26, 2018
4f0958c
WIP: Add data-hot attr to stylesheet element
acdvorak Jan 26, 2018
5bce402
WIP: Remove extra element from merge conflict
acdvorak Jan 26, 2018
f0eb759
WIP: Inherit color and disable underline for __primary-action
acdvorak Jan 26, 2018
0129f53
WIP: Remove unneeded style property
acdvorak Jan 26, 2018
2cba692
WIP: Fix README indentation of code examples
acdvorak Jan 26, 2018
fdd4eb1
WIP: Fix indentation
acdvorak Jan 26, 2018
8f000b6
WIP: Show custom corner radius; rename demo classes
acdvorak Jan 26, 2018
379c541
Merge branch 'chore/card/remove-layouts' into feat/card/states
acdvorak Jan 26, 2018
baacdd2
Merge remote-tracking branch 'origin/master' into feat/card/states
acdvorak Jan 26, 2018
2069984
WIP: Fix __media element height
acdvorak Jan 26, 2018
c498e8b
WIP: Remove unnecessary :focus selector
acdvorak Jan 26, 2018
0a96446
WIP: Remove unnecessary `width: 100%`
acdvorak Jan 26, 2018
70d23bf
WIP: Fix merge conflicts
acdvorak Jan 26, 2018
70e0e90
WIP: Add `border-box` to __primary-action
acdvorak Jan 26, 2018
9050309
WIP: Fix merge conflict in README
acdvorak Jan 26, 2018
276b221
WIP: Update wording in README
acdvorak Jan 26, 2018
1a0ac4d
WIP: Remove `data-hot` attr (create new PR instead)
acdvorak Jan 26, 2018
bdba1d8
Merge branch 'master' into feat/card/states
acdvorak Jan 27, 2018
671f128
Merge remote-tracking branch 'origin' into feat/card/states
acdvorak Feb 6, 2018
17fb14f
WIP: Fix broken build by updating mixin name
acdvorak Feb 6, 2018
d1563ce
WIP: Clarify usage of `__primary-action` in README
acdvorak Feb 6, 2018
5659d54
WIP: Remove unnecessary `0`
acdvorak Feb 6, 2018
6a30d54
WIP: Move flexbox styles from __media to __primary-action
acdvorak Feb 6, 2018
e3648a8
WIP: Move common code into mixin
acdvorak Feb 6, 2018
aff87a1
WIP: Compat for IE, Edge, and Safari
acdvorak Feb 6, 2018
d1b92bc
Merge remote-tracking branch 'origin' into feat/card/states
acdvorak Feb 6, 2018
9287220
WIP: Move box-sizing into layout mixins
acdvorak Feb 6, 2018
9a74141
WIP: Remove min-width from __action
acdvorak Feb 6, 2018
5080a86
WIP: Move justify-content out of mixin into __action
acdvorak Feb 6, 2018
941c6f0
WIP: Add cursor:pointer to __primary-action
acdvorak Feb 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions demos/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@

<section class="hero">
<div class="mdc-card demo-card">
<div class="mdc-card__media mdc-card__media--16-9 demo-card__media demo-card__media--16-9"></div>
<div class="demo-card__primary">
<h2 class="demo-card__title mdc-typography--title">Our Changing Planet</h2>
<h3 class="demo-card__subtitle mdc-typography--subheading1">by Kurt Wagner</h3>
</div>
<div class="demo-card__secondary mdc-typography--body1">
Visit ten places on our planet that are undergoing the biggest changes today.
</div>
<a class="mdc-card__primary-action" href="#">
<div class="mdc-card__media mdc-card__media--16-9 demo-card__media demo-card__media--16-9"></div>
<div class="demo-card__primary">
<h2 class="demo-card__title mdc-typography--title">Our Changing Planet</h2>
<h3 class="demo-card__subtitle mdc-typography--subheading1">by Kurt Wagner</h3>
</div>
<div class="demo-card__secondary mdc-typography--body1">
Visit ten places on our planet that are undergoing the biggest changes today.
</div>
</a>
<div class="mdc-card__actions">
<div class="mdc-card__action-buttons">
<button class="mdc-button mdc-card__action mdc-card__action--button">Read</button>
Expand Down Expand Up @@ -142,13 +144,15 @@ <h2 class="demo-card-article__title mdc-typography--headline">Asia's clean energ
</div>

<div class="mdc-card demo-card demo-card--photo">
<div class="mdc-card__media mdc-card__media--square demo-card__media">
<div class="mdc-card__media-content demo-card__media-content--with-title">
<div class="demo-card__media-title mdc-typography--subheading2">
Vacation Photos
<a class="mdc-card__primary-action demo-card__primary-action" href="#">
<div class="mdc-card__media mdc-card__media--square demo-card__media">
<div class="mdc-card__media-content demo-card__media-content--with-title">
<div class="demo-card__media-title mdc-typography--subheading2">
Vacation Photos
</div>
</div>
</div>
</div>
</a>
<div class="mdc-card__actions mdc-card__action-icons">
<i class="mdc-icon-toggle material-icons mdc-card__action mdc-card__action--icon"
tabindex="0"
Expand Down Expand Up @@ -179,14 +183,16 @@ <h2 class="demo-card-article__title mdc-typography--headline">Asia's clean energ
</div>

<div class="mdc-card demo-card demo-card--music">
<div class="demo-card__music-row">
<div class="mdc-card__media mdc-card__media--square demo-card__media demo-card__media--music"></div>
<div class="demo-card__music-info">
<div class="demo-card__music-title mdc-typography--headline">Rozes</div>
<div class="demo-card__music-artist mdc-typography--body1">Under the Grave</div>
<div class="demo-card__music-year mdc-typography--body1">(2016)</div>
<a class="mdc-card__primary-action demo-card__primary-action" href="#">
<div class="demo-card__music-row">
<div class="mdc-card__media mdc-card__media--square demo-card__media demo-card__media--music"></div>
<div class="demo-card__music-info">
<div class="demo-card__music-title mdc-typography--headline">Rozes</div>
<div class="demo-card__music-artist mdc-typography--body1">Under the Grave</div>
<div class="demo-card__music-year mdc-typography--body1">(2016)</div>
</div>
</div>
</div>
</a>
<hr class="mdc-list-divider">
<div class="mdc-card__actions">
<div class="mdc-card__action-buttons demo-card__action-buttons--text-only">Rate this album</div>
Expand Down Expand Up @@ -256,6 +262,10 @@ <h2 class="demo-card-article__title mdc-typography--headline">Asia's clean energ
[].forEach.call(document.querySelectorAll('.mdc-ripple-surface'), function(surface) {
mdc.ripple.MDCRipple.attachTo(surface);
});

[].forEach.call(document.querySelectorAll('.mdc-card__primary-action'), function(el) {
mdc.ripple.MDCRipple.attachTo(el);
});
});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion demos/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@

.demo-card__media--music {
width: 110px;
border-top-left-radius: inherit; // for music card
border-top-left-radius: inherit;

@include mdc-rtl {
border-top-left-radius: 0;
Expand Down
1 change: 1 addition & 0 deletions packages/mdc-card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ CSS Class | Description
--- | ---
`mdc-card` | Mandatory, for the card element
`mdc-card--stroked` | Removes the shadow and displays a hairline stroke instead
`mdc-card__primary-action` | The main tappable area of the card. Typically contains most (or all) card content _except_ `mdc-card__actions`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to further qualify that this is only applicable to cards that have a primary action that the main surface should trigger?

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

`mdc-card__media` | Media area that displays a custom `background-image` with `background-size: cover`
`mdc-card__media--square` | Automatically scales the media area's height to equal its width
`mdc-card__media--16-9` | Automatically scales the media area's height according to its width, maintaining a 16:9 aspect ratio
Expand Down
28 changes: 28 additions & 0 deletions packages/mdc-card/mdc-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
.mdc-card__media {
@include mdc-card-media-aspect-ratio-base_;

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.

I'm not sure this makes much sense here, but also it seems like it would make more sense (and also work) if we added display / flex-direction to .mdc-card__primary-action instead.

In fact the 3 styles (not counting mixins) currently applied to mdc-card should maybe just be put in a selector that applies to both mdc-card and mdc-card__primary-action?

position: relative;
flex-direction: column;
box-sizing: border-box;
background-repeat: no-repeat;
background-size: cover;
Expand Down Expand Up @@ -81,6 +83,32 @@
box-sizing: border-box;
}

//
// Primary action
//

.mdc-card__primary-action {
@include mdc-ripple-surface;
@include mdc-ripple-radius-bounded;
@include mdc-states;

box-sizing: border-box;
outline: 0 none;
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the 0 here redundant?

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

color: inherit;
text-decoration: none;
overflow: hidden;
}

.mdc-card__primary-action:first-child {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
}

.mdc-card__primary-action:last-child {
border-bottom-left-radius: inherit;
border-bottom-right-radius: inherit;
}

//
// Action row
//
Expand Down