Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit a16b3dd

Browse files
committed
Update changes since initial release
1 parent 49b22a4 commit a16b3dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+444
-191
lines changed

lib/angular2_components.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const List<Type> materialDirectives = const [
4343
ScorecardComponent
4444
];
4545

46-
/// A convenience list of all bindings exposed by this package.
46+
/// A convenience list of all providers exposed by this package.
4747
const List<List<Provider>> materialProviders = const <List<Provider>>[
4848
rippleBindings
4949
];

lib/src/all_components.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export 'components/material_tab/src/tab_mixin.dart';
4646
export 'components/material_tab/tab_change_event.dart';
4747
export 'components/material_toggle/material_toggle.dart';
4848
export 'components/material_yes_no_buttons/material_yes_no_buttons.dart';
49+
export 'components/mixins/focusable_mixin.dart';
50+
export 'components/mixins/has_tab_index.dart';
4951
export 'components/reorder_list/reorder_list.dart';
5052
export 'components/scorecard/scoreboard.dart';
5153
export 'components/scorecard/scorecard.dart';

lib/src/components/button_decorator/button_decorator.dart

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
import 'dart:html';
66

7-
import 'package:angular2/angular2.dart';
8-
97
import '../focus/focus.dart';
8+
import '../mixins/has_tab_index.dart';
109
import '../../utils/angular/properties/properties.dart';
1110
import '../../utils/async/async.dart';
1211
import '../../utils/browser/events/events.dart';
12+
import 'package:angular2/angular2.dart';
1313

1414
/// ButtonDirective adds all basic required a11y functional for any element,
1515
/// that are designed to work as a button (clickable icon, etc.)
@@ -25,18 +25,21 @@ import '../../utils/browser/events/events.dart';
2525
@Directive(selector: '[buttonDecorator]', host: const {
2626
'(click)': r'handleClick($event)',
2727
'(keypress)': r'handleKeyPress($event)',
28-
'tabindex': '0',
28+
'[tabindex]': 'tabIndex',
2929
'role': 'button',
3030
'[attr.aria-disabled]': 'disabledStr',
3131
'[class.is-disabled]': 'disabled',
3232
})
33-
class ButtonDirective extends RootFocusable {
33+
class ButtonDirective extends RootFocusable with HasTabIndex {
3434
/// Will emit Event on mouse click or keyboard activation.
3535
@Output()
3636
final LazyEventEmitter<UIEvent> trigger =
3737
new LazyEventEmitter<UIEvent>.broadcast();
3838

3939
bool _disabled = false;
40+
bool _tabbable = true;
41+
42+
String _hostTabIndex;
4043

4144
ButtonDirective(ElementRef element) : super(element);
4245

@@ -50,6 +53,23 @@ class ButtonDirective extends RootFocusable {
5053
_disabled = getBool(value);
5154
}
5255

56+
/// Is the button tabbable.
57+
bool get tabbable => _tabbable;
58+
@Input()
59+
set tabbable(value) {
60+
_tabbable = getBool(value);
61+
}
62+
63+
String get hostTabIndex => tabbable && !disabled ? _hostTabIndex : '-1';
64+
65+
/// The tab index of the button.
66+
///
67+
/// The value is used if [tabbable] is `true` and [disabled] is `false`.
68+
@Input()
69+
set tabindex(String value) {
70+
_hostTabIndex = value;
71+
}
72+
5373

5474
/// Triggers if not disabled.
5575
void handleClick(MouseEvent mouseEvent) {

lib/src/components/focus/keyboard_only_focus_indicator.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,19 @@ import '../../utils/browser/dom_service/dom_service.dart';
2222
exportAs: 'keyboardOnlyFocusIndicator')
2323
class KeyboardOnlyFocusIndicatorDirective {
2424
final ElementRef _element;
25-
final Renderer _renderer;
2625
final DomService _domService;
2726

28-
KeyboardOnlyFocusIndicatorDirective(
29-
this._element, this._renderer, this._domService);
27+
KeyboardOnlyFocusIndicatorDirective(this._element, this._domService);
3028

3129
void resetOutline() {
3230
_domService.scheduleWrite(() {
33-
_renderer.setElementStyle(_element.nativeElement, 'outline', '');
31+
_element.nativeElement.style.outline = '';
3432
});
3533
}
3634

3735
void hideOutline() {
3836
_domService.scheduleWrite(() {
39-
_renderer.setElementStyle(_element.nativeElement, 'outline', 'none');
37+
_element.nativeElement.style.outline = 'none';
4038
});
4139
}
4240

lib/src/components/glyph/glyph.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import '../../model/ui/icon.dart';
1919
///
2020
/// ```html
2121
/// <link rel="stylesheet" type="text/css"
22-
/// href="https://fonts.googleapis.com/icon?family=Material+Icons+Extended">
22+
/// href="https://fonts.googleapis.com/icon?family=Material+Icons">
2323
/// ```
2424
/// __Attributes:__
2525
///
@@ -30,7 +30,8 @@ import '../../model/ui/icon.dart';
3030
selector: 'glyph',
3131
templateUrl: 'glyph.html',
3232
styleUrls: const ['glyph.scss.css'],
33-
changeDetection: ChangeDetectionStrategy.OnPush)
33+
changeDetection: ChangeDetectionStrategy.OnPush,
34+
preserveWhitespace: false)
3435
class GlyphComponent {
3536
static const String _materialIconsExtended = 'material-icons-extended';
3637

lib/src/components/material_button/material_button.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:angular2/angular2.dart';
6-
75
import '../button_decorator/button_decorator.dart';
86
import '../material_ripple/material_ripple.dart';
97
import '../theme/dark_theme.dart';
8+
import 'package:angular2/angular2.dart';
109

1110
import 'material_button_base.dart';
1211

@@ -85,7 +84,7 @@ import 'material_button_base.dart';
8584
'[attr.elevation]': 'zElevation',
8685
'animated': 'true'
8786
},
88-
inputs: const ['disabled', 'raised'],
87+
inputs: const ['disabled', 'raised', 'tabindex'],
8988
outputs: const ['trigger'],
9089
directives: const [MaterialRippleComponent],
9190
templateUrl: 'material_button.html',
@@ -94,7 +93,8 @@ import 'material_button_base.dart';
9493
const Provider(ButtonDirective, useExisting: MaterialButtonComponent)
9594
],
9695
styleUrls: const ['material_button.scss.css'],
97-
changeDetection: ChangeDetectionStrategy.OnPush)
96+
changeDetection: ChangeDetectionStrategy.OnPush,
97+
preserveWhitespace: false)
9898
class MaterialButtonComponent extends MaterialButtonBase {
9999
final ChangeDetectorRef _changeDetector;
100100

lib/src/components/material_button/material_button_base.dart

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import 'dart:async';
66
import 'dart:html';
77

8-
import 'package:angular2/angular2.dart';
9-
108
import '../button_decorator/button_decorator.dart';
119
import '../../utils/angular/properties/properties.dart';
10+
import 'package:angular2/angular2.dart';
1211

1312
// TODO(google): Right now we use is-raised and isDisabled for CSS styling.
1413
// When Angular supports conditionally adding/removing an attribute, use.
@@ -28,13 +27,13 @@ import '../../utils/angular/properties/properties.dart';
2827
/// - `trigger: Event` -- Published when the button is activated via click or
2928
/// keypress.
3029
class MaterialButtonBase extends ButtonDirective {
31-
static const _MOUSE_UP_Z = 1;
32-
static const _MOUSE_DOWN_Z = 2;
30+
static const lowElevation = 1;
31+
static const mediumElevation = 2;
3332

3433
bool _raised = false;
35-
int _zElevation = 1;
3634
bool _focused = false;
3735
bool _clickFocused = false;
36+
bool _isMouseDown = false;
3837

3938
/// Whether the button should be raised.
4039
bool get raised => _raised;
@@ -51,9 +50,8 @@ class MaterialButtonBase extends ButtonDirective {
5150
/// The elevation the material-shadow component should show.
5251
///
5352
/// When a button is pressed, this is increased.
54-
int get zElevation => _zElevation;
55-
56-
String get tabIndex => disabled ? '-1' : '0';
53+
int get zElevation =>
54+
_isMouseDown || _focused ? mediumElevation : lowElevation;
5755

5856
MaterialButtonBase(ElementRef element) : super(element);
5957

@@ -74,12 +72,12 @@ class MaterialButtonBase extends ButtonDirective {
7472
/// Triggered on a mouse press.
7573
void onMouseDown(_) {
7674
_clickFocused = true;
77-
_zElevation = _MOUSE_DOWN_Z;
75+
_isMouseDown = true;
7876
}
7977

8078
/// Triggered on a mouse release.
8179
void onMouseUp(_) {
82-
_zElevation = _MOUSE_UP_Z;
80+
_isMouseDown = false;
8381
}
8482

8583
/// Triggered on focus.

lib/src/components/material_button/material_fab.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:angular2/angular2.dart';
6-
75
import '../material_ripple/material_ripple.dart';
6+
import 'package:angular2/angular2.dart';
87

98
import 'material_button_base.dart';
109

@@ -69,9 +68,10 @@ import 'material_button_base.dart';
6968
'[attr.elevation]': 'zElevation',
7069
'animated': 'true'
7170
},
72-
inputs: const ['disabled', 'raised'],
71+
inputs: const ['disabled', 'raised', 'tabindex'],
7372
outputs: const ['trigger'],
7473
directives: const [MaterialRippleComponent],
74+
preserveWhitespace: false,
7575
templateUrl: 'material_button.html',
7676
styleUrls: const ['material_fab.scss.css'],
7777
changeDetection: ChangeDetectionStrategy.OnPush)

lib/src/components/material_checkbox/material_checkbox.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const indeterminateAriaState = 'mixed';
8989
'[attr.aria-label]': 'label',
9090
},
9191
directives: const [GlyphComponent, MaterialRippleComponent, NgIf],
92+
preserveWhitespace: false,
9293
templateUrl: 'material_checkbox.html',
9394
styleUrls: const ['material_checkbox.scss.css'],
9495
changeDetection: ChangeDetectionStrategy.OnPush)
@@ -227,8 +228,7 @@ class MaterialCheckboxComponent implements ControlValueAccessor {
227228

228229
void _syncAriaChecked() {
229230
if (_renderer == null || _root == null) return;
230-
_renderer.setElementAttribute(
231-
_root.nativeElement, 'aria-checked', _checkedStr);
231+
_root.nativeElement.attributes['aria-checked'] = _checkedStr;
232232
_changeDetector?.markForCheck();
233233
}
234234

lib/src/components/material_chips/material_chip.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import '../../utils/id_generator/id_generator.dart';
3737
providers: const [
3838
const Provider(HasRenderer, useExisting: MaterialChipComponent)
3939
],
40+
preserveWhitespace: false,
4041
templateUrl: 'material_chip.html',
4142
styleUrls: const ['material_chip.scss.css'],
4243
directives: const [GlyphComponent, ButtonDirective, NgIf],

0 commit comments

Comments
 (0)