I'm working on a React website with a video player that should continuously play on all routes. I'm trying to figure out a way to build a specific dynamic layout using CSS Grid that will update itself and the state of all components except the video component.
The main challenge is to make sure that the video component does not re-render in order to avoid any interruption in the playback.
The Homepage (initial) layout is the following:
// Code from an online generator
<div class="container">
<div class="Video"></div>
<div class="Content"></div>
<div class="Sidebar"></div>
</div>
.container {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas:
"Video Video Sidebar"
"Content Content Sidebar"
". . .";
}
.Video { grid-area: Video; }
.Content { grid-area: Content; }
.Sidebar { grid-area: Sidebar; }
All other routes layout is the following:
// Code from an online generator
<div class="container">
<div class="Content"></div>
<div class="Video"></div>
<div class="Sidebar"></div>
</div>
.container { display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
gap: 0px 0px;
grid-auto-flow: row;
grid-template-areas:
"Content Content Video"
"Content Content Sidebar"
". . .";
}
.Content { grid-area: Content; }
.Video { grid-area: Video; }
.Sidebar { grid-area: Sidebar; }
Is it possible to transition from Layout 1 to Layout 2 using CSS Grid without re-rendering the video component?

