Skip to content

Commit ef67bc8

Browse files
fix: allow CardContent to pass through style to Tile component (#487)
* fix: allow CardContent to pass through style to Tile component * fix: handle case if tile is not defined in CardContent
1 parent c91bf92 commit ef67bc8

File tree

1 file changed

+18
-18
lines changed
  • packages/@lightningjs/ui-components/src/components/CardContent

1 file changed

+18
-18
lines changed

packages/@lightningjs/ui-components/src/components/CardContent/CardContent.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export default class CardContent extends Card {
6464
_update() {
6565
this._updateSize();
6666
this._updateTile();
67-
this._updateRadius();
6867
this._updateMetadata();
6968
super._update();
7069
}
@@ -76,6 +75,20 @@ export default class CardContent extends Card {
7675
_updateTile() {
7776
let w = this.style.imageSize.w;
7877
let h = this.style.expandedHeight;
78+
const radius =
79+
Array.isArray(this.style.radius) && this.style.radius.length === 4
80+
? this.style.radius
81+
: Array(4).fill(this.style.radius);
82+
83+
let tileRadius = radius;
84+
85+
if (!this._collapse) {
86+
tileRadius =
87+
this._orientation === 'horizontal'
88+
? [radius[0], 0, 0, radius[3]]
89+
: [radius[0], radius[1], 0, 0];
90+
}
91+
7992
if (this._orientation !== 'horizontal') {
8093
w = this.style.expandedWidth;
8194
h = this.style.imageSize.h;
@@ -93,6 +106,10 @@ export default class CardContent extends Card {
93106
w,
94107
h,
95108
...tile,
109+
style: {
110+
...(tile?.style || {}),
111+
radius: tileRadius
112+
},
96113
persistentMetadata: true,
97114
alpha: this._shouldShowTile ? 1 : 0
98115
});
@@ -133,23 +150,6 @@ export default class CardContent extends Card {
133150
this.h = h;
134151
}
135152

136-
_updateRadius() {
137-
const radius =
138-
Array.isArray(this.style.radius) && this.style.radius.length === 4
139-
? this.style.radius
140-
: Array(4).fill(this.style.radius);
141-
let tileRadius = radius;
142-
143-
if (!this._collapse) {
144-
tileRadius =
145-
this._orientation === 'horizontal'
146-
? [radius[0], 0, 0, radius[3]]
147-
: [radius[0], radius[1], 0, 0];
148-
}
149-
150-
this._Tile.patch({ style: { radius: tileRadius } });
151-
}
152-
153153
_getSrc() {
154154
return (
155155
(this.tile &&

0 commit comments

Comments
 (0)