From 8972cf937864280e5f918aea42f470842cdd428f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 8 Jul 2020 16:09:45 -0600 Subject: [PATCH] Potential solution to supporting transparent 'show more' buttons In this demonstration, we remove the cutting line (as it collides with the tile in a weird spot) and instead replace the tile with a placeholder when the text is about to collide with the avatar in the tile. We use a `round()` for this because through some amazing coincidence the collision happens at 0.47, which is close enough to 0.5 for people not to notice. --- res/css/views/rooms/_RoomSublist2.scss | 20 +++++--------------- src/components/views/rooms/RoomSublist2.tsx | 10 ++++++++-- src/stores/room-list/ListLayout.ts | 4 ---- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/res/css/views/rooms/_RoomSublist2.scss b/res/css/views/rooms/_RoomSublist2.scss index 30389a4ec5..f64e3c1842 100644 --- a/res/css/views/rooms/_RoomSublist2.scss +++ b/res/css/views/rooms/_RoomSublist2.scss @@ -187,16 +187,16 @@ limitations under the License. flex-direction: column; overflow: hidden; + .mx_RoomSublist2_placeholder { + height: 44px; // Height of a room tile plus margins + } + .mx_RoomSublist2_showNButton { cursor: pointer; font-size: $font-13px; line-height: $font-18px; color: $roomtile2-preview-color; - // This is the same color as the left panel background because it needs - // to occlude the lastmost tile in the list. - background-color: $roomlist2-bg-color; - // Update the render() function for RoomSublist2 if these change // Update the ListLayout class for minVisibleTiles if these change. // @@ -209,7 +209,7 @@ limitations under the License. // We force this to the bottom so it will overlap rooms as needed. // We account for the space it takes up (24px) in the code through padding. position: absolute; - bottom: 0; // the height of the resize handle + bottom: 0; left: 0; right: 0; @@ -236,16 +236,6 @@ limitations under the License. .mx_RoomSublist2_showLessButtonChevron { mask-image: url('$(res)/img/feather-customised/chevron-up.svg'); } - - &.mx_RoomSublist2_isCutting::before { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - height: 4px; - box-shadow: 0px -2px 3px rgba(46, 47, 50, 0.08); - } } // Class name comes from the ResizableBox component diff --git a/src/components/views/rooms/RoomSublist2.tsx b/src/components/views/rooms/RoomSublist2.tsx index 732585d3ac..d6ff77b400 100644 --- a/src/components/views/rooms/RoomSublist2.tsx +++ b/src/components/views/rooms/RoomSublist2.tsx @@ -560,10 +560,8 @@ export default class RoomSublist2 extends React.Component { if (visibleTiles.length > 0) { const layout = this.props.layout; // to shorten calls - const maxTilesFactored = layout.tilesWithResizerBoxFactor(this.numTiles); const showMoreBtnClasses = classNames({ 'mx_RoomSublist2_showNButton': true, - 'mx_RoomSublist2_isCutting': this.state.isResizing && layout.visibleTiles < maxTilesFactored, }); // If we're hiding rooms, show a 'show more' button to the user. This button @@ -642,6 +640,14 @@ export default class RoomSublist2 extends React.Component { const tilesWithoutPadding = Math.min(relativeTiles, layout.visibleTiles); const tilesPx = layout.calculateTilesToPixelsMin(relativeTiles, tilesWithoutPadding, padding); + // Now that we know our padding constraints, let's find out if we need to chop off the + // last rendered visible tile so it doesn't collide with the 'show more' button + let visibleUnpaddedTiles = Math.round(layout.visibleTiles - layout.pixelsToTiles(padding)); + if (visibleUnpaddedTiles === visibleTiles.length - 1) { + const placeholder =
; + visibleTiles.splice(visibleUnpaddedTiles, 1, placeholder); + } + const dimensions = { height: tilesPx, }; diff --git a/src/stores/room-list/ListLayout.ts b/src/stores/room-list/ListLayout.ts index 99674fe74f..5169c5e4e5 100644 --- a/src/stores/room-list/ListLayout.ts +++ b/src/stores/room-list/ListLayout.ts @@ -109,10 +109,6 @@ export class ListLayout { return this.tilesToPixels(Math.min(maxTiles, n)) + padding; } - public tilesWithResizerBoxFactor(n: number): number { - return n + RESIZER_BOX_FACTOR; - } - public tilesWithPadding(n: number, paddingPx: number): number { return this.pixelsToTiles(this.tilesToPixelsWithPadding(n, paddingPx)); }