Skip to content

Commit f188183

Browse files
committed
sync & address comments
1 parent 0fd32a9 commit f188183

File tree

5 files changed

+33
-112
lines changed

5 files changed

+33
-112
lines changed

src/demo-app/chips/chips-demo.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
}
2727

2828
.mat-chip-remove.mat-icon {
29-
font-size: 18px;
29+
font-size: 16px;
3030
width: 1em;
3131
height: 1em;
3232
vertical-align: middle;
33+
cursor: pointer;
3334
}
3435
}

src/demo-app/chips/chips-demo.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {Component} from '@angular/core';
2-
import {MdChipInputEvent, ENTER, COMMA} from '@angular/material';
2+
import {MdChipInputEvent, ENTER} from '@angular/material';
3+
4+
const COMMA = 188;
35

46
export interface Person {
57
name: string;

src/lib/chips/chip-list.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import {
2222

2323
import {MdChip} from './chip';
2424
import {FocusKeyManager} from '../core/a11y/focus-key-manager';
25-
import {SPACE, LEFT_ARROW, RIGHT_ARROW} from '../core/keyboard/keycodes';
26-
import {Subscription} from 'rxjs/Subscription';
25+
import {BACKSPACE, DELETE, SPACE, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, UP_ARROW} from '../core/keyboard/keycodes';
2726
import {coerceBooleanProperty, Directionality} from '@angular/cdk';
2827
import {Subscription} from 'rxjs/Subscription';
2928

src/lib/chips/chip.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
100100

101101
set removable(value: boolean) {
102102
this._removable = coerceBooleanProperty(value);
103-
if (this._chipRemove) { this._chipRemove.visible = this._removable; }
104103
}
105104
protected _removable: boolean = true;
106105

@@ -146,20 +145,14 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
146145
* Allows for programmatic removal of the chip. Called by the MdChipList when the DELETE or
147146
* BACKSPACE keys are pressed.
148147
*
149-
* Note: This only informs any listeners of the removal request, it does **not** actually remove
150-
* the chip from the DOM.
148+
* Informs any listeners of the removal request. Does not remove the chip from the DOM.
151149
*/
152150
remove(): void {
153151
if (this.removable) {
154152
this.onRemove.emit({chip: this});
155153
}
156154
}
157155

158-
/** The aria-disabled state for the chip */
159-
_isAriaDisabled(): string {
160-
return String(this.disabled);
161-
}
162-
163156
/** Ensures events fire properly upon click. */
164157
_handleClick(event: Event) {
165158
// Check disabled
@@ -198,15 +191,6 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
198191
break;
199192
}
200193
}
201-
202-
protected _checkDisabled(event: Event): boolean {
203-
if (this.disabled) {
204-
event.preventDefault();
205-
event.stopPropagation();
206-
}
207-
208-
return this.disabled;
209-
}
210194
}
211195

212196

@@ -217,7 +201,7 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
217201
* Example:
218202
*
219203
* <md-chip>
220-
* <md-icon mdChipRemove>clear</md-icon>
204+
* <md-icon mdChipRemove>cancel</md-icon>
221205
* </md-chip>
222206
*
223207
* You *may* use a custom icon, but you may need to override the `md-chip-remove` positioning styles
@@ -227,19 +211,10 @@ export class MdChip extends _MdChipMixinBase implements Focusable, OnDestroy, Ca
227211
selector: '[mdChipRemove], [matChipRemove]',
228212
host: {
229213
'class': 'mat-chip-remove',
230-
'[class.mat-chip-remove-hidden]': '!visible',
231214
'(click)': '_handleClick($event)'
232215
}
233216
})
234217
export class MdChipRemove {
235-
236-
/** Whether or not the remove icon is visible. */
237-
_isVisible: boolean = true;
238-
239-
@Input('mdChipRemoveVisible')
240-
get visible() { return this._isVisible; }
241-
set visible(value) { this._isVisible = coerceBooleanProperty(value); }
242-
243218
constructor(protected _parentChip: MdChip) {}
244219

245220
/** Calls the parent chip's public `remove()` method if applicable. */

src/lib/chips/chips.scss

Lines changed: 25 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,89 +3,18 @@
33
$mat-chip-vertical-padding: 8px;
44
$mat-chip-horizontal-padding: 12px;
55

6-
$mat-chip-vertical-padding: 8px - $mat-chip-border-width;
7-
$mat-chip-horizontal-padding: 12px - $mat-chip-border-width;
8-
9-
$mat-chip-margin: ($mat-chip-horizontal-padding / 4);
10-
11-
$mat-chip-remove-margin: $mat-chip-line-height * 2;
12-
$mat-chip-remove-icon-offset: 3px;
13-
$mat-chip-remove-size: 24px;
14-
$mat-chip-remove-font-size: 18px;
15-
16-
@mixin chip-margin() {
17-
[dir='rtl'] & {
18-
margin-right: $mat-chip-margin;
19-
margin-left: $mat-chip-margin;
20-
}
21-
22-
[dir='ltr'] & {
23-
margin-right: $mat-chip-margin;
24-
margin-left: $mat-chip-margin;
25-
}
26-
}
27-
28-
@mixin chip-margin-last() {
29-
[dir='rtl'] & {
30-
margin-left: 0;
31-
margin-right: $mat-chip-margin;
32-
}
33-
34-
[dir='ltr'] & {
35-
margin-right: 0;
36-
margin-left: $mat-chip-margin;
37-
}
38-
}
39-
40-
@mixin chip-margin-first() {
41-
[dir='ltr'] & {
42-
margin-left: 0;
43-
margin-right: $mat-chip-margin;
44-
}
45-
46-
[dir='rtl'] & {
47-
margin-right: 0;
48-
margin-left: $mat-chip-margin;
49-
}
50-
}
6+
$mat-chips-chip-margin: $mat-chip-horizontal-padding / 4;
517

528
.mat-chip-list-wrapper {
53-
549
display: flex;
5510
flex-direction: row;
5611
flex-wrap: wrap;
5712
align-items: flex-start;
58-
59-
.mat-chip {
60-
margin: $mat-chip-margin;
61-
62-
// Do not apply the special margins inside an input container
63-
// Remove the margin from the first element (in both LTR and RTL)
64-
&:first-child {
65-
@include chip-margin-first();
66-
}
67-
68-
// Remove the margin from the last element (in both LTR and RTL)
69-
&:last-child {
70-
@include chip-margin-last();
71-
}
72-
}
73-
}
74-
75-
.mat-input-container .mat-chip-list-wrapper .map-chip:last-child {
76-
@include chip-margin();
7713
}
7814

79-
.mat-input-prefix .mat-chip-list-wrapper {
80-
flex-wrap: nowrap;
81-
}
82-
83-
.mat-chip {
15+
.mat-chip:not(.mat-basic-chip) {
8416
display: inline-block;
85-
position: relative;
86-
87-
padding: $mat-chip-vertical-padding $mat-chip-horizontal-padding;
88-
border: $mat-chip-border-width solid transparent;
17+
padding: $mat-chip-vertical-padding $mat-chip-horizontal-padding $mat-chip-vertical-padding $mat-chip-horizontal-padding;
8918
border-radius: $mat-chip-horizontal-padding * 2;
9019

9120
// Apply a margin to adjacent sibling chips.
@@ -95,6 +24,16 @@ $mat-chip-remove-font-size: 18px;
9524
[dir='rtl'] & {
9625
margin: 0 $mat-chips-chip-margin 0 0;
9726
}
27+
28+
.mat-input-prefix & {
29+
&:last-child {
30+
margin-right: $mat-chips-chip-margin;
31+
}
32+
33+
[dir='rtl'] &:last-child {
34+
margin-left: $mat-chips-chip-margin;
35+
}
36+
}
9837
}
9938

10039
@include cdk-high-contrast {
@@ -105,17 +44,22 @@ $mat-chip-remove-font-size: 18px;
10544
.mat-chip-list-stacked .mat-chip-list-wrapper {
10645
display: block;
10746

108-
.mat-chip {
47+
.mat-chip:not(.mat-basic-chip) {
10948
display: block;
11049
margin: 0;
11150
margin-bottom: $mat-chip-vertical-padding;
112-
}
113-
}
11451

115-
.mat-chip-remove.mat-chip-remove-hidden {
116-
display: none;
52+
[dir='rtl'] & {
53+
margin: 0;
54+
margin-bottom: $mat-chip-vertical-padding;
55+
}
56+
57+
&:last-child, [dir='rtl'] &:last-child {
58+
margin-bottom: 0;
59+
}
60+
}
11761
}
11862

119-
.mat-chip-input {
120-
@include chip-margin-last();
63+
.mat-input-prefix .mat-chip-list-wrapper {
64+
margin-bottom: $mat-chip-vertical-padding;
12165
}

0 commit comments

Comments
 (0)