Skip to content

Commit

Permalink
webui: apply pure-menu-selected style after menu item click
Browse files Browse the repository at this point in the history
- distinguish heading and selected menu item, apply menu item
  background color after panel item is selected
  for now, both heading and :first-child use a different color
- add x3 transition time to stall animation from hover & focus
  otherwise, background colors may linger between clicks
  • Loading branch information
mcspr committed Aug 9, 2024
1 parent bd1f734 commit 5f500ff
Show file tree
Hide file tree
Showing 14 changed files with 16,606 additions and 16,525 deletions.
5,047 changes: 2,526 additions & 2,521 deletions code/espurna/static/index.all.html.gz.h

Large diffs are not rendered by default.

3,131 changes: 1,568 additions & 1,563 deletions code/espurna/static/index.curtain.html.gz.h

Large diffs are not rendered by default.

3,071 changes: 1,538 additions & 1,533 deletions code/espurna/static/index.garland.html.gz.h

Large diffs are not rendered by default.

3,631 changes: 1,818 additions & 1,813 deletions code/espurna/static/index.light.html.gz.h

Large diffs are not rendered by default.

3,076 changes: 1,540 additions & 1,536 deletions code/espurna/static/index.lightfox.html.gz.h

Large diffs are not rendered by default.

3,137 changes: 1,571 additions & 1,566 deletions code/espurna/static/index.rfbridge.html.gz.h

Large diffs are not rendered by default.

3,141 changes: 1,573 additions & 1,568 deletions code/espurna/static/index.rfm69.html.gz.h

Large diffs are not rendered by default.

3,364 changes: 1,684 additions & 1,680 deletions code/espurna/static/index.sensor.html.gz.h

Large diffs are not rendered by default.

2,373 changes: 1,189 additions & 1,184 deletions code/espurna/static/index.small.html.gz.h

Large diffs are not rendered by default.

3,108 changes: 1,556 additions & 1,552 deletions code/espurna/static/index.thermostat.html.gz.h

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions code/html/src/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,33 @@ export function onPanelTargetClick(event) {
if (name) {
showPanelByName(name);
}

panelTargetShowSelected(target);
}

/**
* @param {HTMLElement} elem
*/
function panelTargetShowSelected(elem) {
const root = elem.closest("#menu");
if (!root) {
return;
}

const parent = elem.parentElement;
if (!parent) {
return;
}

parent.classList.add("pure-menu-selected");

/** @type {NodeListOf<HTMLAnchorElement>} */
(root.querySelectorAll("#menu a[data-panel]"))
.forEach((a) => {
if (a.parentElement && a.parentElement !== parent) {
a.parentElement.classList.remove("pure-menu-selected");
}
});
}

/**
Expand Down
16 changes: 12 additions & 4 deletions code/html/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@
display: none;
}

#menu .pure-menu-heading {
#menu .pure-menu-item.pure-menu-item:first-child {
font-size: 100%;
padding: .5em .5em;
white-space: normal;
text-transform: initial;
font-weight: 250;
text-transform: uppercase;
background: #333;
}

#menu .pure-menu-item.pure-menu-selected.pure-menu-item:first-child {
background: #1f8dd6;
}

#menu .pure-menu-selected a {
transition: all ease 0.6s;
}

.pure-g {
Expand Down
6 changes: 3 additions & 3 deletions code/html/src/menu-list.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ul class="pure-menu-list">
<li class="pure-menu-item">
<a href="#" class="pure-menu-link pure-menu-selected" data-panel="status">STATUS</a>
<li class="pure-menu-item pure-menu-selected">
<a href="#" class="pure-menu-link pure-menu-heading" data-panel="status">STATUS</a>
</li>
<li class="pure-menu-item">
<li class="pure-menu-item menu-item-divided">
<a href="#" class="pure-menu-link" data-panel="general">GENERAL</a>
</li>
<li class="pure-menu-item module module-curtain">
Expand Down
3 changes: 1 addition & 2 deletions code/html/vendor/side-menu-layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ appears on the left side of the page.
/*
This styles the selected menu item `<li>` and the top item.
*/
#menu .pure-menu-selected,
#menu .pure-menu-heading {
#menu .pure-menu-selected {
background: #1f8dd6;
}
/*
Expand Down

0 comments on commit 5f500ff

Please sign in to comment.