Add dynamic components

This commit is contained in:
Ramon Wenger 2018-08-15 18:47:33 +02:00
parent 0c31f838f2
commit 80b46a4781
10 changed files with 49 additions and 33 deletions

View File

@ -1,9 +1,8 @@
<template>
<div class="chapter">
<h3>{{chapter.title}}</h3>
<content-block></content-block>
<content-block></content-block>
<content-block></content-block>
<content-block :contentBlock="contentBlock" :key="contentBlock.id" v-for="contentBlock in chapter.contentBlocks">
</content-block>
</div>
</template>

View File

@ -1,40 +1,25 @@
<template>
<div class="content-block">
<h4>{{title}}</h4>
<h4>{{contentBlock.title}}</h4>
<component v-for="component in contents" :key="component.id" :is="component.type"
v-bind:data="component"></component>
<component v-for="component in contentBlock.contents" :key="component.id" :is="component.type"
v-bind="component"></component>
</div>
</template>
<script>
import TextBlock from '@/components/TextBlock.vue';
import Task from '@/components/Task.vue';
import ImageBlock from '@/components/ImageBlock.vue';
export default {
components: {
TextBlock
},
props: ['contentBlock'],
data() {
return {
title: 'Auftrag 1',
contents: [
{
type: 'text-block',
id: 1,
content: `
<p>
Sie haben diesen Sommer Ihre Lehre begonnen. Was bedeutet dieser neue Abschnitt für Sie?
</p>
<p>
Halten Sie Ihre Erfahrungen im Bereich <a href alt>«Zusammenarbeit»</a>
fest und stellen Sie diese anschliessend der Klasse vor.
</p>
`
}
]
}
components: {
'text_block': TextBlock,
Task,
'image_block': ImageBlock
}
}
</script>

View File

@ -0,0 +1,10 @@
<template>
<img src="https://picsum.photos/400" alt="" class="image-block">
</template>
<style scoped lang="scss">
.image-block {
width: 100%;
max-width: 100%;
}
</style>

View File

@ -10,7 +10,7 @@
<h3>Lernziele</h3>
<objective-group v-for="group in module.objectiveGroups" :key="group.id" :group="group"></objective-group>
<chapter :chapter="chapter"></chapter>
<chapter :chapter="chapter" v-for="chapter in module.chapters" :key="chapter.id"></chapter>
<h3>1.1 Lehrbeginn</h3>
<h4>Das Interview</h4>
<h4>Tipp</h4>

View File

@ -0,0 +1,15 @@
<template>
<div class="task" v-html="value.text"></div>
</template>
<script>
export default {
props: ['value']
}
</script>
<style scoped lang="scss">
.task {
padding-left: 30px;
}
</style>

View File

@ -1,9 +1,9 @@
<template>
<div v-html="data.content"></div>
<div v-html="value.text"></div>
</template>
<script>
export default {
props: ['data']
props: ['value']
}
</script>

View File

@ -28,6 +28,7 @@ query ModulesQuery($slug: String!) {
edges {
node {
id
title
contentBlocks {
edges {
node {

View File

@ -29,6 +29,12 @@
...node,
objectives: mapNodes(node.objectiveSet, node => node)
};
}),
chapters: mapNodes(node.chapters, node => {
return {
...node,
contentBlocks: mapNodes(node.contentBlocks, node => node)
}
})
};
}

View File

@ -9,7 +9,7 @@ h1, h2, h3, h4, h5 {
font-weight: 600;
}
p, a {
p, a, li {
font-family: $serif-font-family;
font-weight: 300;
}

View File

@ -12,7 +12,7 @@
.container {
margin: 0 auto;
width: 100%;
max-width: 1440px;
//max-width: 1440px;
display: grid;
grid-template-rows: 72px auto 50px;
grid-row-gap: 32px;