-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/core): display checkmark for single-selection #25934
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/material/core/selection/pseudo-checkmark/_pseudo-checkmark-common.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@use 'sass:math'; | ||
@use '../../style/checkbox-common'; | ||
|
||
// Padding inside of a pseudo checkmark. | ||
$padding: checkbox-common.$border-width * 2; | ||
|
||
/// Applies the styles that set the size of the pseudo checkmark | ||
@mixin size($box-size) { | ||
.mat-pseudo-checkmark { | ||
width: $box-size; | ||
height: $box-size; | ||
} | ||
} | ||
|
||
/// Applies the legacy size styles to the pseudo-checkmark | ||
@mixin legacy-size() { | ||
@include size(check-common.$legacy-size); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/material/core/selection/pseudo-checkmark/_pseudo-checkmark-theme.import.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@forward '../../density/private/compatibility' as mat-*; | ||
@forward '../../theming/palette'; // TODO: hide unused colors | ||
@forward '../../theming/palette' as mat-*; // TODO: hide unused colors | ||
@forward '../../theming/theming' as mat-*; | ||
@import '../../theming/theming'; | ||
@forward 'pseudo-checkmark-theme' hide color, theme, typography; | ||
@forward 'pseudo-checkmark-theme' as mat-pseudo-checkmark-* hide mat-pseudo-checkmark-density; | ||
|
35 changes: 35 additions & 0 deletions
35
src/material/core/selection/pseudo-checkmark/_pseudo-checkmark-theme.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@use 'sass:map'; | ||
@use '../../theming/theming'; | ||
|
||
@mixin color($config-or-theme) { | ||
$config: theming.get-color-config($config-or-theme); | ||
$is-dark-theme: map.get($config, is-dark); | ||
$primary: map.get($config, primary); | ||
$accent: map.get($config, accent); | ||
$warn: map.get($config, warn); | ||
|
||
// TODO: implement colors | ||
} | ||
|
||
@mixin typography($config-or-theme) {} | ||
|
||
@mixin _density($config-or-theme) {} | ||
|
||
@mixin theme($theme-or-color-config) { | ||
$theme: theming.private-legacy-get-theme($theme-or-color-config); | ||
@include theming.private-check-duplicate-theme-styles($theme, 'mat-pseudo-checkmark') { | ||
$color: theming.get-color-config($theme); | ||
$density: theming.get-density-config($theme); | ||
$typography: theming.get-typography-config($theme); | ||
|
||
@if $color != null { | ||
@include color($color); | ||
} | ||
@if $density != null { | ||
@include _density($density); | ||
} | ||
@if $typography != null { | ||
@include typography($typography); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/material/core/selection/pseudo-checkmark/pseudo-checkmark-module.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {NgModule} from '@angular/core'; | ||
import {MatPseudoCheckmark} from './pseudo-checkmark'; | ||
import {MatCommonModule} from '../../common-behaviors/common-module'; | ||
|
||
@NgModule({ | ||
imports: [MatCommonModule], | ||
exports: [MatPseudoCheckmark], | ||
declarations: [MatPseudoCheckmark], | ||
}) | ||
export class MatPseudoCheckmarkModule {} |
30 changes: 30 additions & 0 deletions
30
src/material/core/selection/pseudo-checkmark/pseudo-checkmark.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// TODO: implement styles | ||
@use 'sass:math'; | ||
@use '../../style/checkbox-common'; | ||
@use '../../style/private'; | ||
@use '../../style/variables'; | ||
@use './pseudo-checkmark-common'; | ||
|
||
// TODO: implement a visual checkmark | ||
.mat-pseudo-checkmark { | ||
display: inline-block; | ||
box-sizing: border-box; | ||
position: relative; | ||
flex-shrink: 0; | ||
&::after { | ||
position: absolute; | ||
opacity: 0; | ||
font-family: monospace; | ||
content: '✔️'; // TODO: draw a checkmark with CSS. this is jsut a placeholder | ||
} | ||
|
||
&.mat-pseudo-checkmark-checked::after { | ||
opacity: 1; | ||
} | ||
} | ||
|
||
.mat-pseudo-checkmark-disabled { | ||
cursor: default; | ||
} | ||
|
||
@include pseudo-checkmark-common.size(checkbox-common.$size); |
55 changes: 55 additions & 0 deletions
55
src/material/core/selection/pseudo-checkmark/pseudo-checkmark.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { | ||
Component, | ||
ViewEncapsulation, | ||
Input, | ||
ChangeDetectionStrategy, | ||
Inject, | ||
Optional, | ||
} from '@angular/core'; | ||
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; | ||
|
||
export type MatPseudoCheckmarkState = 'unchecked' | 'checked'; | ||
|
||
/** | ||
* Component that shows a simplified checkmark without including any kind of "real" checkmark. | ||
* Meant to be used when the checkmark is purely decorative and a large number of them will be | ||
* included, such as for the options in a single-select. Uses no SVGs or complex animations. | ||
* Note that theming is meant to be handled by the parent element, e.g. | ||
* `mat-primary .mat-pseudo-checkmark`. | ||
* | ||
* Note that this component will be completely invisible to screen-reader users. This is *not* | ||
* interchangeable with `<mat-radio>` and should *not* be used if the user would directly | ||
* interact with the checkmark. The pseudo-checkmark should only be used as an implementation detail | ||
* of more complex components that appropriately handle selected / checked state. | ||
* @docs-private | ||
*/ | ||
@Component({ | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
selector: 'mat-pseudo-checkmark', | ||
styleUrls: ['pseudo-checkmark.css'], | ||
template: '', | ||
host: { | ||
'class': 'mat-pseudo-checkmark', | ||
'[class.mat-pseudo-checkmark-checked]': 'state === "checked"', | ||
'[class.mat-pseudo-checkmark-disabled]': 'disabled', | ||
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"', | ||
}, | ||
}) | ||
export class MatPseudoCheckmark { | ||
/** Display state of the checkbox. */ | ||
@Input() state: MatPseudoCheckmarkState = 'unchecked'; | ||
|
||
/** Whether the checkbox is disabled. */ | ||
@Input() disabled: boolean = false; | ||
|
||
constructor(@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.