Add hover states and basic context menu to new room list

The 'sort by' radio buttons are blocked by https://github.com/matrix-org/matrix-react-sdk/pull/4731 as it contains the styles needed.

The 'unread rooms' checkbox is intentionally not hooked up. This is a more complicated refactoring that needs to be done.

The message preview checkbox works, though the previews remain hardcoded in this change. The primary intent of this change is to have a good enough context menu and the hover states.

The hover states are as described in the design.
This commit is contained in:
Travis Ralston 2020-06-09 21:12:49 -06:00
parent 7549d7d98a
commit 111394df6d
6 changed files with 234 additions and 18 deletions

View file

@ -20,10 +20,12 @@ const TILE_HEIGHT_PX = 44;
interface ISerializedListLayout {
numTiles: number;
showPreviews: boolean;
}
export class ListLayout {
private _n = 0;
private _previews = false;
constructor(public readonly tagId: TagID) {
const serialized = localStorage.getItem(this.key);
@ -31,9 +33,19 @@ export class ListLayout {
// We don't use the setters as they cause writes.
const parsed = <ISerializedListLayout>JSON.parse(serialized);
this._n = parsed.numTiles;
this._previews = parsed.showPreviews;
}
}
public get showPreviews(): boolean {
return this._previews;
}
public set showPreviews(v: boolean) {
this._previews = v;
this.save();
}
public get tileHeight(): number {
return TILE_HEIGHT_PX;
}
@ -48,7 +60,7 @@ export class ListLayout {
public set visibleTiles(v: number) {
this._n = v;
localStorage.setItem(this.key, JSON.stringify(this.serialize()));
this.save();
}
public get minVisibleTiles(): number {
@ -63,9 +75,14 @@ export class ListLayout {
return px / this.tileHeight;
}
private save() {
localStorage.setItem(this.key, JSON.stringify(this.serialize()));
}
private serialize(): ISerializedListLayout {
return {
numTiles: this.visibleTiles,
showPreviews: this.showPreviews,
};
}
}