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: abstract checkbox presentation to standalone component #2590

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 0 additions & 62 deletions src/lib/checkbox/_checkbox-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,9 @@


@mixin md-checkbox-theme($theme) {
$is-dark-theme: map-get($theme, is-dark);
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);
$background: map-get($theme, background);


// The color of the checkbox border.
$checkbox-border-color: if($is-dark-theme, rgba(white, 0.7), rgba(black, 0.54)) !default;

// The color of the checkbox's checkmark / mixedmark.
$checkbox-mark-color: md-color($background, background);

// NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors,
// this does not work well with elements layered on top of one another. To get around this we
// blend the colors together based on the base color and the theme background.
$white-30pct-opacity-on-dark: #686868;
$black-26pct-opacity-on-light: #b0b0b0;
$disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);

.md-checkbox-frame {
border-color: $checkbox-border-color;
}

.md-checkbox-checkmark {
fill: $checkbox-mark-color;
}

.md-checkbox-checkmark-path {
// !important is needed here because a stroke must be set as an attribute on the SVG in order
// for line animation to work properly.
stroke: $checkbox-mark-color !important;
}

.md-checkbox-mixedmark {
background-color: $checkbox-mark-color;
}

.md-checkbox-indeterminate, .md-checkbox-checked {
&.md-primary .md-checkbox-background {
background-color: md-color($primary, 500);
}

&.md-accent .md-checkbox-background {
background-color: md-color($accent, 500);
}

&.md-warn .md-checkbox-background {
background-color: md-color($warn, 500);
}
}

.md-checkbox-disabled {
&.md-checkbox-checked, &.md-checkbox-indeterminate {
.md-checkbox-background {
background-color: $disabled-color;
}
}

&:not(.md-checkbox-checked) {
.md-checkbox-frame {
border-color: $disabled-color;
}
}
}

.md-checkbox:not(.md-checkbox-disabled) {
&.md-primary .md-checkbox-ripple .md-ripple-foreground {
Expand Down
21 changes: 6 additions & 15 deletions src/lib/checkbox/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,12 @@
[mdRippleCentered]="true"
[mdRippleSpeedFactor]="0.3"
mdRippleBackgroundColor="rgba(0, 0, 0, 0)"></div>
<div class="md-checkbox-frame"></div>
<div class="md-checkbox-background">
<svg version="1.1"
class="md-checkbox-checkmark"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
xml:space="preserve">
<path class="md-checkbox-checkmark-path"
fill="none"
stroke="white"
d="M4.1,12.7 9,17.6 20.3,6.3"/>
</svg>
<!-- Element for rendering the indeterminate state checkbox. -->
<div class="md-checkbox-mixedmark"></div>
</div>

<md-pseudo-checkbox
[color]="color"
[checked]="checked"
[indeterminate]="indeterminate"
[disabled]="disabled"></md-pseudo-checkbox>
</div>
<span class="md-checkbox-label">
<ng-content></ng-content>
Expand Down
Loading