[O] Remove dynamic width, use fixed height instead

This commit is contained in:
Hykilpikonna
2020-04-12 14:44:00 -04:00
parent 81f66b65de
commit e886f981a0
+16 -40
View File
@@ -14,15 +14,15 @@
<el-row> <el-row>
<el-col :span="16" class="overall-span"> <el-col :span="16" class="overall-span">
<el-card class="large left vertical-center"> <el-card class="left vertical-center" style="height: 70vh">
</el-card> </el-card>
</el-col> </el-col>
<!-- Course list card --> <!-- Course list card -->
<el-col :span="8" class="overall-span"> <el-col :span="8" class="overall-span">
<el-card id="course-list" ref="cl" class="large right" body-style="padding: 0"> <el-card id="course-list" class="right" style="height: 70vh" body-style="padding: 0">
<div class="header" :style="{width: courseListWidth + 'px'}"> <div class="header padding-fix">
<div class="text">Course List</div> <div class="text">Course List</div>
<!-- Search --> <!-- Search -->
@@ -30,7 +30,7 @@
</div> </div>
<!-- Actual course list --> <!-- Actual course list -->
<div class="list"> <div class="list padding-fix">
<!-- Every course --> <!-- Every course -->
<div v-for="(course, index) in filteredCourses" class="item vertical-center"> <div v-for="(course, index) in filteredCourses" class="item vertical-center">
<span class="name">{{course.name}}</span> <span class="name">{{course.name}}</span>
@@ -57,16 +57,11 @@
directory: any[] = [] directory: any[] = []
loading = true loading = true
courseListWidth: number = 10;
/** /**
* Called before rendering * Called before rendering
*/ */
created() created()
{ {
// Update width dynamically
window.addEventListener("resize", this.updateWidth);
// Get courses // Get courses
App.http.post('/course-info', {}).then(result => App.http.post('/course-info', {}).then(result =>
{ {
@@ -84,32 +79,6 @@
}) })
} }
/**
* Called on destroy
*/
destroyed()
{
// Remove width updater
window.removeEventListener("resize", this.updateWidth);
}
/**
* Called on vue update
*/
updated()
{
this.updateWidth()
}
/**
* Update header width. (CSS doesn't work)
* https://stackoverflow.com/questions/17011195/positionfixed-and-widthinherit-with-percentage-parent
*/
updateWidth()
{
this.courseListWidth = (<Vue> this.$refs.cl).$el.clientWidth - 20;
}
get filteredCourses() get filteredCourses()
{ {
return this.courseInfo.filter(c => c.name.toLowerCase().includes(this.search)) return this.courseInfo.filter(c => c.name.toLowerCase().includes(this.search))
@@ -141,17 +110,18 @@
#course-list #course-list
{ {
margin-right: 20px; margin-right: 20px;
overflow-y: scroll;
.header
.padding-fix
{ {
position: fixed;
background: white;
// Fix width issue // Fix width issue
padding-left: 20px; padding-left: 20px;
padding-right: 20px; padding-right: 20px;
border-radius: 4px; border-radius: 4px;
}
.header
{
.text .text
{ {
@@ -167,6 +137,12 @@
} }
} }
.list
{
overflow: scroll;
overflow-x: hidden;
height: 377px;
}
.item .item
{ {
height: 30px; height: 30px;