Skip to content

Commit

Permalink
Merge pull request #16 from Villhellm/title-change-option
Browse files Browse the repository at this point in the history
added title change option
  • Loading branch information
Villhellm authored Sep 8, 2020
2 parents 1604b4a + 8b646f0 commit 4dc5242
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ order:
bottom: true
```

## Title
| Name | Type | Requirement | Description
| ---- | ---- | ------- | -----------
| title | string | **Optional** | Change the default title over the sidebar

## Order

| Name | Type | Requirement | Description
Expand Down Expand Up @@ -120,8 +125,10 @@ Exceptions can be used if you would like to define an order for a specific user/
| not_device | string, list | **Optional** | Every device *except* this device. ex: ipad, iphone, macintosh, windows, android
| order | [order](#order) | **Required** | Define and order.


Ex sidebar-order.yaml using exceptions:
```yaml
title: Hass
order:
- item: map
hide: true
Expand Down
11 changes: 11 additions & 0 deletions dist/custom-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ var Hacky_Hackerson = setInterval(run, 1000 / 60);
var Loaded = false;
var Haobj = null;
var Root = null;
var TitleElement = null;

function Current_Order(config) {
var return_order = null;
if (config) {
if(config.title){
setTitle(config.title);
}
if (config.order) {
return_order = config.order;
}
Expand Down Expand Up @@ -113,6 +117,12 @@ function rearrange(order) {
}
}

function setTitle(title){
if(TitleElement){
TitleElement.innerHTML = title;
}
}

function run() {
Root = getSidebar();
if (Root && !Loaded) {
Expand Down Expand Up @@ -141,6 +151,7 @@ function getSidebar() {
root = root && root.querySelector("app-drawer-layout app-drawer");
root = root && root.querySelector("ha-sidebar");
root = root && root.shadowRoot;
TitleElement = root.querySelector('span');
root = root && root.querySelector("paper-listbox");
return root;
}
Expand Down

0 comments on commit 4dc5242

Please sign in to comment.