Skip to content

Commit

Permalink
feat(checkbox): drive component with native checkbox (#415)
Browse files Browse the repository at this point in the history
Also fixes lack of visual focus state.

closes #250
  • Loading branch information
robertmesserle authored and jelbourn committed May 13, 2016
1 parent 7323e89 commit 10ac2be
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 223 deletions.
21 changes: 17 additions & 4 deletions src/components/checkbox/checkbox.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
<div class="md-checkbox-layout">
<label class="md-checkbox-layout">
<div class="md-checkbox-inner-container">
<input class="md-checkbox-input" type="checkbox"
[id]="inputId"
[checked]="checked"
[disabled]="disabled"
[name]="name"
[tabIndex]="tabindex"
[indeterminate]="indeterminate"
[attr.aria-label]="ariaLabel"
[attr.aria-labelledby]="ariaLabelledby"
(focus)="onInputFocus()"
(blur)="onInputBlur()"
(change)="onInteractionEvent($event)">
<div class="md-ink-ripple"></div>
<div class="md-checkbox-frame"></div>
<div class="md-checkbox-background">
<svg version="1.1"
Expand All @@ -16,7 +29,7 @@
<div class="md-checkbox-mixedmark"></div>
</div>
</div>
<label [id]="labelId">
<span class="md-checkbox-label">
<ng-content></ng-content>
</label>
</div>
</span>
</label>
18 changes: 12 additions & 6 deletions src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "default-theme";
@import "theme-functions";
@import "variables";
@import "mixins";

/** The width/height of the checkbox element. */
$md-checkbox-size: $md-toggle-size !default;
Expand Down Expand Up @@ -217,11 +218,8 @@ $_md-checkbox-indeterminate-checked-easing-function: cubic-bezier(0.14, 0, 0, 1)
}

md-checkbox {
cursor: pointer;

&:focus {
// TODO(traviskaufman): Add ink ripple on focus state, once ripple is implemented.
outline: none;
&, label {
cursor: pointer;
}
}

Expand Down Expand Up @@ -251,7 +249,7 @@ md-checkbox {
}

// TODO(kara): Remove this style when fixing vertical baseline
.md-checkbox-layout label {
.md-checkbox-layout .md-checkbox-label {
line-height: 24px;
}

Expand Down Expand Up @@ -461,3 +459,11 @@ md-checkbox {
}
}
}

// Underlying native input element.
// Visually hidden but still able to respond to focus.
.md-checkbox-input {
@include md-visually-hidden;
}

@include md-temporary-ink-ripple(checkbox);
Loading

0 comments on commit 10ac2be

Please sign in to comment.