Commit 1e2fddf1 authored by Lasse Overgaard Møldrup's avatar Lasse Overgaard Møldrup
Browse files

Merge: Implemented grid basics

parent cbf43ed8
......@@ -22,6 +22,11 @@
<style lang="scss">
body, html {
height: 100%;
margin: 0;
}
div {
box-sizing: border-box;
}
#app {
......
<template>
<div class="active-courses">
<h2>Aktive kurser</h2>
<ul>
<li v-for="(course, index) in courses" :key="index"><a href="#">{{ course }}</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'ActiveCourses',
data() {
return {
courses: ['Calculus Beta', 'Databaser', 'etc.']
}
}
}
</script>
<style scoped lang="scss">
.active-courses {
@include block;
}
</style>
\ No newline at end of file
<template>
<div class="deadlines">
<h2>Deadlines</h2>
<table>
<tr v-for="(deadline, index) in deadlines" :key="index">
<td class="course-name">{{ deadline.course }}</td>
<td class="handin-name"><a href="#">{{ deadline.name }}</a></td>
<td class="due-date">{{ deadline.date.toLocaleDateString('da-dk').replace(/\./g, '/') }}</td>
</tr>
</table>
</div>
</template>
<script>
export default {
name: 'Deadlines',
data() {
return {
deadlines: [{ course: "Calculus Beta", name: "Aflevering 1", date: new Date() },
{ course: "Databaser", name: "SQL", date: new Date("10 Apr 2021") }]
}
}
}
</script>
<style scoped lang="scss">
.deadlines {
@include block;
}
td {
padding: 5px 10px;
}
</style>
\ No newline at end of file
@mixin block {
width: 100%;
height: 100%;
border: 2px solid black;
text-align: left;
padding: 20px;
h2 {
margin-top: 0;
}
}
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<div id="grid">
<div v-for="side in ['left', 'right']" :key="side" :id="side + '-col'">
<div class="row" v-for="(row, index) in $data[side]" :key="index" :style="{ height: row.height + 'px' }">
<div v-for="(block, index) in row.blocks" :key="index" :style="{ flexBasis: block.width + '%' }">
<component :is="block.type"></component>
</div>
</div>
<button class="add-block" @click="addBlock(side)">Add block</button>
</div>
</div>
</div>
</template>
<script>
import ActiveCourses from "@/components/ActiveCourses";
import Deadlines from "@/components/Deadlines";
export default {
name: 'Home',
data() {
return {
left: [
{
height: 200,
blocks: [{ type: "ActiveCourses", width: 100 }],
},
{
height: 200,
blocks: [{ type: "Deadlines", width: 100 }],
}
],
right: [
{
height: 300,
blocks: [{ type: "ActiveCourses", width: 100 }],
},
{
height: 200,
blocks: [{ type: "ActiveCourses", width: 50 }, { type: "Deadlines", width: 50 }],
},
]
}
},
methods: {
addBlock(side) {
this[side].push({
height: 200,
blocks: [{ type: "ActiveCourses", width: 100 }]
});
}
},
components: {
ActiveCourses,
Deadlines
}
}
</script>
<style scoped lang="scss">
$gap: 40px;
#grid {
display: flex;
align-items: flex-start;
width: 100%;
padding: $gap;
}
#left-col, #right-col {
flex-basis: 0;
min-width: 200px;
> *:not(:last-of-type) {
margin-bottom: $gap;
}
}
#left-col {
margin-right: $gap / 2;
flex-grow: 1;
}
#right-col {
margin-left: $gap / 2;
flex-grow: 3;
}
.row {
display: flex;
> div {
min-width: 200px;
&:not(:last-child) {
margin-right: $gap / 2;
}
&:not(:first-child) {
margin-left: $gap / 2;
}
}
}
</style>
module.exports = {
css: {
loaderOptions: {
sass: {
prependData: `@import "@/scss/_mixins.scss";`,
},
},
},
};
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment