Merge pull request #4765 from matrix-org/travis/room-list/show-less
Add a 'show less' button to the new room list
This commit is contained in:
commit
58671f014b
3 changed files with 43 additions and 13 deletions
|
@ -176,7 +176,7 @@ limitations under the License.
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.mx_RoomSublist2_showMoreButton {
|
.mx_RoomSublist2_showNButton {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: $font-13px;
|
font-size: $font-13px;
|
||||||
line-height: $font-18px;
|
line-height: $font-18px;
|
||||||
|
@ -205,18 +205,25 @@ limitations under the License.
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.mx_RoomSublist2_showMoreButtonChevron {
|
.mx_RoomSublist2_showNButtonChevron {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
margin-left: 12px;
|
margin-left: 12px;
|
||||||
margin-right: 18px;
|
margin-right: 18px;
|
||||||
mask-image: url('$(res)/img/feather-customised/chevron-down.svg');
|
|
||||||
mask-position: center;
|
mask-position: center;
|
||||||
mask-size: contain;
|
mask-size: contain;
|
||||||
mask-repeat: no-repeat;
|
mask-repeat: no-repeat;
|
||||||
background: $roomtile2-preview-color;
|
background: $roomtile2-preview-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_RoomSublist2_showMoreButtonChevron {
|
||||||
|
mask-image: url('$(res)/img/feather-customised/chevron-down.svg');
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_RoomSublist2_showLessButtonChevron {
|
||||||
|
mask-image: url('$(res)/img/feather-customised/chevron-up.svg');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class name comes from the ResizableBox component
|
// Class name comes from the ResizableBox component
|
||||||
|
@ -326,10 +333,10 @@ limitations under the License.
|
||||||
.mx_RoomSublist2_resizeBox {
|
.mx_RoomSublist2_resizeBox {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
.mx_RoomSublist2_showMoreButton {
|
.mx_RoomSublist2_showNButton {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
.mx_RoomSublist2_showMoreButtonChevron {
|
.mx_RoomSublist2_showNButtonChevron {
|
||||||
margin-right: 12px; // to center
|
margin-right: 12px; // to center
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
res/img/feather-customised/chevron-up.svg
Normal file
1
res/img/feather-customised/chevron-up.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-up"><polyline points="18 15 12 9 6 15"></polyline></svg>
|
After Width: | Height: | Size: 268 B |
|
@ -109,6 +109,11 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
||||||
this.forceUpdate(); // because the layout doesn't trigger a re-render
|
this.forceUpdate(); // because the layout doesn't trigger a re-render
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onShowLessClick = () => {
|
||||||
|
this.props.layout.visibleTiles = this.props.layout.minVisibleTiles;
|
||||||
|
this.forceUpdate(); // because the layout doesn't trigger a re-render
|
||||||
|
};
|
||||||
|
|
||||||
private onOpenMenuClick = (ev: InputEvent) => {
|
private onOpenMenuClick = (ev: InputEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -334,25 +339,42 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
||||||
const visibleTiles = tiles.slice(0, nVisible);
|
const visibleTiles = tiles.slice(0, nVisible);
|
||||||
|
|
||||||
// If we're hiding rooms, show a 'show more' button to the user. This button
|
// If we're hiding rooms, show a 'show more' button to the user. This button
|
||||||
// floats above the resize handle, if we have one present
|
// floats above the resize handle, if we have one present. If the user has all
|
||||||
let showMoreButton = null;
|
// tiles visible, it becomes 'show less'.
|
||||||
|
let showNButton = null;
|
||||||
if (tiles.length > nVisible) {
|
if (tiles.length > nVisible) {
|
||||||
// we have a cutoff condition - add the button to show all
|
// we have a cutoff condition - add the button to show all
|
||||||
const numMissing = tiles.length - visibleTiles.length;
|
const numMissing = tiles.length - visibleTiles.length;
|
||||||
let showMoreText = (
|
let showMoreText = (
|
||||||
<span className='mx_RoomSublist2_showMoreButtonText'>
|
<span className='mx_RoomSublist2_showNButtonText'>
|
||||||
{_t("Show %(count)s more", {count: numMissing})}
|
{_t("Show %(count)s more", {count: numMissing})}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
if (this.props.isMinimized) showMoreText = null;
|
if (this.props.isMinimized) showMoreText = null;
|
||||||
showMoreButton = (
|
showNButton = (
|
||||||
<div onClick={this.onShowAllClick} className='mx_RoomSublist2_showMoreButton'>
|
<div onClick={this.onShowAllClick} className='mx_RoomSublist2_showNButton'>
|
||||||
<span className='mx_RoomSublist2_showMoreButtonChevron'>
|
<span className='mx_RoomSublist2_showMoreButtonChevron mx_RoomSublist2_showNButtonChevron'>
|
||||||
{/* set by CSS masking */}
|
{/* set by CSS masking */}
|
||||||
</span>
|
</span>
|
||||||
{showMoreText}
|
{showMoreText}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
} else if (tiles.length <= nVisible) {
|
||||||
|
// we have all tiles visible - add a button to show less
|
||||||
|
let showLessText = (
|
||||||
|
<span className='mx_RoomSublist2_showNButtonText'>
|
||||||
|
{_t("Show less")}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
if (this.props.isMinimized) showLessText = null;
|
||||||
|
showNButton = (
|
||||||
|
<div onClick={this.onShowLessClick} className='mx_RoomSublist2_showNButton'>
|
||||||
|
<span className='mx_RoomSublist2_showLessButtonChevron mx_RoomSublist2_showNButtonChevron'>
|
||||||
|
{/* set by CSS masking */}
|
||||||
|
</span>
|
||||||
|
{showLessText}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out if we need a handle
|
// Figure out if we need a handle
|
||||||
|
@ -376,7 +398,7 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
// The padding is variable though, so figure out what we need padding for.
|
// The padding is variable though, so figure out what we need padding for.
|
||||||
let padding = 0;
|
let padding = 0;
|
||||||
if (showMoreButton) padding += showMoreHeight;
|
if (showNButton) padding += showMoreHeight;
|
||||||
if (handles.length > 0) padding += resizeHandleHeight;
|
if (handles.length > 0) padding += resizeHandleHeight;
|
||||||
|
|
||||||
const minTilesPx = layout.calculateTilesToPixelsMin(tiles.length, layout.minVisibleTiles, padding);
|
const minTilesPx = layout.calculateTilesToPixelsMin(tiles.length, layout.minVisibleTiles, padding);
|
||||||
|
@ -396,7 +418,7 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
||||||
className="mx_RoomSublist2_resizeBox"
|
className="mx_RoomSublist2_resizeBox"
|
||||||
>
|
>
|
||||||
{visibleTiles}
|
{visibleTiles}
|
||||||
{showMoreButton}
|
{showNButton}
|
||||||
</ResizableBox>
|
</ResizableBox>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue