Skip to content

Commit 78e03f3

Browse files
committed
UI fixes
1 parent 93922b4 commit 78e03f3

23 files changed

+301
-232
lines changed

.stylelintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"selector-max-compound-selectors": 4,
2020
"selector-no-qualifying-type": [true, { "ignore": ["class", "attribute"] } ],
2121
"selector-class-pattern": "[a-zA-Z]*",
22-
"at-rule-allowed-list": ["use", "media", "import"],
22+
"at-rule-allowed-list": ["use", "media", "import", "container"],
2323
"at-rule-no-unknown": null,
2424
"custom-property-empty-line-before": null,
2525
"no-descending-specificity": null,

board.htm

+7-17
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ <h3>Scenes</h3>
323323
var ret;
324324
if (!document.querySelector('dialog#addElement')) {
325325
// lazy load dialogs.
326-
ret = fetch("./board-new.htm")
327-
.then(res => res.text())
326+
ret = fetchText("./board-new.htm")
328327
.then(txt => {
329328
document.body.appendChild(document.createRange().createContextualFragment(txt));
330329
document.querySelectorAll('[u-is]').forEach(el => micro.attach(el));
@@ -365,22 +364,13 @@ <h3>Scenes</h3>
365364
timer = window.setTimeout(updateStateNow, 200);
366365
};
367366

368-
369-
// initiate a fetch with JSON res expected.
370-
async function fetchJSON(url, options) {
371-
var p = fetch(url, options)
372-
.then(raw => raw.json());
373-
return (p);
374-
}
375-
376-
// load templates from other file.
377-
var p2 = fetchJSON('/elements.json').then(json => uElements.defs = json);
378-
var p3 = fetchJSON('/env.json').then(json => uElements.env = json);
379-
var p4 = fetchJSON('/config.json').then(json => uElements.config = json);
380-
var pState = fetchJSON('/api/state').then(json => uElements.state = json);
381-
382-
383367
function loaded() {
368+
// load templates from other file.
369+
var p2 = fetchJSON('/elements.json').then(json => uElements.defs = json);
370+
var p3 = fetchJSON('/env.json').then(json => uElements.env = json);
371+
var p4 = fetchJSON('/config.json').then(json => uElements.config = json);
372+
var pState = fetchJSON('/api/state').then(json => uElements.state = json);
373+
384374
params = getHashParams({ sys: false });
385375
var p0 = micro.loadFile('/board-templates.htm');
386376

css/iot.scss

+25-30
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@
1010

1111
@use "sass:color";
1212

13-
// ===== panel grid Layout =====
14-
15-
$u-grid-width: 11.5rem;
16-
$u-grid-gap: $u-gutter;
17-
18-
$u-card-width: 2 * $u-grid-width + $u-gutter;
19-
$u-card-wide-width: calc(4 * $u-grid-width + 3 * $u-gutter);
2013

2114
// ===== Cards layout =====
2215

16+
:root {
17+
--grid-width: 20ch;
18+
--grid-gap: 1ch;
19+
}
20+
2321
.card {
2422
position: relative;
2523
display: flex;
@@ -110,46 +108,43 @@ $u-card-wide-width: calc(4 * $u-grid-width + 3 * $u-gutter);
110108

111109
// ===== Dashboard of cards =====
112110

111+
112+
body {
113+
container-type: size;
114+
}
115+
113116
.panel {
114117
display: grid;
115-
gap: $u-grid-gap;
116-
grid-template-columns: repeat(auto-fill, $u-grid-width);
118+
gap: var(--grid-gap);
119+
grid-template-columns: repeat(auto-fill, var(--grid-width));
117120
grid-auto-rows: minmax(min-content, max-content);
118121
grid-auto-flow: row;
119122
margin-top: 0.5rem;
123+
margin-left: auto;
124+
margin-right: auto;
125+
width: calc(2 * var(--grid-width) + var(--grid-gap));
126+
127+
@container (width >= 84ch) {
128+
width: calc(4 * var(--grid-width) + 3 * var(--grid-gap));
129+
}
130+
131+
@container (width >= 126ch) {
132+
width: calc(6 * var(--grid-width) + 5 * var(--grid-gap));
133+
}
120134

121135
>.card {
122136
grid-column: span 2;
123-
width: $u-card-width;
124-
min-width: $u-card-width;
137+
width: 100%;
138+
min-width: 100%;
125139
align-self: start;
126140
}
127141

128142
>.card.small {
129143
grid-column: span 1;
130-
width: $u-grid-width;
131-
min-width: $u-grid-width;
132144
}
133145

134146
>.card.wide {
135147
grid-column: span 4;
136-
width: $u-card-wide-width;
137-
min-width: $u-card-wide-width;
138-
}
139-
140-
@media (width >=0) {
141-
/* 1 col */
142-
max-width: $u-card-width;
143-
margin-left: auto;
144-
margin-right: auto;
145-
}
146-
147-
@media (width >=2 * $u-card-width + $u-gutter) {
148-
max-width: 2 * $u-card-width + $u-gutter;
149-
}
150-
151-
@media (width >=3 * $u-card-width + 2 * $u-gutter) {
152-
max-width: 3 * $u-card-width + 2 * $u-gutter;
153148
}
154149
}
155150

ding.htm

+7-15
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,21 @@ <h3>Scenes</h3>
193193
state: {}
194194
}
195195

196-
// initiate a fetch with JSON res expected.
197-
async function fetchJSON(url, options) {
198-
var p = fetch(url, options)
199-
.then(raw => raw.json());
200-
return (p)
201-
}
202-
203196
function updateState() {
204197
fetchJSON('/api/state')
205198
.then(json => hub.publishObj(json))
206199
.finally(() => timer = window.setTimeout(updateState, REFRESH_INTERVAL));
207200
} // updateState()
208201
window.updateState = updateState;
209202

210-
// fetch element definitions from env.json and config.json asap
211-
var p3 = fetchJSON('/env.json').then(json => uElements.env = json);
212-
var p4 = fetchJSON('/config.json').then(json => uElements.config = json);
213-
var pState = fetchJSON('/api/state').then(json => uElements.state = json);
214-
215203
function loaded() {
204+
// fetch element definitions from env.json and config.json asap
205+
var p3 = fetchJSON('/env.json').then(json => uElements.env = json);
206+
var p4 = fetchJSON('/config.json').then(json => uElements.config = json);
207+
var pState = fetchJSON('/api/state').then(json => uElements.state = json);
216208

217209
// create new card
218-
hub.subscribe('/*/*', function (path) {
210+
hub.subscribe('/*/*', function(path) {
219211
// console.log("ev:", path);
220212
if (path) {
221213
path = path.toLowerCase();
@@ -244,12 +236,12 @@ <h3>Scenes</h3>
244236
document.querySelector("h1").textContent = _title;
245237
}
246238

247-
hub.subscribe('/device/*?name', function (path, key, value) {
239+
hub.subscribe('/device/*?name', function(path, key, value) {
248240
_name = value;
249241
setTitle();
250242
});
251243

252-
hub.subscribe('/device/*?title', function (path, key, value) {
244+
hub.subscribe('/device/*?title', function(path, key, value) {
253245
_title = value;
254246
setTitle();
255247
});

i/default.svg

+1-1
Loading

i/water.svg

+3
Loading

icons.svg

+2-1
Loading

index.htm

+3-12
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,7 @@ <h3>Diag</h3>
156156

157157
window.addEventListener('load', function () {
158158
memAPI = memObj.getSVGDocument().api;
159-
fetch('/api/sysinfo')
160-
.then(function (result) {
161-
return result.json();
162-
})
159+
fetchJSON('/api/sysinfo')
163160
.then(function (d) {
164161
var o = document.getElementById('sysinfo');
165162
o.innerText = JSON.stringify(d, null, 1)
@@ -185,10 +182,7 @@ <h3>Diag</h3>
185182
]);
186183
});
187184

188-
fetch('/api/state')
189-
.then(function (result) {
190-
return result.json();
191-
})
185+
fetchJSON('/api/state')
192186
.then(function (d) {
193187
var o = document.querySelector('#stateInfo');
194188
o.innerText = JSON.stringify(d, null, 1)
@@ -198,10 +192,7 @@ <h3>Diag</h3>
198192

199193
});
200194

201-
fetch('/api/elements')
202-
.then(function (result) {
203-
return result.json();
204-
})
195+
fetchJSON('/api/elements')
205196
.then(function (d) {
206197
var o = document.querySelector('#elementsInfo');
207198
o.innerText = d.join(', ');

iotstyle.css

+26-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)