Refactor content list component
This commit is contained in:
parent
ddc484e0f3
commit
db35d407ca
|
|
@ -94,6 +94,7 @@
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@import "~styles/main.scss";
|
@import "~styles/main.scss";
|
||||||
|
@import "~styles/helpers";
|
||||||
|
|
||||||
body {
|
body {
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
<template>
|
||||||
|
<ol class="content-list">
|
||||||
|
<li
|
||||||
|
:key="item.id"
|
||||||
|
class="content-list__item"
|
||||||
|
v-for="(item, index) in items">
|
||||||
|
<p class="content-list__numbering">{{ alphaIndex(index) }})</p>
|
||||||
|
<slot :item="item">
|
||||||
|
{{ item.id }}
|
||||||
|
</slot>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const lowerAsciiA = 97;
|
||||||
|
|
||||||
|
export default {
|
||||||
|
//
|
||||||
|
props: {
|
||||||
|
startingIndex: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
items: {
|
||||||
|
type: Array,
|
||||||
|
default: () => ([])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
alphaIndex(index) {
|
||||||
|
return String.fromCharCode(lowerAsciiA + this.startingIndex + index);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
@import '~styles/helpers';
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
@ -1,32 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="content-list-block__container">
|
<content-list
|
||||||
<div class="content-list-wrapper">
|
:items="contentBlocks"
|
||||||
<ol class="content-list">
|
:starting-index="startingIndex">
|
||||||
<li
|
<template v-slot:default="{ item }">
|
||||||
:key="contentBlock.id"
|
<content-block
|
||||||
class="content-list__item contentlist-item"
|
:content-block="item"
|
||||||
v-for="(contentBlock, index) in contentBlocks">
|
:parent="parent"
|
||||||
<p class="content-list__numbering">{{ alphaIndex(index) }})</p>
|
/>
|
||||||
<content-block
|
</template>
|
||||||
:content-block="contentBlock"
|
</content-list>
|
||||||
:parent="parent"
|
|
||||||
/>
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
const lowerAsciiA = 97;
|
import ContentList from '@/components/content-blocks/ContentList';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ContentBlockList',
|
name: 'ContentBlockList',
|
||||||
props: ['contents', 'parent', 'startingIndex'],
|
props: ['contents', 'parent', 'startingIndex'],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
ContentList,
|
||||||
// https://vuejs.org/v2/guide/components-edge-cases.html#Circular-References-Between-Components
|
// https://vuejs.org/v2/guide/components-edge-cases.html#Circular-References-Between-Components
|
||||||
ContentBlock: () => import('@/components/ContentBlock')
|
ContentBlock: () => import('@/components/ContentBlock')
|
||||||
},
|
},
|
||||||
|
|
@ -45,36 +38,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
};
|
||||||
alphaIndex(index) {
|
|
||||||
return String.fromCharCode(lowerAsciiA + this.startingIndex + index);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "~styles/helpers";
|
||||||
@import "@/styles/_mixins.scss";
|
|
||||||
|
|
||||||
.content-list-wrapper {
|
|
||||||
.content-list {
|
|
||||||
/* https://stackoverflow.com/questions/1632005/ordered-list-html-lower-alpha-with-right-parentheses */
|
|
||||||
|
|
||||||
&__item {
|
|
||||||
list-style: none;
|
|
||||||
position: relative;
|
|
||||||
padding: 0 0 0 2*15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__numbering {
|
|
||||||
position: absolute;
|
|
||||||
font-weight: 600;
|
|
||||||
left: 0;
|
|
||||||
color: $color-brand;
|
|
||||||
line-height: 27px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
.content-list {
|
||||||
|
/* https://stackoverflow.com/questions/1632005/ordered-list-html-lower-alpha-with-right-parentheses */
|
||||||
|
|
||||||
|
&__item {
|
||||||
|
list-style: none;
|
||||||
|
position: relative;
|
||||||
|
padding: 0 0 0 2*15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__numbering {
|
||||||
|
position: absolute;
|
||||||
|
font-weight: 600;
|
||||||
|
left: 0;
|
||||||
|
color: $color-brand;
|
||||||
|
line-height: 27px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,3 +27,4 @@
|
||||||
@import "simple-list";
|
@import "simple-list";
|
||||||
@import "widget-popover";
|
@import "widget-popover";
|
||||||
@import "intro";
|
@import "intro";
|
||||||
|
@import "nested-content-lists";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue