<div class="vue-app">
<panel :title="'Car Manufacturers'">
<cars :data="['Mazda', 'Ford', 'Mercedes']"></cars>
</panel>
<panel :title="'Lorem Ipsum'">
<lorem-ipsum></lorem-ipsum>
</panel>
</div>
<script type="text/x-template" id="cars">
<template>
<ul>
<li v-for="car in data" :key="car">{{car}}</li>
</ul>
</template>
</script>
<script type="text/x-template" id="lorem-ipsum">
<template>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</template>
</script>
body {
padding: .5rem
}
* {
padding: 0;
margin:0;
box-sizing: border-box;
}
.panel {
margin-bottom: .5rem
}
.panel, .panel-header {
border: 1px solid #d3d3d3;
border-radius: 4px;
}
.panel-header, .panel-body, .panel {
padding: .5rem;
}
.panel-header {
background-color:#efefef;
color: #eeeee
}
ul {
list-style: none;
}
ul > li {
padding: .5rem .2rem
}
// the wrapper panel
const panel = {
functional: true,
name: "panel",
props: {
title: String
},
render(createElement, context) {
const slots = context.slots();
const header = createElement('header', {
attrs: { class: 'panel-header'}
}, context.props.title);
const body = createElement('main', {
attrs: { class: 'panel-body'}
}, slots.default);
return createElement('section', {
attrs: { class: 'panel' }
}, [header, body]);
}
}
// sample components
const cars = {
name: 'cars',
template: '#cars',
props: {
data: Array
}
}
const loremIpsum = {
name: 'lorem-ipsum',
template: '#lorem-ipsum'
}
new Vue({
el: '.vue-app',
components: {
panel,
cars,
'lorem-ipsum': loremIpsum
}
});
View Compiled
This Pen doesn't use any external CSS resources.