Skip to content

Commit 8f0aaea

Browse files
authored
Revert "feature(radio): Add ripple effect for radio buttons" (#1552)
1 parent 196bad7 commit 8f0aaea

File tree

6 files changed

+11
-53
lines changed

6 files changed

+11
-53
lines changed

src/lib/radio/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ The `md-radio-group` component has no button initially selected.
5757
| `aria-label` | `string` | Used to set the `aria-label` attribute of the underlying input element. |
5858
| `aria-labelledby` | `string` | Used to set the `aria-labelledby` attribute of the underlying input element.
5959
If provided, this attribute takes precedence as the element's text alternative. |
60-
| `disableRipple` | boolean | Whether the ripple effect when the radio button is clicked should be disabled
6160

6261
When checked, an event is emitted from the `change` EventEmitter property.
6362

src/lib/radio/_radio-theme.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
}
3030
}
3131

32-
.md-radio-focused .md-radio-ripple .md-ripple-foreground {
32+
// TODO(jelbourn): remove style for temporary ripple once the real ripple is applied.
33+
.md-radio-focused .md-ink-ripple {
3334
background-color: md-color($accent, 0.26);
3435
}
3536
}

src/lib/radio/radio.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<!-- TODO(jelbourn): render the radio on either side of the content -->
22
<!-- TODO(mtlin): Evaluate trade-offs of using native radio vs. cost of additional bindings. -->
33
<label [attr.for]="inputId" class="md-radio-label">
4-
54
<!-- The actual 'radio' part of the control. -->
65
<div class="md-radio-container">
76
<div class="md-radio-outer-circle"></div>
87
<div class="md-radio-inner-circle"></div>
9-
<div md-ripple *ngIf="isRippleEnabled()" class="md-radio-ripple"
10-
[md-ripple-trigger]="getHostElement()"
11-
[md-ripple-centered]="true"
12-
md-ripple-background-color="rgba(0, 0, 0, 0)"></div>
8+
<div class="md-ink-ripple"></div>
139
</div>
1410

1511
<input #input class="md-radio-input md-visually-hidden" type="radio"

src/lib/radio/radio.scss

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
$md-radio-size: $md-toggle-size !default;
6-
$md-radio-ripple-size: $md-radio-size * 0.75;
76

87
// Top-level host container.
98
md-radio-button {
@@ -90,12 +89,4 @@ md-radio-button {
9089
cursor: default;
9190
}
9291

93-
.md-radio-ripple {
94-
position: absolute;
95-
left: -$md-radio-ripple-size;
96-
top: -$md-radio-ripple-size;
97-
right: -$md-radio-ripple-size;
98-
bottom: -$md-radio-ripple-size;
99-
border-radius: 50%;
100-
z-index: 1;
101-
}
92+
@include md-temporary-ink-ripple(radio);

src/lib/radio/radio.spec.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,6 @@ describe('MdRadio', () => {
216216

217217
expect(radioInstances.every(radio => !radio.checked)).toBe(true);
218218
});
219-
220-
it('should remove ripple if md-ripple-disabled input is set', async(() => {
221-
fixture.detectChanges();
222-
for (let radioNativeElement of radioNativeElements)
223-
{
224-
expect(radioNativeElement.querySelectorAll('[md-ripple]').length).toBe(1);
225-
}
226-
227-
testComponent.disableRipple = true;
228-
fixture.detectChanges();
229-
for (let radioNativeElement of radioNativeElements)
230-
{
231-
expect(radioNativeElement.querySelectorAll('[md-ripple]').length).toBe(0);
232-
}
233-
}));
234219
});
235220

236221
describe('group with ngModel', () => {
@@ -441,25 +426,26 @@ describe('MdRadio', () => {
441426
});
442427
});
443428

429+
444430
@Component({
445431
template: `
446432
<md-radio-group [disabled]="isGroupDisabled"
447433
[align]="alignment"
448434
[value]="groupValue"
449435
name="test-name">
450-
<md-radio-button value="fire" [disableRipple]="disableRipple">Charmander</md-radio-button>
451-
<md-radio-button value="water" [disableRipple]="disableRipple">Squirtle</md-radio-button>
452-
<md-radio-button value="leaf" [disableRipple]="disableRipple">Bulbasaur</md-radio-button>
436+
<md-radio-button value="fire">Charmander</md-radio-button>
437+
<md-radio-button value="water">Squirtle</md-radio-button>
438+
<md-radio-button value="leaf">Bulbasaur</md-radio-button>
453439
</md-radio-group>
454440
`
455441
})
456442
class RadiosInsideRadioGroup {
457-
disableRipple: boolean = false;
458443
alignment: string;
459444
isGroupDisabled: boolean = false;
460445
groupValue: string = null;
461446
}
462447

448+
463449
@Component({
464450
template: `
465451
<md-radio-button name="season" value="spring">Spring</md-radio-button>
@@ -478,6 +464,7 @@ class RadiosInsideRadioGroup {
478464
})
479465
class StandaloneRadioButtons { }
480466

467+
481468
@Component({
482469
template: `
483470
<md-radio-group [(ngModel)]="modelValue" (change)="lastEvent = $event">

src/lib/radio/radio.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,23 @@ import {
33
Component,
44
ContentChildren,
55
Directive,
6-
ElementRef,
76
EventEmitter,
87
HostBinding,
98
Input,
109
OnInit,
1110
Optional,
1211
Output,
1312
QueryList,
14-
ViewChild,
1513
ViewEncapsulation,
1614
forwardRef,
1715
NgModule,
1816
ModuleWithProviders,
1917
} from '@angular/core';
20-
import {CommonModule} from '@angular/common';
2118
import {
2219
NG_VALUE_ACCESSOR,
2320
ControlValueAccessor
2421
} from '@angular/forms';
25-
import {BooleanFieldValue, MdRippleModule, MdUniqueSelectionDispatcher} from '../core';
22+
import {MdUniqueSelectionDispatcher} from '../core';
2623

2724

2825

@@ -261,9 +258,6 @@ export class MdRadioButton implements OnInit {
261258
/** The 'aria-labelledby' attribute takes precedence as the element's text alternative. */
262259
@Input('aria-labelledby') ariaLabelledby: string;
263260

264-
/** Whether the ripple effect on click should be disabled. */
265-
@Input() @BooleanFieldValue() disableRipple: boolean = false;
266-
267261
/** Whether this radio is disabled. */
268262
private _disabled: boolean;
269263

@@ -278,7 +272,6 @@ export class MdRadioButton implements OnInit {
278272
change: EventEmitter<MdRadioChange> = new EventEmitter<MdRadioChange>();
279273

280274
constructor(@Optional() radioGroup: MdRadioGroup,
281-
private _elementRef: ElementRef,
282275
public radioDispatcher: MdUniqueSelectionDispatcher) {
283276
// Assertions. Ideally these should be stripped out by the compiler.
284277
// TODO(jelbourn): Assert that there's no name binding AND a parent radio group.
@@ -418,19 +411,10 @@ export class MdRadioButton implements OnInit {
418411
this.radioGroup._touch();
419412
}
420413
}
421-
422-
getHostElement() {
423-
return this._elementRef.nativeElement;
424-
}
425-
426-
isRippleEnabled() {
427-
return !this.disableRipple;
428-
}
429414
}
430415

431416

432417
@NgModule({
433-
imports: [CommonModule, MdRippleModule],
434418
exports: [MdRadioGroup, MdRadioButton],
435419
declarations: [MdRadioGroup, MdRadioButton],
436420
})

0 commit comments

Comments
 (0)