@effindomv2/fui-as 0.1.45 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effindomv2/fui-as",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "private": false,
5
5
  "license": "AGPL-3.0-only OR LicenseRef-EffinDom-Commercial",
6
6
  "description": "EffinDom v2 AssemblyScript frontend framework SDK and browser harness",
@@ -96,7 +96,7 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@assemblyscript/loader": "^0.28.19",
99
- "@effindomv2/runtime": "0.1.25"
99
+ "@effindomv2/runtime": "0.1.26"
100
100
  },
101
101
  "devDependencies": {
102
102
  "@as-pect/assembly": "9.0.0",
@@ -15,7 +15,7 @@ import { navigateTo } from "../core/Navigation";
15
15
  import { PointerEventArgs, PointerType } from "../core/Node";
16
16
  import { hasPrimaryShortcutModifier } from "../core/Platform";
17
17
  import { Theme, activeTheme } from "../core/Theme";
18
- import { FlexBox } from "../nodes";
18
+ import { FlexBox, Text } from "../nodes";
19
19
 
20
20
  export class NavigateEventArgs {
21
21
  readonly path: string;
@@ -40,16 +40,28 @@ export class NavLink extends FlexBox {
40
40
  private previewVisible: bool = false;
41
41
  private previewPinnedForContextMenu: bool = false;
42
42
  private disposed: bool = false;
43
+ private textColorValue: u32;
44
+ readonly labelNode: Text;
43
45
 
44
46
  constructor(href: string, label: string = href, openInNewTab: bool = false) {
45
47
  super();
48
+ const theme = activeTheme.value;
46
49
  this.hrefValue = href;
47
50
  this.openInNewTabValue = openInNewTab;
51
+ this.textColorValue = theme.colors.accent;
52
+ this.labelNode = new Text(label)
53
+ .fontFamily(theme.fonts.bodyFamily)
54
+ .fontSize(15.0)
55
+ .textColor(theme.colors.accent)
56
+ .selectable(false)
57
+ .cursor(CursorStyle.Pointer) as Text;
48
58
  this.semanticRole(SemanticRole.Link);
49
59
  this.semanticLabel(label);
50
60
  this.cursor(CursorStyle.Pointer);
51
61
  this.focusable(true);
62
+ this.child(this.labelNode);
52
63
  this.track(activeTheme.addAction(new HandlerAction<NavLink, Theme>(this, (link: NavLink, _theme: Theme): void => {
64
+ link.syncVisualState();
53
65
  link.syncFocusChrome();
54
66
  })));
55
67
  this.track(keyboardFocusVisible.addAction(new HandlerAction<NavLink, bool>(this, (link: NavLink, _visible: bool): void => {
@@ -75,6 +87,18 @@ export class NavLink extends FlexBox {
75
87
  return this;
76
88
  }
77
89
 
90
+ text(value: string): this {
91
+ this.semanticLabel(value);
92
+ this.labelNode.text(value);
93
+ return this;
94
+ }
95
+
96
+ textColor(color: u32): this {
97
+ this.textColorValue = color;
98
+ this.syncVisualState();
99
+ return this;
100
+ }
101
+
78
102
  dispose(): void {
79
103
  this.hidePreview();
80
104
  if (!this.disposed) {
@@ -92,6 +116,7 @@ export class NavLink extends FlexBox {
92
116
  super._handlePointerEvent(eventType, x, y, modifiers);
93
117
  if (eventType == PointerEventType.Enter) {
94
118
  this.hovered = true;
119
+ this.syncVisualState();
95
120
  this.showPreview();
96
121
  return;
97
122
  }
@@ -99,6 +124,7 @@ export class NavLink extends FlexBox {
99
124
  this.hovered = false;
100
125
  this.pointerPressed = false;
101
126
  this.pointerPressedOpenInNewTab = false;
127
+ this.syncVisualState();
102
128
  if (!this.previewPinnedForContextMenu && !this.focused) {
103
129
  this.hidePreview();
104
130
  }
@@ -228,6 +254,10 @@ export class NavLink extends FlexBox {
228
254
  FocusAdornerManager.hideOwner(this);
229
255
  }
230
256
 
257
+ private syncVisualState(): void {
258
+ this.labelNode.textColor(this.hovered ? activeTheme.value.colors.accentHovered : this.textColorValue);
259
+ }
260
+
231
261
  private track(disposable: Disposable): void {
232
262
  this.disposables.push(disposable);
233
263
  }