Skip to content

Commit

Permalink
feature: make it possible to hide the browse media button
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Dec 17, 2023
1 parent 9b89f97 commit c31016f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ topFavorites: # Show these favorites at the top of the list
- Country Rocks
- Kacey Musgraves Radio
numberOfFavoritesToShow: 10 # Use this to limit the amount of favorites to show
hideBrowseMediaButton: true # default is false. Hides the button to open the media browser.
```

## Using individual section cards
Expand Down
8 changes: 6 additions & 2 deletions src/components/media-browser-header.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { css, html, LitElement } from 'lit';
import { css, html, LitElement, nothing } from 'lit';
import { property } from 'lit/decorators.js';
import { MediaPlayerEntityFeature } from '../types';
import Store from '../model/store';

class MediaBrowserHeader extends LitElement {
@property({attribute: false}) store!: Store;
@property({ attribute: false }) store!: Store;

render() {
return html`
<div class="title">All Favorites</div>
<sonos-ha-player
hide=${this.store.config.hideBrowseMediaButton || nothing}
.store=${this.store}
.features=${[MediaPlayerEntityFeature.BROWSE_MEDIA]}
class="browse"
Expand All @@ -35,6 +36,9 @@ class MediaBrowserHeader extends LitElement {
.browse {
margin: 0.5rem;
}
*[hide] {
display: none;
}
`;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const ADVANCED_SCHEMA = [
name: 'dynamicVolumeSlider',
selector: { boolean: {} },
},
{
name: 'hideBrowseMediaButton',
selector: { boolean: {} },
},

{
type: 'string',
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface CardConfig extends LovelaceCardConfig {
mediaBrowserShowTitleForThumbnailIcons?: boolean;
topFavorites?: string[];
numberOfFavoritesToShow?: number;
hideBrowseMediaButton?: boolean;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit c31016f

Please sign in to comment.