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.
- checksums.yaml +7 -0
- data/LICENSE +14 -0
- data/NOTICE +5 -0
- data/README.md +242 -0
- data/exe/ozdenui +17 -0
- data/lib/ozdenui/AGENTS.md +210 -0
- data/lib/ozdenui/COMPONENTS.md +3017 -0
- data/lib/ozdenui/app.rb +749 -0
- data/lib/ozdenui/command.rb +107 -0
- data/lib/ozdenui/components.rb +368 -0
- data/lib/ozdenui/dialogs.rb +212 -0
- data/lib/ozdenui/files.rb +124 -0
- data/lib/ozdenui/icon.png +0 -0
- data/lib/ozdenui/kit.json +1 -0
- data/lib/ozdenui/kit.rb +115 -0
- data/lib/ozdenui/look.rb +229 -0
- data/lib/ozdenui/objects.rb +652 -0
- data/lib/ozdenui/server.rb +270 -0
- data/lib/ozdenui/values.rb +273 -0
- data/lib/ozdenui/version.rb +15 -0
- data/lib/ozdenui/web/basic/LICENSE +14 -0
- data/lib/ozdenui/web/basic/basic.min.css +1 -0
- data/lib/ozdenui/web/basic/basic.min.js +78 -0
- data/lib/ozdenui/web/basic/font/open-sans/LICENSE.txt +206 -0
- data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Bold.ttf +0 -0
- data/lib/ozdenui/web/basic/font/open-sans/OpenSans-Regular.ttf +0 -0
- data/lib/ozdenui/web/basic/scroll-bar.min.js +3 -0
- data/lib/ozdenui/web/bridge.js +584 -0
- data/lib/ozdenui/web/comp/accordion.js +659 -0
- data/lib/ozdenui/web/comp/action-button/add.png +0 -0
- data/lib/ozdenui/web/comp/action-button.js +521 -0
- data/lib/ozdenui/web/comp/action-tab-bar.js +383 -0
- data/lib/ozdenui/web/comp/app-bar.js +237 -0
- data/lib/ozdenui/web/comp/badge.js +292 -0
- data/lib/ozdenui/web/comp/bottom-bar.js +555 -0
- data/lib/ozdenui/web/comp/breadcrumbs.js +524 -0
- data/lib/ozdenui/web/comp/canvas.js +652 -0
- data/lib/ozdenui/web/comp/chat-view.js +827 -0
- data/lib/ozdenui/web/comp/check-box.js +490 -0
- data/lib/ozdenui/web/comp/code-editor.js +965 -0
- data/lib/ozdenui/web/comp/color-picker.js +636 -0
- data/lib/ozdenui/web/comp/context-menu.js +951 -0
- data/lib/ozdenui/web/comp/currency-field.js +209 -0
- data/lib/ozdenui/web/comp/data-table/arrow.svg +2 -0
- data/lib/ozdenui/web/comp/data-table.js +937 -0
- data/lib/ozdenui/web/comp/date-picker.js +1055 -0
- data/lib/ozdenui/web/comp/dialog.js +992 -0
- data/lib/ozdenui/web/comp/email-field.js +65 -0
- data/lib/ozdenui/web/comp/file-picker.js +920 -0
- data/lib/ozdenui/web/comp/filters.js +807 -0
- data/lib/ozdenui/web/comp/form.js +602 -0
- data/lib/ozdenui/web/comp/full-screen-select/arrow.svg +2 -0
- data/lib/ozdenui/web/comp/full-screen-select/cancel.svg +2 -0
- data/lib/ozdenui/web/comp/full-screen-select.js +614 -0
- data/lib/ozdenui/web/comp/gauge.js +439 -0
- data/lib/ozdenui/web/comp/graph-box.js +3911 -0
- data/lib/ozdenui/web/comp/grid-group.js +185 -0
- data/lib/ozdenui/web/comp/hold-to-confirm-button/trash-red.png +0 -0
- data/lib/ozdenui/web/comp/hold-to-confirm-button/trash.png +0 -0
- data/lib/ozdenui/web/comp/hold-to-confirm-button.js +289 -0
- data/lib/ozdenui/web/comp/image-view.js +598 -0
- data/lib/ozdenui/web/comp/item-list.js +1740 -0
- data/lib/ozdenui/web/comp/json-editor.js +3221 -0
- data/lib/ozdenui/web/comp/json-view.js +597 -0
- data/lib/ozdenui/web/comp/label-editor.js +1140 -0
- data/lib/ozdenui/web/comp/left-menu/data-table.png +0 -0
- data/lib/ozdenui/web/comp/left-menu/home.png +0 -0
- data/lib/ozdenui/web/comp/left-menu/reports.png +0 -0
- data/lib/ozdenui/web/comp/left-menu/setting.png +0 -0
- data/lib/ozdenui/web/comp/left-menu.js +548 -0
- data/lib/ozdenui/web/comp/line-progress-bar.js +343 -0
- data/lib/ozdenui/web/comp/loading-screen.js +413 -0
- data/lib/ozdenui/web/comp/log-view.js +530 -0
- data/lib/ozdenui/web/comp/login-page.js +685 -0
- data/lib/ozdenui/web/comp/markdown-view.js +1045 -0
- data/lib/ozdenui/web/comp/menu-bar.js +624 -0
- data/lib/ozdenui/web/comp/mini-graph-box.js +492 -0
- data/lib/ozdenui/web/comp/minimal-accent.js +208 -0
- data/lib/ozdenui/web/comp/notice.js +229 -0
- data/lib/ozdenui/web/comp/number-field.js +128 -0
- data/lib/ozdenui/web/comp/numeric-keyboard.js +298 -0
- data/lib/ozdenui/web/comp/page-control.js +762 -0
- data/lib/ozdenui/web/comp/page-header.js +191 -0
- data/lib/ozdenui/web/comp/password-field/hide-btn.png +0 -0
- data/lib/ozdenui/web/comp/password-field/hide-btn2.png +0 -0
- data/lib/ozdenui/web/comp/password-field/show-btn.png +0 -0
- data/lib/ozdenui/web/comp/password-field/show-btn2.png +0 -0
- data/lib/ozdenui/web/comp/password-field.js +192 -0
- data/lib/ozdenui/web/comp/period-bar.js +436 -0
- data/lib/ozdenui/web/comp/phone-field.js +322 -0
- data/lib/ozdenui/web/comp/progress-bar.js +992 -0
- data/lib/ozdenui/web/comp/property-panel.js +3639 -0
- data/lib/ozdenui/web/comp/radio-button.js +527 -0
- data/lib/ozdenui/web/comp/range-slider.js +569 -0
- data/lib/ozdenui/web/comp/rich-text-editor.js +1064 -0
- data/lib/ozdenui/web/comp/scroll-area.js +308 -0
- data/lib/ozdenui/web/comp/scrolling-text.js +297 -0
- data/lib/ozdenui/web/comp/search-input/clear-round.svg +1 -0
- data/lib/ozdenui/web/comp/search-input/clear.svg +1 -0
- data/lib/ozdenui/web/comp/search-input/filter.png +0 -0
- data/lib/ozdenui/web/comp/search-input/filter.svg +1 -0
- data/lib/ozdenui/web/comp/search-input/search.svg +1 -0
- data/lib/ozdenui/web/comp/search-input.js +725 -0
- data/lib/ozdenui/web/comp/search-results.js +596 -0
- data/lib/ozdenui/web/comp/select-box.js +1862 -0
- data/lib/ozdenui/web/comp/settings-row.js +299 -0
- data/lib/ozdenui/web/comp/side-panel.js +616 -0
- data/lib/ozdenui/web/comp/slider-field.js +952 -0
- data/lib/ozdenui/web/comp/slider.js +838 -0
- data/lib/ozdenui/web/comp/smart-button/alert-black.png +0 -0
- data/lib/ozdenui/web/comp/smart-button/clock.png +0 -0
- data/lib/ozdenui/web/comp/smart-button.js +981 -0
- data/lib/ozdenui/web/comp/smart-table/clock.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/down.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/scroll.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/sort.png +0 -0
- data/lib/ozdenui/web/comp/smart-table/up.png +0 -0
- data/lib/ozdenui/web/comp/smart-table.js +1883 -0
- data/lib/ozdenui/web/comp/sortable-list.js +1181 -0
- data/lib/ozdenui/web/comp/spark-line-box.js +738 -0
- data/lib/ozdenui/web/comp/splitter.js +411 -0
- data/lib/ozdenui/web/comp/status-bar.js +408 -0
- data/lib/ozdenui/web/comp/step-bar.js +345 -0
- data/lib/ozdenui/web/comp/stepper.js +753 -0
- data/lib/ozdenui/web/comp/tabs.js +1366 -0
- data/lib/ozdenui/web/comp/tag-input.js +1107 -0
- data/lib/ozdenui/web/comp/tap-effect.js +170 -0
- data/lib/ozdenui/web/comp/text-area-field.js +233 -0
- data/lib/ozdenui/web/comp/text-field.js +1006 -0
- data/lib/ozdenui/web/comp/time-line.js +398 -0
- data/lib/ozdenui/web/comp/time-picker.js +1032 -0
- data/lib/ozdenui/web/comp/tiny-select/arrow.svg +1 -0
- data/lib/ozdenui/web/comp/tiny-select.js +322 -0
- data/lib/ozdenui/web/comp/tiny-table.js +283 -0
- data/lib/ozdenui/web/comp/toast.js +891 -0
- data/lib/ozdenui/web/comp/toggle.js +757 -0
- data/lib/ozdenui/web/comp/tool-bar.js +760 -0
- data/lib/ozdenui/web/comp/tooltip.js +534 -0
- data/lib/ozdenui/web/comp/tree-view.js +1179 -0
- data/lib/ozdenui/web/comp/ui-effects.js +1097 -0
- data/lib/ozdenui/web/comp/ui-standards.js +403 -0
- data/lib/ozdenui/web/comp/url-field.js +190 -0
- data/lib/ozdenui/web/comp/web-view.js +588 -0
- data/lib/ozdenui/web/components.js +123 -0
- data/lib/ozdenui/web/index.html +39 -0
- data/lib/ozdenui/window.rb +188 -0
- data/lib/ozdenui/window_cocoa.rb +221 -0
- data/lib/ozdenui.rb +32 -0
- metadata +200 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/* Bismillah */
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
|
|
5
|
+
SettingsRow - v26.11
|
|
6
|
+
|
|
7
|
+
A ROW OF A SETTINGS PAGE of a mobile app.
|
|
8
|
+
- The sizes are px of a 600 px design: the page is fitted with page.fit(600, 800), like the mobile template
|
|
9
|
+
(04-templates/mobile-app-template/classic).
|
|
10
|
+
- A white row, 100 px high, a thin line at the bottom. A title (20 px) at the left; with a small text (descriptionText,
|
|
11
|
+
one line, "..." at its end) the title stands 14 px over the middle and the small text 14 px under it.
|
|
12
|
+
- setDescriptionText(text): the small text fades in or out and the title slides to its place (0.3 s; no motion at the
|
|
13
|
+
first view, none with prefers-reduced-motion). The old text stays while it fades out.
|
|
14
|
+
- A control at the right: control: function (row) { Toggle({...}); } -> the objects made in it stand in a row at
|
|
15
|
+
the right side, 20 px from the right, in the middle of the row (they need no left / top / right).
|
|
16
|
+
- arrow: 1 -> a chevron at the right (drawn in SVG), for a row that opens a page. Give that row an onClick: a row
|
|
17
|
+
with onClick can be clicked (role "button"), Tab reaches it, Enter / Space press it (a focus ring only for the
|
|
18
|
+
keyboard). A click on a control in the row is the control's own (it does not call onClick).
|
|
19
|
+
- titleColor: Ex: "orangered" for a row that deletes something.
|
|
20
|
+
- SettingsRow.createSection(titleText, params): the band between the groups of rows (Ex: "APPEARANCE").
|
|
21
|
+
- The rows go one under the other in a VGroup (in a box that scrolls: CLAUDE.md).
|
|
22
|
+
|
|
23
|
+
USAGE:
|
|
24
|
+
VGroup({ width: "100%", height: "auto", align: "left top", gap: 0 });
|
|
25
|
+
SettingsRow.createSection("APPEARANCE");
|
|
26
|
+
SettingsRow({ titleText: "Dark Mode", descriptionText: "Use interface colors inverted.", control: function (row) {
|
|
27
|
+
Toggle({ width: 60, height: 40, onChange: function (self) { saveDarkMode(self.value); } });
|
|
28
|
+
} });
|
|
29
|
+
const videoRow = SettingsRow({ titleText: "Video Quality", descriptionText: "Remaining disk space: 2.3GB" });
|
|
30
|
+
SettingsRow({ titleText: "Security", arrow: 1, onClick: function (self) { App.open("security"); } });
|
|
31
|
+
SettingsRow({ titleText: "Delete All Downloads", titleColor: "orangered", arrow: 1, onClick: deleteDownloads });
|
|
32
|
+
endGroup();
|
|
33
|
+
videoRow.setDescriptionText(""); // the small text fades out, the title slides to the middle
|
|
34
|
+
videoRow.setTitleColor("orangered");
|
|
35
|
+
|
|
36
|
+
Started Date: November 2026
|
|
37
|
+
Webpage: https://bug7a.github.io/js-components/
|
|
38
|
+
|
|
39
|
+
Copyright 2020-2026 Bugra Ozden <bugra.ozden@gmail.com> (https://bug7a.github.io/)
|
|
40
|
+
Licensed under the Apache License, Version 2.0
|
|
41
|
+
SPDX-License-Identifier: Apache-2.0
|
|
42
|
+
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
"use strict";
|
|
46
|
+
|
|
47
|
+
// Default values:
|
|
48
|
+
const SettingsRowDefaults = {
|
|
49
|
+
key: "0", // Your name for this object: read it in a callback (self.key)
|
|
50
|
+
width: "100%",
|
|
51
|
+
height: 100,
|
|
52
|
+
color: "white", // The background of the row
|
|
53
|
+
titleText: "",
|
|
54
|
+
descriptionText: "", // The small text under the title. "": the title stands in the middle (setDescriptionText)
|
|
55
|
+
titleColor: Black(0.8), // Ex: "orangered" for a row that deletes something (setTitleColor)
|
|
56
|
+
control: null, // function (row): the objects made in it stand at the right (Ex: a Toggle). Its result: row.controlObject
|
|
57
|
+
arrow: 0, // 1: a chevron at the right (a row that opens a page: give it onClick)
|
|
58
|
+
onClick: null, // function (self, event): the row can be clicked (role "button", Enter / Space)
|
|
59
|
+
style: {
|
|
60
|
+
layout: {
|
|
61
|
+
side: 20, // The space at the left and the right
|
|
62
|
+
gap: 10, // Between the texts, the objects of the control and the arrow
|
|
63
|
+
textShift: 14, // With a small text: the title goes up and the small text down by this much from the middle
|
|
64
|
+
},
|
|
65
|
+
title: {
|
|
66
|
+
fontSize: 20,
|
|
67
|
+
},
|
|
68
|
+
desc: {
|
|
69
|
+
fontSize: 18,
|
|
70
|
+
textColor: Black(0.5),
|
|
71
|
+
},
|
|
72
|
+
arrow: {
|
|
73
|
+
size: 36,
|
|
74
|
+
color: Black(0.8),
|
|
75
|
+
},
|
|
76
|
+
line: {
|
|
77
|
+
width: 1,
|
|
78
|
+
color: Black(0.2),
|
|
79
|
+
},
|
|
80
|
+
focus: {
|
|
81
|
+
ringColor: "rgba(95, 158, 160, 0.6)", // The ring of the keyboard focus
|
|
82
|
+
},
|
|
83
|
+
motionTime: 0.3, // s: the small text fades, the title slides
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const SettingsRow = function (params = {}) {
|
|
88
|
+
|
|
89
|
+
// Merge params:
|
|
90
|
+
mergeIntoIfMissing(params, SettingsRowDefaults);
|
|
91
|
+
|
|
92
|
+
// Edit params, if needed:
|
|
93
|
+
params.descriptionText = SettingsRow.toText(params.descriptionText);
|
|
94
|
+
|
|
95
|
+
// BOX: Component container
|
|
96
|
+
const box = startObject(params);
|
|
97
|
+
|
|
98
|
+
// *** PRIVATE VARIABLES:
|
|
99
|
+
const _s = box.style;
|
|
100
|
+
const isClickable = (typeof box.onClick === "function");
|
|
101
|
+
|
|
102
|
+
// *** PUBLIC VARIABLES:
|
|
103
|
+
box.controlObject = null; // What control() returned (Ex: the Toggle), or null
|
|
104
|
+
// NOTE: Default values are also public variables. (box.titleText, box.descriptionText...)
|
|
105
|
+
|
|
106
|
+
// *** PRIVATE FUNCTIONS:
|
|
107
|
+
|
|
108
|
+
const isReducedMotion = function () {
|
|
109
|
+
return window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// The middle of the row moved by shift px (no measuring: the label is moved by its own half height)
|
|
113
|
+
const getMiddleTransform = function (shift) {
|
|
114
|
+
return "translateY(calc(-50% + " + shift + "px))";
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// The small text fades in or out (its old text stays while it fades out), the title slides to its place.
|
|
118
|
+
const showTexts = function () {
|
|
119
|
+
const hasDesc = (box.descriptionText !== "");
|
|
120
|
+
if (hasDesc) box.lblDesc.plainText = box.descriptionText;
|
|
121
|
+
box.lblDesc.opacity = hasDesc ? 1 : 0;
|
|
122
|
+
box.lblDesc.aria = { hidden: hasDesc ? null : true };
|
|
123
|
+
const titleShift = hasDesc ? -_s.layout.textShift : 0;
|
|
124
|
+
box.lblTitle.css = { transform: getMiddleTransform(titleShift) };
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// WHY setMotion(): it starts a moment later, so the first view does not move
|
|
128
|
+
const applyMotion = function () {
|
|
129
|
+
if (isReducedMotion()) return;
|
|
130
|
+
const time = _s.motionTime + "s";
|
|
131
|
+
box.lblTitle.setMotion("transform " + time);
|
|
132
|
+
box.lblDesc.setMotion("opacity " + time);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// The objects of control() go into their group at the right.
|
|
136
|
+
// WHY no places: an object in a group is relative, and the "right: 20" of an object in a box would move it 20 px
|
|
137
|
+
// to the left; the group places them.
|
|
138
|
+
const createControl = function () {
|
|
139
|
+
if (typeof box.control !== "function") return;
|
|
140
|
+
box.controlObject = createIn(box.controlGroup, function () {
|
|
141
|
+
return box.control(box);
|
|
142
|
+
}) || null;
|
|
143
|
+
box.controlGroup.children.forEach(function (obj) {
|
|
144
|
+
obj.css = { left: "", right: "", top: "", bottom: "" };
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// A click on a control in the row (a Toggle) is the control's own
|
|
149
|
+
const isFromControl = function (event) {
|
|
150
|
+
return box.controlGroup.elem.contains(event.target);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const press = function (event) {
|
|
154
|
+
box.onClick(box, event);
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// A row with onClick: the mouse, Tab and Enter / Space
|
|
158
|
+
const makeClickable = function () {
|
|
159
|
+
box.clickable = 1;
|
|
160
|
+
box.cursor = "pointer";
|
|
161
|
+
box.role = "button";
|
|
162
|
+
box.tabIndex = 0;
|
|
163
|
+
box.setFocusRing(_s.focus.ringColor);
|
|
164
|
+
box.on("click", function (self, event) {
|
|
165
|
+
if (isFromControl(event)) return;
|
|
166
|
+
press(event);
|
|
167
|
+
});
|
|
168
|
+
box.on("keydown", function (self, event) {
|
|
169
|
+
if (event.target !== box.elem) return; // WHY: the keys of a control in the row stay its own
|
|
170
|
+
if (event.key != "Enter" && event.key != " ") return;
|
|
171
|
+
event.preventDefault(); // WHY: Space must not scroll the page
|
|
172
|
+
if (event.repeat) return; // WHY: a held key presses once
|
|
173
|
+
press(event);
|
|
174
|
+
});
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// *** PUBLIC FUNCTIONS:
|
|
178
|
+
|
|
179
|
+
box.setTitleText = function (text) {
|
|
180
|
+
box.titleText = text;
|
|
181
|
+
box.lblTitle.plainText = text;
|
|
182
|
+
};
|
|
183
|
+
// USAGE: row.setTitleText("Dark Mode")
|
|
184
|
+
|
|
185
|
+
// The small text fades in / out and the title slides (0.3 s)
|
|
186
|
+
box.setDescriptionText = function (text) {
|
|
187
|
+
box.descriptionText = SettingsRow.toText(text);
|
|
188
|
+
showTexts();
|
|
189
|
+
};
|
|
190
|
+
// USAGE: get: row.descriptionText, set: row.setDescriptionText("Remaining disk space: 2.3GB") / row.setDescriptionText("")
|
|
191
|
+
|
|
192
|
+
box.setTitleColor = function (color) {
|
|
193
|
+
box.titleColor = color;
|
|
194
|
+
box.lblTitle.textColor = color;
|
|
195
|
+
};
|
|
196
|
+
// USAGE: row.setTitleColor("orangered")
|
|
197
|
+
|
|
198
|
+
// *** OBJECT VIEW:
|
|
199
|
+
|
|
200
|
+
// BOX: Row
|
|
201
|
+
box.shrink = 0; // WHY: in a group with a fixed height the rows keep their height (the box scrolls)
|
|
202
|
+
box.css = { borderBottom: _s.line.width + "px solid " + _s.line.color };
|
|
203
|
+
|
|
204
|
+
// GROUP: Layout (the texts take the free room; the control and the arrow stand at the right)
|
|
205
|
+
box.layout = HGroup({ width: "100%", height: "100%", align: "left center", gap: _s.layout.gap, padding: [_s.layout.side, 0] });
|
|
206
|
+
|
|
207
|
+
// BOX: Texts (the title and the small text around the middle of the row)
|
|
208
|
+
box.texts = startBox({ height: "100%", color: "transparent" });
|
|
209
|
+
box.texts.css = { flex: "1 1 0", minWidth: "0px" }; // WHY: it takes the free room, its texts end with "..."
|
|
210
|
+
|
|
211
|
+
// LABEL: Title
|
|
212
|
+
box.lblTitle = Label({ left: 0, top: "50%", width: "100%", ..._s.title, textColor: box.titleColor, ellipsis: 1 });
|
|
213
|
+
|
|
214
|
+
// LABEL: Small text (one line)
|
|
215
|
+
box.lblDesc = Label({ left: 0, top: "50%", width: "100%", ..._s.desc, ellipsis: 1 });
|
|
216
|
+
box.lblDesc.css = { transform: getMiddleTransform(_s.layout.textShift) };
|
|
217
|
+
|
|
218
|
+
endBox();
|
|
219
|
+
|
|
220
|
+
// GROUP: The objects of control() (createControl)
|
|
221
|
+
box.controlGroup = HGroup({ width: "auto", height: "100%", align: "right center", gap: _s.layout.gap });
|
|
222
|
+
endGroup();
|
|
223
|
+
|
|
224
|
+
// ICON: Arrow
|
|
225
|
+
if (box.arrow == 1) {
|
|
226
|
+
box.icoArrow = Icon({ width: _s.arrow.size, height: _s.arrow.size, alt: "" });
|
|
227
|
+
box.icoArrow.load(SettingsRow.toSvgFile(SettingsRow.drawChevron(_s.arrow.color)));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
endGroup();
|
|
231
|
+
|
|
232
|
+
// *** OBJECT INIT CODE:
|
|
233
|
+
|
|
234
|
+
createControl();
|
|
235
|
+
// WHY after its objects: an object made in a hidden group is not a flex item
|
|
236
|
+
box.controlGroup.visible = (box.controlGroup.children.length > 0) ? 1 : 0;
|
|
237
|
+
|
|
238
|
+
if (isClickable) makeClickable();
|
|
239
|
+
|
|
240
|
+
box.setTitleText(box.titleText);
|
|
241
|
+
showTexts();
|
|
242
|
+
applyMotion();
|
|
243
|
+
|
|
244
|
+
return endObject(box);
|
|
245
|
+
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// *** STATIC VARIABLES AND FUNCTIONS:
|
|
249
|
+
|
|
250
|
+
// "" for null / undefined, else the value as a text
|
|
251
|
+
SettingsRow.toText = function (value) {
|
|
252
|
+
return (value === null || value === undefined) ? "" : String(value);
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
// An SVG text as a file for an Icon (a data URI)
|
|
256
|
+
SettingsRow.toSvgFile = function (svg) {
|
|
257
|
+
return "data:image/svg+xml;charset=utf-8," + encodeURIComponent(svg);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// A chevron to the right (24 x 24)
|
|
261
|
+
SettingsRow.drawChevron = function (color) {
|
|
262
|
+
return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="' + color +
|
|
263
|
+
'" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9.6 6l6 6-6 6"/></svg>';
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// THE SECTION: the band between the groups of rows. Its look (params over these; Ex: { color: "white" }):
|
|
267
|
+
SettingsRow.sectionDefaults = {
|
|
268
|
+
width: "100%",
|
|
269
|
+
height: 90,
|
|
270
|
+
color: "whitesmoke",
|
|
271
|
+
style: {
|
|
272
|
+
title: { left: 20, top: 50, fontSize: 18, bold: 1, textColor: Black(0.8) },
|
|
273
|
+
line: { width: 3, color: Black(0.1) },
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// Returns the band (band.lblTitle is its title).
|
|
278
|
+
SettingsRow.createSection = function (titleText, params = {}) {
|
|
279
|
+
|
|
280
|
+
// WHY a new object: the params of the page and sectionDefaults are not changed by the merge
|
|
281
|
+
const sectionParams = { titleText: titleText };
|
|
282
|
+
mergeIntoIfMissing(sectionParams, params);
|
|
283
|
+
mergeIntoIfMissing(sectionParams, SettingsRow.sectionDefaults);
|
|
284
|
+
|
|
285
|
+
// BOX: Band
|
|
286
|
+
const section = startObject(sectionParams);
|
|
287
|
+
section.shrink = 0; // WHY: in a group with a fixed height the band keeps its height
|
|
288
|
+
const _s = section.style;
|
|
289
|
+
section.css = { borderBottom: _s.line.width + "px solid " + _s.line.color };
|
|
290
|
+
|
|
291
|
+
// LABEL: Title
|
|
292
|
+
section.lblTitle = Label({ ..._s.title, plainText: section.titleText });
|
|
293
|
+
section.lblTitle.role = "heading";
|
|
294
|
+
section.lblTitle.aria = { level: 2 };
|
|
295
|
+
|
|
296
|
+
return endObject(section);
|
|
297
|
+
|
|
298
|
+
};
|
|
299
|
+
// USAGE: SettingsRow.createSection("APPEARANCE")
|