Skip to content

Commit 561cda3

Browse files
committed
Integrate the checkboxes.
1 parent c8848d6 commit 561cda3

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

src/lib/core/option/_option-theme.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@
1212
}
1313

1414
&.md-selected {
15-
background: md-color($background, hover);
1615
color: md-color($primary);
16+
17+
// In multiple mode there is a checkbox to show that the option is selected.
18+
&:not(.md-option-multiple) {
19+
background: md-color($background, hover);
20+
}
1721
}
1822

1923
&.md-option-disabled {
2024
color: md-color($foreground, hint-text);
2125
}
2226

2327
}
24-
}
28+
}

src/lib/core/option/_option.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,14 @@
3030
opacity: 0.5;
3131
}
3232
}
33+
34+
.md-option-content {
35+
vertical-align: middle;
36+
}
37+
38+
// TODO: doesn't handle RTL yet
39+
md-pseudo-checkbox {
40+
margin-right: $md-menu-side-padding / 2;
41+
}
3342
}
3443

src/lib/core/option/option.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
<ng-content></ng-content>
1+
<md-pseudo-checkbox *ngIf="multiple" [state]="selected ? 'checked' : ''"
2+
color="primary"></md-pseudo-checkbox>
3+
<span class="md-option-content"><ng-content></ng-content></span>
24
<div class="md-option-ripple" *ngIf="!disabled" md-ripple mdRippleBackgroundColor="rgba(0,0,0,0)"
3-
[mdRippleTrigger]="_getHostElement()"></div>
5+
[mdRippleTrigger]="_getHostElement()"></div>

src/lib/core/option/option.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {CommonModule} from '@angular/common';
1313
import {ENTER, SPACE} from '../keyboard/keycodes';
1414
import {coerceBooleanProperty} from '../coercion/boolean-property';
1515
import {MdRippleModule} from '../ripple/ripple';
16+
import {MdSelectionModule} from '../selection/index';
1617

1718
/**
1819
* Option IDs need to be unique across components, so this counter exists outside of
@@ -36,6 +37,7 @@ export class MdOptionSelectionChange {
3637
'role': 'option',
3738
'[attr.tabindex]': '_getTabIndex()',
3839
'[class.md-selected]': 'selected',
40+
'[class.md-option-multiple]': 'multiple',
3941
'[id]': 'id',
4042
'[attr.aria-selected]': 'selected.toString()',
4143
'[attr.aria-disabled]': 'disabled.toString()',
@@ -138,7 +140,7 @@ export class MdOption {
138140
}
139141

140142
@NgModule({
141-
imports: [MdRippleModule, CommonModule],
143+
imports: [MdRippleModule, CommonModule, MdSelectionModule],
142144
exports: [MdOption],
143145
declarations: [MdOption]
144146
})

src/lib/select/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import {NgModule, ModuleWithProviders} from '@angular/core';
22
import {CommonModule} from '@angular/common';
33
import {MdSelect} from './select';
44
import {MdOptionModule} from '../core/option/option';
5-
import {
6-
CompatibilityModule,
7-
OverlayModule,
8-
} from '../core';
5+
import {CompatibilityModule, OverlayModule} from '../core';
6+
97
export * from './select';
108
export {fadeInContent, transformPanel, transformPlaceholder} from './select-animations';
119

0 commit comments

Comments
 (0)