Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Tile): update conditions to show/hide gradient #457

Merged
merged 5 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions packages/@lightningjs/ui-components/src/components/Tile/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ export default class Tile extends Surface {
get _gradient() {
if (this._isCircleLayout) return false;
return Boolean(
this._isInsetMetadata && this._hasMetadata && this._shouldShowMetadata
(this._isInsetMetadata &&
this._hasMetadata &&
this._shouldShowMetadata) ||
this.progressBar?.progress > 0 ||
this._shouldShowLogo
);
}

Expand Down Expand Up @@ -192,29 +196,28 @@ export default class Tile extends Surface {
/* ------------------------------ Logo ------------------------------ */

_updateLogo() {
if (!this.logo) {
this.patch({ Logo: undefined });
return;
}
const logoObject = {
w: this.style.logoWidth,
h: this.style.logoHeight,
icon: this.logo,
alpha: this.style.alpha,
alpha: this._shouldShowLogo ? this.style.alpha : 0.001,
x: this.style.paddingX,
y: this._calculateLogoYPosition()
};

if (this.logo && (this.persistentMetadata || this._isFocusedMode)) {
if (!this._Logo) {
this.patch({
Logo: {
type: Icon,
mountY: 1,
...logoObject
}
});
} else {
this.applySmooth(this._Logo, logoObject);
}
if (!this._Logo) {
this.patch({
Logo: {
type: Icon,
mountY: 1,
...logoObject
}
});
} else {
this.patch({ Logo: undefined });
this.applySmooth(this._Logo, logoObject);
}
}

Expand All @@ -226,6 +229,11 @@ export default class Tile extends Surface {
? this._progressBarY - this.style.paddingYBetweenContent
: this._h - this.style.paddingY;
}

get _shouldShowLogo() {
return this.logo && (this.persistentMetadata || this._isFocusedMode);
}

/* ------------------------------ Artwork ------------------------------ */

_updateArtwork() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Tile.argTypes = {
},
logo: {
control: 'select',
options: [xfinityLogo, 'null'],
options: [xfinityLogo, null],
description: 'Icon source',
table: {
defaultValue: { summary: 'undefined' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ describe('Tile', () => {
progress: 0.5
};
await tile.__updateSpyPromise;
expect(tile._gradient).toBe(false);
expect(tile._gradient).toBe(true);
tile.progressBar = {
progress: 0
};
Expand Down
Loading