Skip to content

Commit

Permalink
feature: configurable artworkMinHeight
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Mar 11, 2024
1 parent 37cba92 commit 4515c91
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ showAudioInputFormat: true # default is false. Will show the audio input format
fallbackArtwork: https://cdn-icons-png.flaticon.com/512/651/651717.png # Override default fallback artwork image if artwork is missing for the currently selected media.
entitiesToIgnoreVolumeLevelFor: # default is empty. Use this if you want to ignore volume level for certain players in the player section. Useful if you have a main device with fixed volume.
- media_player.my_sonos_port_device
artworkMinHeight: 10 # default is 5. Use this to change the minimum height of the artwork in the player section. Unit is in rem.

# media browser specific
mediaBrowserItemsPerRow: 1 # default is 4. Use this to show items as list.
Expand Down
8 changes: 8 additions & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export const ADVANCED_SCHEMA = [
valueMin: 1,
valueMax: 100,
},
{
type: 'integer',
name: 'artworkMinHeight',
help: 'Minimum height of the artwork in rem',
default: 5,
required: true,
valueMin: 0,
},
{
name: 'hideBrowseMediaButton',
selector: { boolean: {} },
Expand Down
9 changes: 7 additions & 2 deletions src/sections/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ export class Player extends LitElement {
return html`
<div class="container">
<sonos-player-header class="header" .store=${this.store}></sonos-player-header>
<div class="artwork" style=${this.getBackgroundImage()}></div>
<div class="artwork" style=${this.artworkStyle()}></div>
<sonos-player-controls class="controls" .store=${this.store}></sonos-player-controls>
</div>
`;
}

private artworkStyle() {
const minHeight = this.config.artworkMinHeight ?? 5;
return `${this.getBackgroundImage()}; min-height: ${minHeight}rem`;
}

private getBackgroundImage() {
const fallbackImage =
this.config.fallbackArtwork ??
Expand Down Expand Up @@ -105,7 +110,7 @@ export class Player extends LitElement {
flex-shrink: 0;
width: 100%;
height: 100%;
min-height: 10rem;
min-height: 5rem;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface CardConfig extends LovelaceCardConfig {
hideVolumeCogwheel?: boolean;
dynamicVolumeSliderThreshold?: number;
dynamicVolumeSliderMax?: number;
artworkMinHeight?: number;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit 4515c91

Please sign in to comment.