Skip to content

Instantly share code, notes, and snippets.

@nwrox
Created April 1, 2018 23:26
Show Gist options
  • Save nwrox/df62315673ac9459ea91de75837fbdbf to your computer and use it in GitHub Desktop.
Save nwrox/df62315673ac9459ea91de75837fbdbf to your computer and use it in GitHub Desktop.
<template>
<div class="container-info">
<div class="info-title">Informações:</div>
<div class="container-rows"
:style="{ 'gridTemplateAreas': createAreas }">
<div :key="row"
:style="{ 'font-weight': !(i % 2) ? 'bold' : 'normal' }"
v-for="(row, i) in createRows">
{{ row }}
</div>
</div>
</div>
</template>
<script>
export default {
computed: {
createAreas () {
const { element } = this
const len = Object.entries(element)
.length
return Array.from(Array(len / 2).keys())
.map(n => `header${n} data${n}`)
},
createRows () {
const { element } = this
const rows = []
Object.entries(element)
.forEach(([k, v]) => {
rows[rows.length] = k
rows[rows.length] = v
})
return rows
}
},
props: ['element']
}
</script>
<style lang="scss" scoped>
.container-info {
margin: 25px 0;
}
.container-rows {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
.info-title {
font-weight: bold;
margin-bottom: 10px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment