Skip to content

Commit 1f19ef0

Browse files
crisbetommalerba
authored andcommitted
fix(pseudo-checkbox): alignment issue and border color (#3144)
* fix(pseudo-checkbox): alignment issue and border color * Fixes an alignment issue with the pseudo checkboxes. Most likely caused by the `mat-` prefix changes or a faulty conflict resolution. * Fixes pseudo checkboxes not using the proper border color from the theme. * Adds the pseudo checkboxes to the checkbox demo for easier testing. * fix: address PR feedback
1 parent 634e414 commit 1f19ef0

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

src/demo-app/checkbox/checkbox-demo.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,15 @@ <h1>md-checkbox: Basic Example</h1>
4343
</div>
4444
</div>
4545

46+
<h1>Pseudo checkboxes</h1>
47+
<md-pseudo-checkbox></md-pseudo-checkbox>
48+
<md-pseudo-checkbox [disabled]="true"></md-pseudo-checkbox>
49+
50+
<md-pseudo-checkbox state="checked"></md-pseudo-checkbox>
51+
<md-pseudo-checkbox state="checked" [disabled]="true"></md-pseudo-checkbox>
52+
53+
<md-pseudo-checkbox state="indeterminate"></md-pseudo-checkbox>
54+
<md-pseudo-checkbox state="indeterminate" [disabled]="true"></md-pseudo-checkbox>
55+
4656
<h1>Nested Checklist</h1>
4757
<md-checkbox-demo-nested-checklist></md-checkbox-demo-nested-checklist>

src/demo-app/demo-app-module.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import {HttpModule} from '@angular/http';
44
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
55
import {DemoApp, Home} from './demo-app/demo-app';
66
import {RouterModule} from '@angular/router';
7-
import {MaterialModule, OverlayContainer, FullscreenOverlayContainer} from '@angular/material';
7+
import {
8+
MaterialModule,
9+
OverlayContainer,
10+
FullscreenOverlayContainer,
11+
MdSelectionModule,
12+
} from '@angular/material';
813
import {DEMO_APP_ROUTES} from './demo-app/routes';
914
import {ProgressBarDemo} from './progress-bar/progress-bar-demo';
1015
import {JazzDialog, ContentElementDialog, DialogDemo, IFrameDialog} from './dialog/dialog-demo';
@@ -47,6 +52,7 @@ import {StyleDemo} from './style/style-demo';
4752
ReactiveFormsModule,
4853
RouterModule.forRoot(DEMO_APP_ROUTES),
4954
MaterialModule.forRoot(),
55+
MdSelectionModule,
5056
],
5157
declarations: [
5258
AutocompleteDemo,
@@ -93,7 +99,7 @@ import {StyleDemo} from './style/style-demo';
9399
SunnyTabContent,
94100
RainyTabContent,
95101
FoggyTabContent,
96-
PlatformDemo
102+
PlatformDemo,
97103
],
98104
providers: [
99105
{provide: OverlayContainer, useClass: FullscreenOverlayContainer}

src/lib/checkbox/_checkbox-theme.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
$background: map-get($theme, background);
1010

1111

12-
// The color of the checkbox border.
13-
$checkbox-border-color: if($is-dark-theme, rgba(white, 0.7), rgba(black, 0.54)) !default;
14-
1512
// The color of the checkbox's checkmark / mixedmark.
1613
$checkbox-mark-color: mat-color($background, background);
1714

@@ -23,7 +20,7 @@
2320
$disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);
2421

2522
.mat-checkbox-frame {
26-
border-color: $checkbox-border-color;
23+
border-color: mat-color(map-get($theme, foreground), secondary-text);
2724
}
2825

2926
.mat-checkbox-checkmark {

src/lib/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@
88
$warn: map-get($theme, warn);
99
$background: map-get($theme, background);
1010

11-
// The color of the checkbox's checkmark / mixedmark.
12-
$checkbox-mark-color: mat-color($background, background);
13-
1411
// NOTE(traviskaufman): While the spec calls for translucent blacks/whites for disabled colors,
1512
// this does not work well with elements layered on top of one another. To get around this we
1613
// blend the colors together based on the base color and the theme background.
1714
$white-30pct-opacity-on-dark: #686868;
1815
$black-26pct-opacity-on-light: #b0b0b0;
1916
$disabled-color: if($is-dark-theme, $white-30pct-opacity-on-dark, $black-26pct-opacity-on-light);
2017

21-
.mat-pseudo-checkbox::after {
22-
color: $checkbox-mark-color;
18+
.mat-pseudo-checkbox {
19+
color: mat-color(map-get($theme, foreground), secondary-text);
20+
21+
&::after {
22+
color: mat-color($background, background);
23+
}
2324
}
2425

2526
.mat-pseudo-checkbox-checked, .mat-pseudo-checkbox-indeterminate {

src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ $_mat-pseudo-checkmark-size: $mat-checkbox-size - (2 * $_mat-pseudo-checkbox-pad
2929
border-bottom: $mat-checkbox-border-width solid currentColor;
3030
transition: opacity $mat-checkbox-transition-duration $mat-linear-out-slow-in-timing-function;
3131
}
32+
33+
&.mat-pseudo-checkbox-checked, &.mat-pseudo-checkbox-indeterminate {
34+
border: none;
35+
}
3236
}
3337

3438
.mat-pseudo-checkbox-disabled {

0 commit comments

Comments
 (0)