Skip to content

Commit

Permalink
Layout tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gadgetchnnel committed Mar 7, 2022
1 parent 7f170aa commit 2051ee3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion dist/lovelace-header-cards.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 30 additions & 24 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,28 @@ class HeaderCards {
let oldBadges = this.toolbar.querySelector("#headerBadges");
if(oldBadges) oldBadges.remove();

if(cards.length > 0 || badges.length > 0){
if(cards.length > 0 || badges.length > 0){
let outerDiv = document.createElement("div");
outerDiv.style.display = "flex";
outerDiv.style["-ms-flex-direction"] = "row";
outerDiv.style["-webkit-flex-direction"] = "row";
outerDiv.style["flex-direction"] = "row";
outerDiv.style["-ms-flex-align"] = "center";
outerDiv.style["-webkit-align-items"] = "center";
outerDiv.style["align-items"] = "center";

if(badges.length > 0){
let div = document.createElement("div");
div.id = "headerBadges";
div.style.width = "auto";
div.style.minWidth = "max-content";
badges.forEach(badgeConfig => {
this.addBadge(badgeConfig, div);
});

outerDiv.appendChild(div);
}

if(cards.length > 0){
let div = document.createElement("div");
div.id = "headerCards";
Expand All @@ -187,35 +208,20 @@ class HeaderCards {
cards.forEach(cardConfig => {
this.addCardWhenDefined(cardConfig, div);
});
div.style.marginRight = "auto";
if(button) {
this.toolbar.insertBefore(div, button);
}
else{
this.toolbar.appendChild(div);
}

outerDiv.appendChild(div);
}

if(badges.length > 0){
let div = document.createElement("div");
div.id = "headerBadges";
div.style.width = "auto";
div.style.minWidth = "max-content";
badges.forEach(badgeConfig => {
this.addBadge(badgeConfig, div);
});
if(cards.length == 0) div.style.marginRight = "auto";
if(button) {
this.toolbar.insertBefore(div, button);
}
else{
this.toolbar.appendChild(div);
}
if(button) {
this.toolbar.insertBefore(outerDiv, button);
}
else{
this.toolbar.appendChild(outerDiv);
}

if(tabs && replaceTabs){
tabs.style.display = "none";
}
}
}
});
}
Expand Down

0 comments on commit 2051ee3

Please sign in to comment.