ozdenui 0.1.0

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.
Files changed (149) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +14 -0
  3. data/NOTICE +5 -0
  4. data/README.md +242 -0
  5. data/exe/ozdenui +17 -0
  6. data/lib/ozdenui/AGENTS.md +210 -0
  7. data/lib/ozdenui/COMPONENTS.md +3017 -0
  8. data/lib/ozdenui/app.rb +749 -0
  9. data/lib/ozdenui/command.rb +107 -0
  10. data/lib/ozdenui/components.rb +368 -0
  11. data/lib/ozdenui/dialogs.rb +212 -0
  12. data/lib/ozdenui/files.rb +124 -0
  13. data/lib/ozdenui/icon.png +0 -0
  14. data/lib/ozdenui/kit.json +1 -0
  15. data/lib/ozdenui/kit.rb +115 -0
  16. data/lib/ozdenui/look.rb +229 -0
  17. data/lib/ozdenui/objects.rb +652 -0
  18. data/lib/ozdenui/server.rb +270 -0
  19. data/lib/ozdenui/values.rb +273 -0
  20. data/lib/ozdenui/version.rb +15 -0
  21. data/lib/ozdenui/web/basic/LICENSE +14 -0
  22. data/lib/ozdenui/web/basic/basic.min.css +1 -0
  23. data/lib/ozdenui/web/basic/basic.min.js +78 -0
  24. data/lib/ozdenui/web/basic/font/open-sans/LICENSE.txt +206 -0
  25. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
  26. data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
  27. data/lib/ozdenui/web/basic/scroll-bar.min.js +3 -0
  28. data/lib/ozdenui/web/bridge.js +584 -0
  29. data/lib/ozdenui/web/comp/accordion.js +659 -0
  30. data/lib/ozdenui/web/comp/action-button/add.png +0 -0
  31. data/lib/ozdenui/web/comp/action-button.js +521 -0
  32. data/lib/ozdenui/web/comp/action-tab-bar.js +383 -0
  33. data/lib/ozdenui/web/comp/app-bar.js +237 -0
  34. data/lib/ozdenui/web/comp/badge.js +292 -0
  35. data/lib/ozdenui/web/comp/bottom-bar.js +555 -0
  36. data/lib/ozdenui/web/comp/breadcrumbs.js +524 -0
  37. data/lib/ozdenui/web/comp/canvas.js +652 -0
  38. data/lib/ozdenui/web/comp/chat-view.js +827 -0
  39. data/lib/ozdenui/web/comp/check-box.js +490 -0
  40. data/lib/ozdenui/web/comp/code-editor.js +965 -0
  41. data/lib/ozdenui/web/comp/color-picker.js +636 -0
  42. data/lib/ozdenui/web/comp/context-menu.js +951 -0
  43. data/lib/ozdenui/web/comp/currency-field.js +209 -0
  44. data/lib/ozdenui/web/comp/data-table/arrow.svg +2 -0
  45. data/lib/ozdenui/web/comp/data-table.js +937 -0
  46. data/lib/ozdenui/web/comp/date-picker.js +1055 -0
  47. data/lib/ozdenui/web/comp/dialog.js +992 -0
  48. data/lib/ozdenui/web/comp/email-field.js +65 -0
  49. data/lib/ozdenui/web/comp/file-picker.js +920 -0
  50. data/lib/ozdenui/web/comp/filters.js +807 -0
  51. data/lib/ozdenui/web/comp/form.js +602 -0
  52. data/lib/ozdenui/web/comp/full-screen-select/arrow.svg +2 -0
  53. data/lib/ozdenui/web/comp/full-screen-select/cancel.svg +2 -0
  54. data/lib/ozdenui/web/comp/full-screen-select.js +614 -0
  55. data/lib/ozdenui/web/comp/gauge.js +439 -0
  56. data/lib/ozdenui/web/comp/graph-box.js +3911 -0
  57. data/lib/ozdenui/web/comp/grid-group.js +185 -0
  58. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash-red.png +0 -0
  59. data/lib/ozdenui/web/comp/hold-to-confirm-button/trash.png +0 -0
  60. data/lib/ozdenui/web/comp/hold-to-confirm-button.js +289 -0
  61. data/lib/ozdenui/web/comp/image-view.js +598 -0
  62. data/lib/ozdenui/web/comp/item-list.js +1740 -0
  63. data/lib/ozdenui/web/comp/json-editor.js +3221 -0
  64. data/lib/ozdenui/web/comp/json-view.js +597 -0
  65. data/lib/ozdenui/web/comp/label-editor.js +1140 -0
  66. data/lib/ozdenui/web/comp/left-menu/data-table.png +0 -0
  67. data/lib/ozdenui/web/comp/left-menu/home.png +0 -0
  68. data/lib/ozdenui/web/comp/left-menu/reports.png +0 -0
  69. data/lib/ozdenui/web/comp/left-menu/setting.png +0 -0
  70. data/lib/ozdenui/web/comp/left-menu.js +548 -0
  71. data/lib/ozdenui/web/comp/line-progress-bar.js +343 -0
  72. data/lib/ozdenui/web/comp/loading-screen.js +413 -0
  73. data/lib/ozdenui/web/comp/log-view.js +530 -0
  74. data/lib/ozdenui/web/comp/login-page.js +685 -0
  75. data/lib/ozdenui/web/comp/markdown-view.js +1045 -0
  76. data/lib/ozdenui/web/comp/menu-bar.js +624 -0
  77. data/lib/ozdenui/web/comp/mini-graph-box.js +492 -0
  78. data/lib/ozdenui/web/comp/minimal-accent.js +208 -0
  79. data/lib/ozdenui/web/comp/notice.js +229 -0
  80. data/lib/ozdenui/web/comp/number-field.js +128 -0
  81. data/lib/ozdenui/web/comp/numeric-keyboard.js +298 -0
  82. data/lib/ozdenui/web/comp/page-control.js +762 -0
  83. data/lib/ozdenui/web/comp/page-header.js +191 -0
  84. data/lib/ozdenui/web/comp/password-field/hide-btn.png +0 -0
  85. data/lib/ozdenui/web/comp/password-field/hide-btn2.png +0 -0
  86. data/lib/ozdenui/web/comp/password-field/show-btn.png +0 -0
  87. data/lib/ozdenui/web/comp/password-field/show-btn2.png +0 -0
  88. data/lib/ozdenui/web/comp/password-field.js +192 -0
  89. data/lib/ozdenui/web/comp/period-bar.js +436 -0
  90. data/lib/ozdenui/web/comp/phone-field.js +322 -0
  91. data/lib/ozdenui/web/comp/progress-bar.js +992 -0
  92. data/lib/ozdenui/web/comp/property-panel.js +3639 -0
  93. data/lib/ozdenui/web/comp/radio-button.js +527 -0
  94. data/lib/ozdenui/web/comp/range-slider.js +569 -0
  95. data/lib/ozdenui/web/comp/rich-text-editor.js +1064 -0
  96. data/lib/ozdenui/web/comp/scroll-area.js +308 -0
  97. data/lib/ozdenui/web/comp/scrolling-text.js +297 -0
  98. data/lib/ozdenui/web/comp/search-input/clear-round.svg +1 -0
  99. data/lib/ozdenui/web/comp/search-input/clear.svg +1 -0
  100. data/lib/ozdenui/web/comp/search-input/filter.png +0 -0
  101. data/lib/ozdenui/web/comp/search-input/filter.svg +1 -0
  102. data/lib/ozdenui/web/comp/search-input/search.svg +1 -0
  103. data/lib/ozdenui/web/comp/search-input.js +725 -0
  104. data/lib/ozdenui/web/comp/search-results.js +596 -0
  105. data/lib/ozdenui/web/comp/select-box.js +1862 -0
  106. data/lib/ozdenui/web/comp/settings-row.js +299 -0
  107. data/lib/ozdenui/web/comp/side-panel.js +616 -0
  108. data/lib/ozdenui/web/comp/slider-field.js +952 -0
  109. data/lib/ozdenui/web/comp/slider.js +838 -0
  110. data/lib/ozdenui/web/comp/smart-button/alert-black.png +0 -0
  111. data/lib/ozdenui/web/comp/smart-button/clock.png +0 -0
  112. data/lib/ozdenui/web/comp/smart-button.js +981 -0
  113. data/lib/ozdenui/web/comp/smart-table/clock.png +0 -0
  114. data/lib/ozdenui/web/comp/smart-table/down.png +0 -0
  115. data/lib/ozdenui/web/comp/smart-table/scroll.png +0 -0
  116. data/lib/ozdenui/web/comp/smart-table/sort.png +0 -0
  117. data/lib/ozdenui/web/comp/smart-table/up.png +0 -0
  118. data/lib/ozdenui/web/comp/smart-table.js +1883 -0
  119. data/lib/ozdenui/web/comp/sortable-list.js +1181 -0
  120. data/lib/ozdenui/web/comp/spark-line-box.js +738 -0
  121. data/lib/ozdenui/web/comp/splitter.js +411 -0
  122. data/lib/ozdenui/web/comp/status-bar.js +408 -0
  123. data/lib/ozdenui/web/comp/step-bar.js +345 -0
  124. data/lib/ozdenui/web/comp/stepper.js +753 -0
  125. data/lib/ozdenui/web/comp/tabs.js +1366 -0
  126. data/lib/ozdenui/web/comp/tag-input.js +1107 -0
  127. data/lib/ozdenui/web/comp/tap-effect.js +170 -0
  128. data/lib/ozdenui/web/comp/text-area-field.js +233 -0
  129. data/lib/ozdenui/web/comp/text-field.js +1006 -0
  130. data/lib/ozdenui/web/comp/time-line.js +398 -0
  131. data/lib/ozdenui/web/comp/time-picker.js +1032 -0
  132. data/lib/ozdenui/web/comp/tiny-select/arrow.svg +1 -0
  133. data/lib/ozdenui/web/comp/tiny-select.js +322 -0
  134. data/lib/ozdenui/web/comp/tiny-table.js +283 -0
  135. data/lib/ozdenui/web/comp/toast.js +891 -0
  136. data/lib/ozdenui/web/comp/toggle.js +757 -0
  137. data/lib/ozdenui/web/comp/tool-bar.js +760 -0
  138. data/lib/ozdenui/web/comp/tooltip.js +534 -0
  139. data/lib/ozdenui/web/comp/tree-view.js +1179 -0
  140. data/lib/ozdenui/web/comp/ui-effects.js +1097 -0
  141. data/lib/ozdenui/web/comp/ui-standards.js +403 -0
  142. data/lib/ozdenui/web/comp/url-field.js +190 -0
  143. data/lib/ozdenui/web/comp/web-view.js +588 -0
  144. data/lib/ozdenui/web/components.js +123 -0
  145. data/lib/ozdenui/web/index.html +39 -0
  146. data/lib/ozdenui/window.rb +188 -0
  147. data/lib/ozdenui/window_cocoa.rb +221 -0
  148. data/lib/ozdenui.rb +32 -0
  149. metadata +200 -0
@@ -0,0 +1,408 @@
1
+ /* Bismillah */
2
+
3
+ /*
4
+
5
+ StatusBar - v26.11
6
+
7
+ UI COMPONENT
8
+ - The thin bar at the bottom of a window of a program: a short message at the left ("Saved"), small parts at the
9
+ right ("3 files", "UTF-8", "100%").
10
+ - A message can have a tone (a colored dot: success, warn, error, info) and a time: after it the bar goes back to
11
+ its lasting message.
12
+ - setBusy(1): a small turning circle in front of the message, while a job runs. (Still when the system asks for
13
+ reduced motion.)
14
+ - A part with onClick is a real button (Tab, Enter, Space); a part without it is only a text.
15
+ - Stands at the bottom of its Box by itself; in a VGroup it takes its place in the column.
16
+ - Style packages: "light" (default), "dark", "minimal", "minimalDark" (a package of params: its height too; setTheme()
17
+ changes only the colors and the shapes). Select with styleName (StatusBar.styles), or later with setTheme().
18
+
19
+ PART: { key, text, icon, tone, ariaLabel, onClick }
20
+ - A string is also accepted: "UTF-8" -> { key: "UTF-8", text: "UTF-8" }
21
+ - icon: an SVG text ("<svg ...>", your own code, not a user text), drawn with the color of the text of the part.
22
+ - tone: "", "success", "warn", "error", "info": the color of its text.
23
+ - onClick: function (self, part) {}: self is the StatusBar.
24
+
25
+ USAGE:
26
+ const bar = StatusBar({
27
+ messageText: "Ready",
28
+ items: [
29
+ { key: "files", text: "3 files" },
30
+ "UTF-8",
31
+ { key: "zoom", text: "100%", onClick: function (self, part) { println(part.text); } },
32
+ ],
33
+ });
34
+ bar.setMessageText("Ready"); // the lasting message
35
+ bar.setMessageText("Saved", "success", 3000); // for 3 seconds, then "Ready" again
36
+ bar.setMessageText("The disk is full", "error"); // stays
37
+ bar.setBusy(1);
38
+ bar.setItemText("files", "4 files");
39
+ bar.setItemVisible("zoom", 0);
40
+ bar.setItems(["One", "Two"]);
41
+ bar.setTheme("dark");
42
+ StatusBar({ styleName: "dark" });
43
+
44
+ Started Date: November 2026
45
+ Webpage: https://bug7a.github.io/js-components/
46
+
47
+ Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
48
+ Licensed under the Apache License, Version 2.0
49
+ SPDX-License-Identifier: Apache-2.0
50
+
51
+ */
52
+
53
+ "use strict";
54
+
55
+ // Default values:
56
+ const StatusBarDefaults = {
57
+ key: "0", // Your name for this object: read it in a callback (self.key)
58
+ left: 0,
59
+ width: "100%",
60
+ height: 28,
61
+ messageText: "",
62
+ messageTone: "", // "", "success", "warn", "error", "info"
63
+ items: [], // [{ key, text, icon, tone, ariaLabel, onClick }, "Text"]
64
+ busy: 0,
65
+ ariaLabel: "Status bar",
66
+ styleName: "light", // "light", "dark", "minimal", "minimalDark" or a name added to StatusBar.styles
67
+ style: { // Light style package (default)
68
+ box: { color: "#F4F4F2", lineColor: Black(0.12) },
69
+ layout: { padding: 10, gap: 8 },
70
+ message: { fontSize: 12, textColor: Black(0.68) },
71
+ dot: { size: 8 },
72
+ busy: { size: 12, lineWidth: 2, color: "#3F8D94", trackColor: Black(0.12) },
73
+ part: { fontSize: 12, textColor: Black(0.68), padding: 8, iconSize: 14, iconGap: 5, lineColor: Black(0.12) },
74
+ partHover: { color: Black(0.07), textColor: Black(0.88) },
75
+ tones: { // text: on a text, dot: the dot of a message
76
+ success: { text: "#1F7A5C", dot: "#2E9E74" },
77
+ warn: { text: "#8A5A00", dot: "#E0A92B" },
78
+ error: { text: "#C0362C", dot: "#E2604F" },
79
+ info: { text: "#2467B8", dot: "#4A96D8" },
80
+ },
81
+ focus: { ringColor: "rgba(63, 141, 148, 0.8)" },
82
+ },
83
+ };
84
+
85
+ const StatusBar = function (params = {}) {
86
+
87
+ // Merge style package: params.style > StatusBar.styles[styleName] > StatusBarDefaults.style (light)
88
+ const pageStyle = params.style; // WHY: setTheme() puts it over another package.
89
+ basic.applyStylePackage(params, StatusBar.styles, StatusBarDefaults);
90
+
91
+ // Merge params:
92
+ mergeIntoIfMissing(params, StatusBarDefaults);
93
+
94
+ // Edit params, if needed:
95
+ params.items = (Array.isArray(params.items)) ? params.items : [];
96
+ // WHY not a default: a default bottom would clear a top given by the page. (In a VGroup it has no effect.)
97
+ if (params.top === undefined && params.bottom === undefined) params.bottom = 0;
98
+
99
+ // BOX: Component container
100
+ const box = startObject(params);
101
+
102
+ // *** PRIVATE VARIABLES:
103
+ let _s = box.style;
104
+ let lastingText = box.messageText; // The message a message with a time goes back to
105
+ let lastingTone = box.messageTone;
106
+ let cancelMessageEnd = null; // The cancel function of the waiting end of a message with a time
107
+
108
+ // *** PUBLIC VARIABLES:
109
+ box.partList = []; // [{ item, obj }]: the parts and their objects
110
+ // NOTE: Default values are also public variables. (box.messageText, box.messageTone, box.busy...)
111
+
112
+ // *** PRIVATE FUNCTIONS:
113
+
114
+ // The style of a package, with the style of the page over it. (setTheme)
115
+ const styleOfPackage = function (styleName) {
116
+ const fresh = { styleName: styleName, style: pageStyle };
117
+ basic.applyStylePackage(fresh, StatusBar.styles, StatusBarDefaults);
118
+ mergeIntoIfMissing(fresh, StatusBarDefaults);
119
+ return fresh.style;
120
+ };
121
+
122
+ const normalizeItem = function (item) {
123
+ if (typeof item == "string" || typeof item == "number") return { key: String(item), text: String(item) };
124
+ return Object.assign({ key: item.text, text: "" }, item);
125
+ };
126
+
127
+ const toneColor = function (tone, partName, fallback) {
128
+ const look = _s.tones[tone];
129
+ return (look) ? look[partName] : fallback;
130
+ };
131
+
132
+ // PAINT: a part with the mouse on it
133
+ const paintPart = function (part, isOver) {
134
+ const hasHover = (isOver && part.item.onClick);
135
+ part.obj.color = (hasHover) ? _s.partHover.color : "transparent";
136
+ part.obj.textColor = (hasHover) ? _s.partHover.textColor : toneColor(part.item.tone, "text", _s.part.textColor);
137
+ };
138
+
139
+ // CONTENT: the icon and the text of a part
140
+ // WHY: An SVG icon and the text are in one object: a button can not hold other objects.
141
+ const applyPartContent = function (part) {
142
+ if (part.item.icon) {
143
+ part.obj.text = part.item.icon + "<span>" + basic.escapeHtml(part.item.text) + "</span>";
144
+ } else {
145
+ part.obj.plainText = part.item.text;
146
+ }
147
+ };
148
+
149
+ const createPartObject = function (item) {
150
+ const isButton = (typeof item.onClick == "function");
151
+ const look = {
152
+ fontSize: _s.part.fontSize,
153
+ height: "100%",
154
+ shrink: 0,
155
+ // WHY display here and not in the class: the visible prop writes back only an inline display.
156
+ css: { display: "inline-flex", padding: "0 " + _s.part.padding + "px" },
157
+ };
158
+ if (!isButton) return Label(look);
159
+
160
+ // BUTTON: A part that can be clicked
161
+ const button = Button(look);
162
+ button.minimal = 1;
163
+ button.width = "auto";
164
+ button.round = 0;
165
+ button.setFocusRing(_s.focus.ringColor);
166
+ if (item.ariaLabel) button.aria = { label: item.ariaLabel };
167
+ return button;
168
+ };
169
+
170
+ const createPart = function (item, index) {
171
+ const obj = createPartObject(item);
172
+ const part = { item: item, obj: obj };
173
+ obj.elem.classList.add("status-bar-part");
174
+ obj.elem.style.setProperty("--status-bar-icon", _s.part.iconSize + "px");
175
+ obj.elem.style.setProperty("--status-bar-icon-gap", _s.part.iconGap + "px");
176
+ // WHY: A thin line between the parts, not at the left of the first one: the message is not a part of them.
177
+ obj.css.borderLeft = (index > 0) ? ("1px solid " + _s.part.lineColor) : "0";
178
+ applyPartContent(part);
179
+ paintPart(part, 0);
180
+ if (item.onClick) {
181
+ obj.onHoverChange(function (self, isOver) { paintPart(part, isOver); });
182
+ obj.on("click", function () { item.onClick(box, item); });
183
+ }
184
+ return part;
185
+ };
186
+
187
+ const createItems = function () {
188
+ box.partList.forEach(function (part) { part.obj.remove(); });
189
+ box.partList = box.items.map(function (item, index) {
190
+ return createIn(box.partGroup, function () { return createPart(item, index); });
191
+ });
192
+ };
193
+
194
+ // PAINT: the mark in front of the message: the turning circle or the dot of a tone
195
+ const paintMark = function () {
196
+ const dotColor = toneColor(box.messageTone, "dot", "");
197
+ box.spinner.visible = (box.busy == 1) ? 1 : 0;
198
+ box.dot.visible = (box.busy != 1 && dotColor) ? 1 : 0;
199
+ if (dotColor) box.dot.color = dotColor;
200
+ };
201
+
202
+ // CONTENT: the message
203
+ const applyMessage = function () {
204
+ box.lblMessage.plainText = box.messageText;
205
+ box.lblMessage.textColor = toneColor(box.messageTone, "text", _s.message.textColor);
206
+ paintMark();
207
+ };
208
+
209
+ // LOOK: everything that comes from the style (the first drawing and setTheme)
210
+ const applyLook = function () {
211
+ box.color = _s.box.color;
212
+ box.css.borderTop = "1px solid " + _s.box.lineColor;
213
+ box.layout.gap = _s.layout.gap;
214
+ box.layout.padding = [_s.layout.padding, 0];
215
+ box.spinner.props({ width: _s.busy.size, height: _s.busy.size, round: _s.busy.size / 2 });
216
+ box.spinner.css.border = _s.busy.lineWidth + "px solid " + _s.busy.trackColor;
217
+ box.spinner.css.borderTopColor = _s.busy.color;
218
+ box.dot.props({ width: _s.dot.size, height: _s.dot.size, round: _s.dot.size / 2 });
219
+ box.lblMessage.fontSize = _s.message.fontSize;
220
+ createItems();
221
+ applyMessage();
222
+ };
223
+
224
+ const showMessage = function (text, tone) {
225
+ box.messageText = text;
226
+ box.messageTone = tone;
227
+ applyMessage();
228
+ };
229
+
230
+ const stopMessageTimer = function () {
231
+ if (cancelMessageEnd) cancelMessageEnd();
232
+ cancelMessageEnd = null;
233
+ };
234
+
235
+ // *** PUBLIC FUNCTIONS:
236
+
237
+ // showTime (ms): after it the bar goes back to the lasting message. 0: this one is the lasting message.
238
+ box.setMessageText = function (text, tone = "", showTime = 0) {
239
+ stopMessageTimer();
240
+ showMessage(text, tone);
241
+ if (showTime > 0) {
242
+ cancelMessageEnd = box.after(showTime, function () {
243
+ cancelMessageEnd = null;
244
+ showMessage(lastingText, lastingTone);
245
+ });
246
+ return;
247
+ }
248
+ lastingText = text;
249
+ lastingTone = tone;
250
+ };
251
+ // USAGE: bar.setMessageText("Saved", "success", 3000)
252
+
253
+ box.setBusy = function (value) {
254
+ box.busy = basic.isOn(value) ? 1 : 0;
255
+ paintMark();
256
+ };
257
+ // USAGE: bar.setBusy(1)
258
+
259
+ box.setItems = function (items) {
260
+ box.items = (Array.isArray(items)) ? items.map(normalizeItem) : [];
261
+ createItems();
262
+ };
263
+ // USAGE: bar.setItems(["3 files", { key: "zoom", text: "100%", onClick: openZoomMenu }])
264
+
265
+ box.getItem = function (key) {
266
+ return box.items.find(function (item) { return item.key == key; }) || null;
267
+ };
268
+
269
+ const getPart = function (key) {
270
+ return box.partList.find(function (part) { return part.item.key == key; }) || null;
271
+ };
272
+
273
+ box.setItemText = function (key, text) {
274
+ const part = getPart(key);
275
+ if (!part) return;
276
+ part.item.text = String(text);
277
+ applyPartContent(part);
278
+ };
279
+ // USAGE: bar.setItemText("files", "4 files")
280
+
281
+ box.setItemVisible = function (key, value) {
282
+ const part = getPart(key);
283
+ if (part) part.obj.visible = basic.isOn(value) ? 1 : 0;
284
+ };
285
+ // USAGE: bar.setItemVisible("zoom", 0)
286
+
287
+ // Another style package while it is on the page. A style given by the page stays over it.
288
+ box.setTheme = function (styleName) {
289
+ box.styleName = styleName;
290
+ _s = styleOfPackage(styleName);
291
+ box.style = _s;
292
+ applyLook();
293
+ };
294
+ // USAGE: bar.setTheme("dark")
295
+
296
+ // *** OBJECT VIEW:
297
+
298
+ // An SVG icon in a part stands next to its text.
299
+ // WHY: A status bar is one line, so the parts are never wrapped.
300
+ basic.addCss("status-bar-part",
301
+ ".status-bar-part { align-items: center; gap: var(--status-bar-icon-gap); white-space: nowrap; }" +
302
+ ".status-bar-part svg { display: block; width: var(--status-bar-icon); height: var(--status-bar-icon); flex: none; }");
303
+ basic.addCss("status-bar-spin",
304
+ "@keyframes status-bar-spin { to { transform: rotate(360deg); } }" +
305
+ ".status-bar-spinner { animation: status-bar-spin 0.9s linear infinite; }" +
306
+ "@media (prefers-reduced-motion: reduce) { .status-bar-spinner { animation: none; } }");
307
+
308
+ // BOX: The bar
309
+ box.css.boxSizing = "border-box";
310
+ box.role = "group";
311
+ box.aria = { label: box.ariaLabel };
312
+
313
+ // GROUP: The message at the left, the parts at the right
314
+ box.layout = HGroup({ width: "100%", height: "100%", align: "left center" });
315
+
316
+ // BOX: The turning circle
317
+ box.spinner = Box({ color: "transparent", shrink: 0 });
318
+ box.spinner.elem.classList.add("status-bar-spinner");
319
+
320
+ // BOX: The dot of a tone
321
+ box.dot = Box({ shrink: 0 });
322
+
323
+ // LABEL: The message
324
+ box.lblMessage = Label({ ellipsis: 1, grow: 1, shrink: 1, css: { minWidth: "0", flexBasis: "0" } });
325
+ box.lblMessage.role = "status";
326
+
327
+ // GROUP: The parts
328
+ box.partGroup = HGroup({ width: "auto", height: "100%", align: "right center", gap: 0, shrink: 0 });
329
+ endGroup();
330
+
331
+ endGroup();
332
+
333
+ // *** OBJECT INIT CODE:
334
+
335
+ box.items = (Array.isArray(params.items)) ? params.items.map(normalizeItem) : [];
336
+ applyLook();
337
+
338
+ return endObject(box);
339
+
340
+ };
341
+
342
+ // *** STYLE PACKAGES:
343
+ // USAGE: StatusBar({ styleName: "dark" })
344
+ // USAGE: StatusBar({ styleName: "dark", style: { box: { color: "#101010" } } }) // Change only some keys.
345
+ // NOTE: A new package needs only the keys that differ from the default (light) style.
346
+ // USAGE: StatusBar.styles.myStyle = { box: { color: "tomato" } };
347
+ StatusBar.styles = {
348
+
349
+ // A light gray bar, dark text, a soft line over it.
350
+ light: StatusBarDefaults.style,
351
+
352
+ // For a dark window.
353
+ dark: {
354
+ box: { color: "#232322", lineColor: White(0.1) },
355
+ message: { textColor: White(0.72) },
356
+ busy: { color: "#6FC6CD", trackColor: White(0.16) },
357
+ part: { textColor: White(0.72), lineColor: White(0.1) },
358
+ partHover: { color: White(0.09), textColor: White(0.95) },
359
+ tones: {
360
+ success: { text: "#7FE3B5", dot: "#2E9E74" },
361
+ warn: { text: "#F1C74A", dot: "#F1C74A" },
362
+ error: { text: "#FF9F93", dot: "#E8796D" },
363
+ info: { text: "#8CC4EE", dot: "#5AA9E6" },
364
+ },
365
+ focus: { ringColor: "rgba(111, 198, 205, 0.8)" },
366
+ },
367
+
368
+ };
369
+
370
+ // The minimal theme (_designs/minimal-theme.htm): no fill (the ground of the window), one line over it, 12 px soft
371
+ // texts; a part that can be clicked gets darker under the mouse (no fill). minimalDark: the same on a dark window.
372
+ StatusBar.createMinimalStyle = function (colors) {
373
+ return {
374
+ height: 24,
375
+ style: {
376
+ box: { color: "transparent", lineColor: colors.line },
377
+ layout: { padding: 10, gap: 8 },
378
+ message: { fontSize: 12, textColor: colors.softText },
379
+ dot: { size: 6 },
380
+ busy: { size: 12, lineWidth: 1.5, color: colors.ink, trackColor: colors.track },
381
+ part: { fontSize: 12, textColor: colors.softText, padding: 8, iconSize: 12, iconGap: 5, lineColor: colors.line },
382
+ partHover: { color: "transparent", textColor: colors.text },
383
+ tones: colors.tones,
384
+ focus: { ringColor: colors.focus },
385
+ },
386
+ };
387
+ };
388
+ // WHY own tones: the texts of a tone must read on the ground of the window (4.5:1); the light tones were about 3:1 on dark.
389
+ StatusBar.MINIMAL_COLORS = {
390
+ text: Black(0.85), softText: Black(0.55), line: Black(0.2), track: Black(0.12), ink: "#1F1F1F", focus: "#3D8BD9",
391
+ tones: {
392
+ success: { text: "#1F7A5C", dot: "#2E9E74" },
393
+ warn: { text: "#8A5A00", dot: "#B77A00" },
394
+ error: { text: "#C24A36", dot: "#C24A36" },
395
+ info: { text: "#2467B8", dot: "#3D8BD9" },
396
+ },
397
+ };
398
+ StatusBar.styles.minimal = StatusBar.createMinimalStyle(StatusBar.MINIMAL_COLORS);
399
+ StatusBar.MINIMAL_DARK_COLORS = {
400
+ text: White(0.88), softText: White(0.55), line: White(0.18), track: White(0.14), ink: "#EDEDEB", focus: "#7FB6DE",
401
+ tones: {
402
+ success: { text: "#7FE3B5", dot: "#7FE3B5" },
403
+ warn: { text: "#E8B23A", dot: "#E8B23A" },
404
+ error: { text: "#FF9F93", dot: "#FF9F93" },
405
+ info: { text: "#7FB6DE", dot: "#7FB6DE" },
406
+ },
407
+ };
408
+ StatusBar.styles.minimalDark = StatusBar.createMinimalStyle(StatusBar.MINIMAL_DARK_COLORS);