Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 01351b1

Browse files
committedJul 31, 2020
fix(chips): update to latest Material Design spec (2017) updates
- use the `md-cancel` button instead of the `md-close` button - `$chip-font-size` reduced to `13px` from `16px` - `$chip-remove-padding-right` increased to `28px` from `22px` - in light mode, remove chip icon should be black w/ 87% opacity - update custom remove chip template demo - show remove icon on hover/focus only - remove unnecessary CSS - update to new size guidelines and remove color on hover/focus - fix remove chip icon color when chip is focused Fixes #9883 BREAKING CHANGE: Chips have been updated to latest Material Design spec (2017). `$chip-font-size` was reduced to `13px` from `16px`. `$chip-remove-padding-right` was increased to `28px` from `22px`. These changes may cause your chips to have a smaller, denser layout now. In certain scenarios, this may require minor changes to your app's layout. You can change these variables back to their old values if your app consumes Sass. Additionally, the remove chip icon has been changed, but you can use the custom chip template demo as a guide to changing back to the old icon, if desired.
1 parent 47106ba commit 01351b1

File tree

6 files changed

+34
-39
lines changed

6 files changed

+34
-39
lines changed
 

‎src/components/chips/chips-theme.scss

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ md-chips.md-THEME_NAME-theme {
3737
color: '{{background-800}}';
3838
}
3939
}
40-
md-chip-remove {
41-
.md-button {
42-
md-icon {
43-
path {
44-
fill: '{{background-500}}';
40+
.md-chip-remove-container {
41+
button {
42+
&md-chip-remove,
43+
&.md-chip-remove {
44+
md-icon {
45+
color: '{{foreground-2}}';
46+
fill: '{{foreground-2}}';
4547
}
4648
}
4749
}

‎src/components/chips/chips.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
$chip-font-size: rem(1.6) !default;
1+
$chip-font-size: rem(1.3) !default;
22
$chip-height: rem(3.2) !default;
33
$chip-padding: 0 rem(1.2) 0 rem(1.2) !default;
44
$chip-input-padding: 0 !default;
5-
$chip-remove-padding-right: rem(2.2) !default;
5+
$chip-remove-padding-right: rem(2.8) !default;
66
$chip-remove-line-height: rem(2.2) !default;
77
$chip-margin: rem(0.8) rem(0.8) 0 0 !default;
88
$chip-wrap-padding: 0 0 rem(0.8) rem(0.3) !default;

‎src/components/chips/demoBasicUsage/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h2 class="md-title">Display an ordered set of objects as chips (with custom tem
6969
<em>({{$chip.type}})</em>
7070
</span>
7171
</md-chip-template>
72-
<button md-chip-remove class="md-primary vegetablechip" aria-label="Remove {{$chip.name}}">
72+
<button md-chip-remove class="demo-remove-vegetable-chip" aria-label="Remove {{$chip.name}}">
7373
<md-icon md-svg-icon="md-close"></md-icon>
7474
</button>
7575
</md-chips>

‎src/components/chips/demoBasicUsage/style.scss

+18-25
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,43 @@
33
color: rgb(221,44,0);
44
margin-top: 10px;
55
}
6-
76
.custom-chips {
87
md-chip {
98
position: relative;
9+
padding-right: 24px;
10+
1011
.md-chip-remove-container {
1112
position: absolute;
1213
right: 4px;
1314
top: 4px;
1415
margin-right: 0;
15-
height: 24px;
16-
button.vegetablechip {
16+
height: 26px;
17+
display: none;
18+
19+
button.demo-remove-vegetable-chip {
1720
position: relative;
1821
height: 24px;
1922
width: 24px;
2023
line-height: 30px;
21-
text-align: center;
22-
background: rgba(black, 0.3);
23-
border-radius: 50%;
24+
background: transparent;
2425
border: none;
25-
box-shadow: none;
2626
padding: 0;
27-
margin: 0;
28-
transition: background 0.15s linear;
29-
display: block;
27+
3028
md-icon {
31-
position: absolute;
32-
top: 50%;
33-
left: 50%;
34-
transform: translate3d(-50%, -50%, 0) scale(0.7);
35-
color: white;
36-
fill: white;
37-
}
38-
&:hover, &:focus {
39-
background: rgba(red, 0.8);
29+
transform: translate(0, -3px) scale(0.75);
30+
fill: rgba(0, 0, 0, 0.33);
4031
}
4132
}
4233
}
43-
}
34+
&:hover:not(.md-readonly) .md-chip-remove-container {
35+
display: block;
36+
}
37+
&.md-focused:not(.md-readonly) .md-chip-remove-container {
38+
display: block;
4439

45-
// Show custom padding for the custom delete button, which needs more space.
46-
md-chips-wrap.md-removable {
47-
md-chip md-chip-template {
48-
padding-right: 5px;
40+
button.demo-remove-vegetable-chip md-icon {
41+
fill: rgba(255, 255, 255, 0.87);
42+
}
4943
}
5044
}
51-
5245
}

‎src/components/chips/js/chipRemoveDirective.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ angular
2424
* ### With Standard Chips
2525
* <hljs lang="html">
2626
* <md-chips ...>
27-
* <button md-chip-remove class="md-primary" type="button" aria-label="Remove {{$chip}}">
28-
* <md-icon md-svg-icon="md-close"></md-icon>
27+
* <button md-chip-remove type="button" aria-label="Remove {{$chip}}">
28+
* <md-icon md-svg-icon="md-cancel"></md-icon>
2929
* </button>
3030
* </md-chips>
3131
* </hljs>
3232
*
3333
* ### With Object Chips
3434
* <hljs lang="html">
3535
* <md-chips ...>
36-
* <button md-chip-remove class="md-primary" type="button" aria-label="Remove {{$chip.name}}">
37-
* <md-icon md-svg-icon="md-close"></md-icon>
36+
* <button md-chip-remove type="button" aria-label="Remove {{$chip.name}}">
37+
* <md-icon md-svg-icon="md-cancel"></md-icon>
3838
* </button>
3939
* </md-chips>
4040
* </hljs>
@@ -57,7 +57,7 @@ function MdChipRemove ($timeout) {
5757
};
5858

5959
function postLink(scope, element, attr, ctrl) {
60-
element.on('click', function(event) {
60+
element.on('click', function() {
6161
scope.$apply(function() {
6262
ctrl.removeChip(scope.$$replacedScope.$index);
6363
});

‎src/components/chips/js/chipsDirective.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@
400400
mdChipsCtrl.chipRemoveTemplate = chipRemoveTemplate;
401401
mdChipsCtrl.chipInputTemplate = chipInputTemplate;
402402

403-
mdChipsCtrl.mdCloseIcon = $$mdSvgRegistry.mdClose;
403+
mdChipsCtrl.mdCloseIcon = $$mdSvgRegistry.mdCancel;
404404

405405
element
406406
.attr({ tabindex: -1 })

0 commit comments

Comments
 (0)
Failed to load comments.