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

refactor(button): Add ripple target as an inner element. #4890

Merged
merged 38 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
6e0afcf
feat(ripple): Add support for ripple target to mixins.
joyzhong Jul 8, 2019
edec5fc
Fix syntax error
joyzhong Jul 9, 2019
8f80edd
Fix ripple-target-selector mixin.
joyzhong Jul 9, 2019
cd9a089
ripple-target-selector=>ripple-target-string
joyzhong Jul 9, 2019
9021755
ripple-target-str=>ripple-target
joyzhong Jul 9, 2019
cfff73e
Fix
joyzhong Jul 9, 2019
80aec16
Fix comment.
joyzhong Jul 9, 2019
13320a2
Address comments.
joyzhong Jul 10, 2019
8197f79
Fix typo.
joyzhong Jul 10, 2019
2c9a37a
ripple-target=>ripple-target-selector
joyzhong Jul 10, 2019
4ffa363
Move button ripple target to an inner element.
joyzhong Jul 10, 2019
d8b7de9
Move button ripple target to inner element.
joyzhong Jul 10, 2019
621e2fd
Address comments
joyzhong Jul 10, 2019
8f1ee07
Refactor css/js-only selectors.
joyzhong Jul 10, 2019
3c113d1
Merge branch 'feat/ripple_target' into refactor/button_ripple
joyzhong Jul 10, 2019
da5a79e
Fix build error.
joyzhong Jul 10, 2019
b9a2aa8
Revert "Fix build error."
joyzhong Jul 10, 2019
4e52b54
Fix build error.
joyzhong Jul 10, 2019
646714a
Fix focus bug
joyzhong Jul 10, 2019
6ea0c1d
Merge branch 'feat/ripple_target' into refactor/button_ripple
joyzhong Jul 10, 2019
b749087
Merge remote-tracking branch 'origin/develop' into feat/ripple_target
joyzhong Jul 11, 2019
306f0c1
Break into separate lines.
joyzhong Jul 11, 2019
a372161
Merge branch 'feat/ripple_target' into refactor/button_ripple
joyzhong Jul 11, 2019
495e55a
Merge remote-tracking branch 'origin/develop' into refactor/button_ri…
joyzhong Jul 11, 2019
11a63ae
Update screenshots
joyzhong Jul 11, 2019
507860d
Fix IE11 ripple bug.
joyzhong Jul 11, 2019
d7b372b
Update screenshots
joyzhong Jul 11, 2019
cd24706
Add feature targeting for new button ripple CSS properties.
joyzhong Jul 11, 2019
282c791
Revert package-lock.json
joyzhong Jul 11, 2019
8fe98ad
Move border for outlined buttons to ripple target, to fix bug where r…
joyzhong Jul 11, 2019
87f069f
Fix custom border color and update screenshots.
joyzhong Jul 12, 2019
753eee7
Approve screenshot
joyzhong Jul 12, 2019
f098a82
Add transparent border to ripple target if outline is specified, to c…
joyzhong Jul 12, 2019
fac684f
Add back horizontal padding compensation
joyzhong Jul 12, 2019
fe94533
Fix typo
joyzhong Jul 12, 2019
5abf84e
Revert screenshots
joyzhong Jul 12, 2019
2e46d01
Fix
joyzhong Jul 12, 2019
597f6b3
Approve screenshot
joyzhong Jul 12, 2019
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
6 changes: 6 additions & 0 deletions packages/mdc-button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ npm install @material/button

```html
<button class="mdc-button">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">Button</span>
</button>
```
Expand Down Expand Up @@ -91,6 +92,7 @@ To add an icon, add an element with the `mdc-button__icon` class inside the butt

```html
<button class="mdc-button">
<div class="mdc-button__ripple"></div>
<i class="material-icons mdc-button__icon" aria-hidden="true">favorite</i>
<span class="mdc-button__label">Button</span>
</button>
Expand All @@ -100,6 +102,7 @@ It's also possible to use an SVG icon:

```html
<button class="mdc-button">
<div class="mdc-button__ripple"></div>
<svg class="mdc-button__icon" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="...">
...
</svg>
Expand All @@ -114,6 +117,7 @@ putting the icon markup _after_ the `mdc-button__label` element.

```html
<button class="mdc-button">
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">Button</span>
<i class="material-icons mdc-button__icon" aria-hidden="true">favorite</i>
</button>
Expand All @@ -128,6 +132,7 @@ Disabled buttons cannot be interacted with and have no visual interaction effect

```html
<button class="mdc-button" disabled>
<div class="mdc-button__ripple"></div>
<span class="mdc-button__label">Button</span>
</button>
```
Expand All @@ -139,6 +144,7 @@ Disabled buttons cannot be interacted with and have no visual interaction effect
CSS Class | Description
--- | ---
`mdc-button` | Mandatory. Defaults to a text button that is flush with the surface.
`mdc-button__ripple` | Mandatory. Indicates the element which shows the ripple styling.
`mdc-button--raised` | Optional. Styles a contained button that is elevated above the surface.
`mdc-button--unelevated` | Optional. Styles a contained button that is flush with the surface.
`mdc-button--outlined` | Optional. Styles an outlined button that is flush with the surface.
Expand Down
40 changes: 33 additions & 7 deletions packages/mdc-button/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
@import "@material/shape/functions";
@import "./variables";

$mdc-button-ripple-target: ".mdc-button__ripple";

@mixin mdc-button-core-styles($query: mdc-feature-all()) {
@include mdc-button-without-ripple($query);
@include mdc-button-ripple($query);
Expand Down Expand Up @@ -123,14 +125,24 @@
@include mdc-ripple-common($query);

.mdc-button {
@include mdc-ripple-surface($query);
@include mdc-ripple-radius-bounded($query: $query);
@include mdc-states(primary, false, $query);
@include mdc-ripple-surface($query: $query, $ripple-target: $mdc-button-ripple-target);
@include mdc-ripple-radius-bounded(
$query: $query, $ripple-target: $mdc-button-ripple-target);
@include mdc-states(
$color: primary, $query: $query, $ripple-target: $mdc-button-ripple-target);

#{$mdc-button-ripple-target} {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
}

.mdc-button--raised,
.mdc-button--unelevated {
@include mdc-states(on-primary, false, $query);
@include mdc-states(
$color: on-primary, $query: $query, $ripple-target: $mdc-button-ripple-target);
}
}

Expand All @@ -141,10 +153,12 @@

@if ($fill-tone == "dark") {
@include mdc-button-ink-color(text-primary-on-dark, $query);
@include mdc-states(text-primary-on-dark, $query: $query);
@include mdc-states(
$color: text-primary-on-dark, $query: $query, $ripple-target: $mdc-button-ripple-target);
} @else {
@include mdc-button-ink-color(text-primary-on-light, $query);
@include mdc-states(text-primary-on-light, $query: $query);
@include mdc-states(
$color: text-primary-on-light, $query: $query, $ripple-target: $mdc-button-ripple-target);
}
}

Expand Down Expand Up @@ -197,6 +211,14 @@
$query: $query
);

#{$mdc-button-ripple-target} {
@include mdc-shape-radius(
mdc-shape-resolve-percentage-radius($mdc-button-height, $radius),
$rtl-reflexive,
$query: $query
);
}

&.mdc-button--dense {
@include mdc-shape-radius(
mdc-shape-resolve-percentage-radius($mdc-dense-button-height, $radius),
Expand Down Expand Up @@ -252,7 +274,6 @@
line-height: inherit;
user-select: none;
-webkit-appearance: none;
overflow: hidden;
vertical-align: middle;
}

Expand Down Expand Up @@ -288,12 +309,17 @@
pointer-events: none;
}
}

.mdc-button__label {
joyzhong marked this conversation as resolved.
Show resolved Hide resolved
position: relative;
}
}

@mixin mdc-button__icon_ {
@include mdc-rtl-reflexive-box(margin, right, 8px);

display: inline-block;
position: relative;
width: 18px;
height: 18px;
font-size: 18px;
Expand Down
Loading