Skip to content

Commit 2831ae9

Browse files
authored
[Feature Request] Allow to make an display order of module position in config (#3762)
My proposal for #3761 * I use `flex` box for create region container * I have moved `container` definition to `main.css` (for css tunning, maybe it can be useful) * I create `order` in module config for define module order display from position # Advantage: We don't have to move module config in another place in array of modules # Another advantage that i did'nt think: We can change dynamicaly module order of a container: - So, in this case, for a module config builder, (I won't mention the name because otherwise I'll get angry...) It can be usefull for a config preview (before saving config) --> just change style css `order` module value for see preview - Or, change `order` value in dev console for testing # Disadvantages I don't see any ;)
1 parent 7b4d363 commit 2831ae9

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ planned for 2025-07-01
1313

1414
### Added
1515

16+
- [config] Allow to change module order for final renderer (or dynamicaly with CSS): Feature `order` in config. (#3762)
1617
- [clock] Added option 'disableNextEvent' to hide next sun event (#3769)
1718

1819
### Changed

css/main.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,16 @@ sup {
239239
border-spacing: 0;
240240
border-collapse: separate;
241241
}
242+
243+
/**
244+
* Container Definitions.
245+
*/
246+
247+
.region .container {
248+
display: flex;
249+
flex-direction: column;
250+
}
251+
252+
.region .container.hidden {
253+
display: none;
254+
}

js/loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ const Loader = (function () {
108108
header: moduleData.header,
109109
configDeepMerge: typeof moduleData.configDeepMerge === "boolean" ? moduleData.configDeepMerge : false,
110110
config: moduleData.config,
111-
classes: typeof moduleData.classes !== "undefined" ? `${moduleData.classes} ${module}` : module
111+
classes: typeof moduleData.classes !== "undefined" ? `${moduleData.classes} ${module}` : module,
112+
order: (typeof moduleData.order === "number" && Number.isInteger(moduleData.order)) ? moduleData.order : 0
112113
});
113114
});
114115

js/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const MM = (function () {
3030
dom.className = `module ${dom.className} ${module.data.classes}`;
3131
}
3232

33+
dom.style.order = (typeof module.data.order === "number" && Number.isInteger(module.data.order)) ? module.data.order : 0;
34+
3335
dom.opacity = 0;
3436
wrapper.appendChild(dom);
3537

@@ -463,7 +465,8 @@ const MM = (function () {
463465
}
464466
});
465467

466-
wrapper.style.display = showWrapper ? "block" : "none";
468+
// move container definitions to main CSS
469+
wrapper.className = showWrapper ? "container" : "container hidden";
467470
});
468471
};
469472

0 commit comments

Comments
 (0)