Skip to content
Snippets Groups Projects
Commit 6a3b44c4 authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

generalisering som gjør det mulig å gjengi artikler i Norsk Ordbok

parent 746d0aeb
No related branches found
No related tags found
No related merge requests found
...@@ -163,8 +163,8 @@ export default { ...@@ -163,8 +163,8 @@ export default {
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
color: #2c3e50; color: #2c3e50;
margin-top: 60px; margin-top: 60px;
margin-left: 30%; margin-left: 500px;
margin-right: 10%; margin-right: 300px;
} }
.show { .show {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<section> <section>
<h3>Definisjoner</h3> <h3>Definisjoner</h3>
<ol> <ol>
<Definition v-for="definition in definitions" :key="definition.id" :body='definition' @article-click="article_link_click" /> <Definition v-for="definition in article.body.definitions" :level="1" :key="definition.id" :body='definition' @article-click="article_link_click" />
</ol> </ol>
</section> </section>
</article> </article>
...@@ -72,31 +72,49 @@ a { ...@@ -72,31 +72,49 @@ a {
//color: #42b983; //color: #42b983;
} }
ol > li { li {
padding-bottom: 4px;
}
li.level1.definition {
list-style: upper-alpha;
}
li.level3.definition {
list-style: lower-alpha;
}
li.sub_article > ul {
padding-left: 0px;
}
li.definition.level1, li.definition.level2 {
padding-bottom: 2em; padding-bottom: 2em;
} }
ol > li:only-child { ::marker {
font-weight: bold;
}
ol > li:only-child.level1, li:only-child.level2, li:only-child.level3 {
list-style: none; list-style: none;
} }
ol > li:only-child > ul { li:only-child.level1 > ol {
padding-left: 0px; padding-left: 0px;
} }
ul { ul {
padding-top: 8px; padding-top: 8px;
padding-left: 20px;
} }
ul li { ul li {
list-style:none; list-style:none;
} }
li ul .definition ul {
padding-left: 6px;
}
ul li.definition { ul li.definition {
list-style: disc; list-style: disc;
} }
</style> </style>
<template> <template>
<li class="definition" :ref="'def' + body.id" :id="'def' + body.id"> <li :class="['definition', 'level'+level]" :ref="'def' + body.id" :id="'def' + body.id">
<ul> <ul class="explanation">
<li :is="element_wrapper.template" :body="element_wrapper.element" v-for="(element_wrapper, index) in template_name_added" :key="index" @article-click="article_link_click">{{element_wrapper.element}}</li> <li :is="element_wrapper.template" :body="element_wrapper.element" v-for="(element_wrapper, index) in template_name_added" :key="index" @article-click="article_link_click">{{element_wrapper.element}}</li>
</ul> </ul>
<div :is="level < 3 ? 'ol' : 'ul'" class="sub_definitions" v-if="subdefs.length">
<Definition :level="level+1" :body="subdef" v-for="(subdef, index) in subdefs" :key="index" @article-click="article_link_click" />
</div>
<ul class="sub_articles" v-if="subArticles.length">
<SubArticle :body="subart" v-for="(subart, index) in subArticles" :key="index" @article-click="article_link_click" />
</ul>
</li> </li>
</template> </template>
...@@ -15,7 +21,8 @@ import CompoundList from './CompoundList.vue' ...@@ -15,7 +21,8 @@ import CompoundList from './CompoundList.vue'
var Definition = { var Definition = {
name: 'Definition', name: 'Definition',
props: { props: {
body: Object body: Object,
level: Number
}, },
components: { components: {
DefElement, DefElement,
...@@ -26,19 +33,23 @@ var Definition = { ...@@ -26,19 +33,23 @@ var Definition = {
}, },
computed: { computed: {
template_name_added: function(){ template_name_added: function(){
return this.body.elements.map( return this.body.elements.filter(el => ! ['definition', 'sub_article'].includes(el.type_)).map(
function(element){ function(element){
return { return {
'template': { 'template': {
'explanation': 'DefElement', 'explanation': 'DefElement',
'definition': 'Definition',
'example': 'Example', 'example': 'Example',
'sub_article': 'SubArticle',
'compound_list': 'CompoundList' 'compound_list': 'CompoundList'
}[element.type_] || 'li', }[element.type_] || 'li',
'element': element 'element': element
} }
}) })
},
subdefs: function() {
return this.body.elements.filter(el => el.type_ == 'definition')
},
subArticles: function() {
return this.body.elements.filter(el => el.type_ == 'sub_article')
} }
}, },
mounted: function() { mounted: function() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment