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

Commit daad18e

Browse files
authored
Additional updates to existing components. (#60)
Preperation for publishing.
1 parent dedd4cb commit daad18e

File tree

23 files changed

+133
-38
lines changed

23 files changed

+133
-38
lines changed

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## 0.4.0-alpha
22

3-
This code is considered production quality, but depends on angular2: 3.0.0-alpha.
3+
This code is considered production quality, but depends on angular2: 3.0.0-alpha+1.
44
The alpha tag represents the evolving nature of the AngularDart api, not
5-
code quality (3.0.0-alpha is used in production Google apps).
5+
code quality (3.0.0-alpha+1 is used in production Google apps).
66

77
### Breaking Changes
88
* Update for generic syntax and `FutureOr` type introduced in Dart SDK 1.22.0.
@@ -15,18 +15,24 @@ code quality (3.0.0-alpha is used in production Google apps).
1515

1616
### Other Changes
1717
* Focus: Fix AX_ARIA_08 a11y issue.
18+
* Glyph: Option to horizontally flip glyphs when the direction is RTL.
1819
* Material Chips: Use :host to remove need for wrapper div.
1920
* Material Expansionpanel: Fix panel overflow issues.
2021
* Material Input:
2122
* Add new number accessors and validators.
23+
* Add ability to override/specify error messages.
2224
* Fix AX_TEXT_01 a11y issue.
23-
* Material List: Block pointer events for disabled list items.
25+
* Material List:
26+
* Block pointer events for disabled list items.
27+
* Remove duplicate mixin.
2428
* Material Popup: Disable animation delay when there is nothing to animate.
2529
* Material Radio: Fix styling issue, flex for IE11.
2630
* Material Tab Panel: Fix issue that prevents displaying tabs on initialization.
31+
* Material Yes/No Buttons: Add submit/cancel buttons.
2732
* Scorecard:
2833
* Add support for RTL languages in scrollable scoreboards.
2934
* Add support for themes.
35+
* Prevent exceptions during width calculations when scorecard width is `auto`.
3036
* Compute the ARIA roles only once per instance.
3137
* Fix dom update issues.
3238
* Add proper types to injected providers.

lib/src/components/glyph/glyph.dart

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,22 @@
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 'dart:html';
6+
57
import 'package:angular2/angular2.dart';
68

79
import '../../model/ui/icon.dart';
810

11+
/// Icons that should be horizontally flipped when the direction is RTL.
12+
///
13+
/// Please add to this list as needed.
14+
const List<String> _flippedIcons = const [
15+
'chevron_left',
16+
'chevron_right',
17+
'navigate_before',
18+
'navigate_next',
19+
];
20+
921
/// A component that creates a material style icon. Currently only font icons
1022
/// are supported and
1123
/// [material-icons-extended](https://www.google.com/design/icons/) is the only
@@ -21,11 +33,18 @@ import '../../model/ui/icon.dart';
2133
/// <link rel="stylesheet" type="text/css"
2234
/// href="https://fonts.googleapis.com/icon?family=Material+Icons">
2335
/// ```
36+
///
37+
/// Make sure to take RTL into account. Specifically, use the [flip] attribute
38+
/// if the icon should be flipped for RTL UIs. Read [these
39+
/// guidelines](https://material.io/guidelines/usability/bidirectionality.html#bidirectionality-rtl-mirroring-guidelines)
40+
/// for advice on when and when not to flip the icon.
41+
///
2442
/// __Attributes:__
2543
///
2644
/// - `size: string {x-small, small, medium, large, x-large}` -- Sizes names for
2745
/// the icon, corresponding to 12px, 13px, 16px, 18px, and 20px, respectively.
2846
/// If no size is specified, the default of 24px is used.
47+
/// - `flip` -- Whether the icon should be flipped for RTL languages.
2948
@Component(
3049
selector: 'glyph',
3150
templateUrl: 'glyph.html',
@@ -39,7 +58,15 @@ class GlyphComponent {
3958
/// [https://www.google.com/design/icons/](https://goo.gl/YKrYlu) for
4059
/// available icons.
4160
@Input()
42-
var icon;
61+
set icon(dynamic value) {
62+
_icon = value;
63+
if (_flippedIcons.contains(iconName)) {
64+
_element.setAttribute('flip', '');
65+
}
66+
}
67+
68+
dynamic get icon => _icon;
69+
var _icon;
4370

4471
bool get _isIconModel => icon is Icon;
4572

@@ -62,6 +89,10 @@ class GlyphComponent {
6289
bool _useMaterialIconsExtended = true;
6390

6491
bool get useMaterialIconsExtended => _useMaterialIconsExtended;
92+
93+
final HtmlElement _element;
94+
95+
GlyphComponent(ElementRef elementRef) : _element = elementRef.nativeElement;
6596
}
6697

6798
/// Size names which can be used on the glyph icon.

lib/src/components/glyph/glyph.scss.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* for details. All rights reserved. Use of this source code is governed by a
44
* BSD-style license that can be found in the LICENSE file.
55
*/
6-
:host{display:-webkit-inline-flex;display:inline-flex}:host[light]{opacity:0.54}:host[size="x-small"] /deep/ i{font-size:12px;height:1em;line-height:1em;width:1em}:host[size="small"] /deep/ i{font-size:13px;height:1em;line-height:1em;width:1em}:host[size="medium"] /deep/ i{font-size:16px;height:1em;line-height:1em;width:1em}:host[size="large"] /deep/ i{font-size:18px;height:1em;line-height:1em;width:1em}:host[size="x-large"] /deep/ i{font-size:20px;height:1em;line-height:1em;width:1em}
6+
:host{display:-webkit-inline-flex;display:inline-flex}:host[light]{opacity:0.54}:host[size="x-small"] /deep/ i{font-size:12px;height:1em;line-height:1em;width:1em}:host[size="small"] /deep/ i{font-size:13px;height:1em;line-height:1em;width:1em}:host[size="medium"] /deep/ i{font-size:16px;height:1em;line-height:1em;width:1em}:host[size="large"] /deep/ i{font-size:18px;height:1em;line-height:1em;width:1em}:host[size="x-large"] /deep/ i{font-size:20px;height:1em;line-height:1em;width:1em}:host-context([dir="rtl"])[flip]{transform:scaleX(-1)}

lib/src/components/material_checkbox/material_checkbox.scss.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/components/material_dialog/material_dialog.scss.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/components/material_input/base_material_input.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const String materialInputErrorKey = 'material-input-error';
2121

2222
typedef String ValidityCheck(String inputText);
2323
typedef int CharacterCounter(String inputText);
24+
typedef Map<String, dynamic> ErrorFn(Map<String, dynamic> errors);
2425

2526
/// Represents which label should be shown in the BottomPanel
2627
enum BottomPanelState {
@@ -140,6 +141,13 @@ class BaseMaterialInput extends FocusableMixin
140141
_displayBottomPanel = getBool(value);
141142
}
142143

144+
/// A function which takes in an error map, and returns another map, replacing
145+
/// errors with human readable text.
146+
///
147+
/// WARNING: The API of this mechanism is still in flux and there will be
148+
/// breaking changes. Be careful relying on it.
149+
ErrorFn errorRenderer;
150+
143151
/// Custom character counter function to be used.
144152
CharacterCounter characterCounter;
145153

@@ -294,6 +302,7 @@ class BaseMaterialInput extends FocusableMixin
294302
// error map
295303
if (_cd != null && _cd.control?.errors != null) {
296304
Map<String, dynamic> errorMap = _cd.control.errors;
305+
if (errorRenderer != null) errorMap = errorRenderer(errorMap);
297306
var stringValue = errorMap.values.firstWhere(
298307
((v) => (v is String) && v.isNotEmpty),
299308
orElse: () => null);

lib/src/components/material_input/material_input.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ const String materialInputErrorKey = 'material-input-error';
122122
'error',
123123
'errorMsg',
124124
'label',
125+
'errorRenderer',
125126
'floatingLabel',
126127
'hintText',
127128
'showHintOnlyOnFocus',

0 commit comments

Comments
 (0)