Skip to content

Commit bc3909c

Browse files
authored
Grid refactor (#15)
* Change grid layout * Make grid look better * Fix alignment * Post rebase touch up
1 parent fa34ef9 commit bc3909c

File tree

4 files changed

+40
-35
lines changed

4 files changed

+40
-35
lines changed

src/components/Peer.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import { Icons } from './Icons';
1111
interface IPeer {
1212
peer: HMSPeer;
1313
className: string;
14-
dimension: number;
1514
}
1615

17-
const Peer = ({ peer, className, dimension }: IPeer) => {
16+
const Peer = ({ peer, className }: IPeer) => {
1817
// TODO: Use peer id instead of Peer
1918
const { videoRef } = useVideo({
2019
trackId: peer.videoTrack
@@ -29,7 +28,7 @@ const Peer = ({ peer, className, dimension }: IPeer) => {
2928
};
3029

3130
return (
32-
<div className={'jlab-gather-peer-tile'}>
31+
<div className={`jlab-gather-peer-tile jlab-gather-peer-tile-${className}`}>
3332
{peer.isHandRaised ? (
3433
<Icons.raisedHand className="jlab-gather-peer-hand-raised-icon" />
3534
) : (
@@ -39,12 +38,12 @@ const Peer = ({ peer, className, dimension }: IPeer) => {
3938
<>
4039
<video
4140
ref={videoRef}
42-
className={`${className} ${peer.isHandRaised ? 'jlab-gather-peer-hand-raised' : ''}`}
41+
className={`jlab-gather-peer-video jlab-gather-peer-video-${className}
42+
${peer.isHandRaised ? 'jlab-gather-peer-hand-raised' : ''}
43+
${peer.isLocal ? 'jlab-gather-local' : ''}`}
4344
autoPlay
4445
muted
4546
playsInline
46-
height={dimension}
47-
width={dimension}
4847
/>
4948
<div className="jlab-gather-peer-name">{peer.name}</div>
5049
</>

src/components/PeerSidePane.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ const PeerSidePane = ({ peers }: IPeerSidePane) => {
1010
return (
1111
<div className="jlab-gather-peer-sidepane-list">
1212
{peers.map(peer => (
13-
<Peer
14-
key={peer.id}
15-
peer={peer}
16-
className="jlab-gather-peer-video"
17-
dimension={128}
18-
/>
13+
<Peer key={peer.id} peer={peer} className="sidepane" />
1914
))}
2015
</div>
2116
);

src/layouts/GridView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ const GridView = () => {
1010
<div className="jlab-gather-main-grid-container">
1111
<div className="jlab-gather-main-grid-view">
1212
{peers.map(peer => (
13-
<Peer
14-
key={peer.id}
15-
peer={peer}
16-
className={`jlab-gather-peer-video ${peer.isLocal ? 'jlab-gather-local' : ''}`}
17-
dimension={256}
18-
/>
13+
<Peer key={peer.id} peer={peer} className={'grid'} />
1914
))}
2015
</div>
2116
</div>

style/base.css

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
margin-bottom: 20px;
4141
}
4242

43-
/* Common styles for.jlab-gather-btn-primary and.jlab-gather-btn-danger */
4443
.jlab-gather-btn-common {
4544
padding: 6px 14px;
4645
cursor: pointer;
@@ -50,62 +49,81 @@
5049
font-family: inherit;
5150
}
5251

53-
/* Specific styles for.jlab-gather-btn-primary */
5452
.jlab-gather-btn-primary {
5553
background-color: var(--jp-brand-color1);
5654
color: whitesmoke;
5755
}
5856

59-
/* Specific styles for.jlab-gather-btn-danger */
6057
.jlab-gather-btn-danger {
6158
background-color: var(--jp-warn-color1);
6259
color: black;
6360
}
6461

6562
.jlab-gather-main-grid-container {
66-
width: auto;
6763
padding: 2rem 0;
64+
display: flex;
65+
justify-content: center;
6866
}
6967

7068
.jlab-gather-main-grid-view {
7169
display: flex;
7270
flex-wrap: wrap;
7371
justify-content: center;
7472
gap: 0.2rem;
73+
padding: 0 0.5rem;
7574
}
7675

7776
.jlab-gather-overflow {
7877
overflow-y: auto;
7978
}
8079

80+
.jlab-gather-peer-hand-raised-icon {
81+
fill: #f37726;
82+
position: absolute;
83+
z-index: 40;
84+
top: 0.3rem;
85+
right: 0.3rem;
86+
width: 2rem;
87+
height: 2rem;
88+
}
89+
8190
.jlab-gather-peer-tile {
8291
display: flex;
8392
justify-content: center;
8493
position: relative;
8594
min-width: 8rem;
95+
border-radius: var(--gather-border-radius);
96+
}
97+
98+
.jlab-gather-peer-tile-sidepane {
8699
max-width: 16rem;
87100
min-height: 8rem;
88101
max-height: 16rem;
89102
}
90103

91-
.jlab-gather-peer-hand-raised-icon {
92-
fill: #f37726;
93-
position: absolute;
94-
z-index: 40;
95-
top: 0.3rem;
96-
right: 0.3rem;
97-
width: 2rem;
98-
height: 2rem;
104+
.jlab-gather-peer-tile-grid {
105+
flex: 1 1 20%;
106+
overflow: hidden;
107+
max-height: 32rem;
108+
aspect-ratio: 4/3;
99109
}
100110

101111
.jlab-gather-peer-video {
102112
object-fit: cover;
103113
z-index: 0;
104-
max-width: 256px;
105-
max-height: 256px;
106114
border-radius: var(--gather-border-radius);
107115
}
108116

117+
.jlab-gather-peer-video-sidepane {
118+
max-width: 128px;
119+
max-height: 128px;
120+
}
121+
122+
.jlab-gather-peer-video-grid {
123+
min-width: 256px;
124+
min-height: 256px;
125+
}
126+
109127
.jlab-gather-local {
110128
transform: scaleX(-1);
111129
}
@@ -123,8 +141,8 @@
123141
font-weight: bold;
124142
color: whitesmoke;
125143
text-align: center;
126-
white-space: nowrap;
127144
text-overflow: ellipsis;
145+
white-space: nowrap;
128146
}
129147

130148
.jlab-gather-control-bar {
@@ -272,8 +290,6 @@
272290

273291
.jlab-gather-icon {
274292
scale: 0.8;
275-
276-
/* fill: var(--jp-inverse-layout-color3); */
277293
fill: whitesmoke;
278294
}
279295

0 commit comments

Comments
 (0)