Skip to content

Commit

Permalink
feature: make it possible to set footer height
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Nov 30, 2024
1 parent 5d9f73c commit c63439d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ sections: # see explanation further up
startSection: queue # default is player. Use this to set the default section to show.
widthPercentage: 75 # default is 100. Use this to change the width of the card.
heightPercentage: 75 # default is 100. Use this to change the height of the card. Set to 'auto' to make the card height adjust to the content.
footerHeight: 4 # default is 5. Unit is 'rem'. Use this to change the height of the footer.
entityId: media_player.bedroom # Forces this player to be the selected one on loading the card (overrides url param etc)
entityNameRegexToReplace: ' PLAYER' # Regex pattern to replace parts of the entity names
entityNameReplacement: ''
Expand Down
9 changes: 5 additions & 4 deletions src/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export class Card extends LitElement {
let height = getHeight(this.config);
const sections = this.config.sections;
const showFooter = !sections || sections.length > 1;
const contentHeight = showFooter ? height - FOOTER_HEIGHT : height;
const footerHeight = this.config.footerHeight || FOOTER_HEIGHT;
const contentHeight = showFooter ? height - footerHeight : height;
const title = this.config.title;
height = title ? height + TITLE_HEIGHT : height;
return html`
Expand Down Expand Up @@ -84,7 +85,7 @@ export class Card extends LitElement {
showFooter,
() =>
html`<sonos-footer
style=${this.footerStyle()}
style=${this.footerStyle(footerHeight)}
.config=${this.config}
.section=${this.section}
@show-section=${this.showSectionListener}
Expand Down Expand Up @@ -183,9 +184,9 @@ export class Card extends LitElement {
});
}

footerStyle() {
footerStyle(height: number) {
return styleMap({
height: `${FOOTER_HEIGHT}rem`,
height: `${height}rem`,
padding: '0 1rem',
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Footer extends LitElement {
justify-content: space-between;
}
:host > * {
padding: 1rem 0;
align-content: center;
}
`;
}
Expand Down
5 changes: 5 additions & 0 deletions src/editor/advanced-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ export const ADVANCED_SCHEMA = [
type: 'string',
name: 'mediaTitleReplacement',
},
{
name: 'footerHeight',
type: 'integer',
valueMin: 0,
},
];

class AdvancedEditor extends BaseEditor {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface CardConfig extends LovelaceCardConfig {
fastForwardAndRewindStepSizeSeconds?: number;
groupingButtonIcons?: GroupingButtonIcons;
sectionButtonIcons?: SectionButtonIcons;
footerHeight?: number;
}

export interface MediaArtworkOverride {
Expand Down

0 comments on commit c63439d

Please sign in to comment.