Last active
December 3, 2020 16:46
-
-
Save johannschopplich/b062f80e8fdddb1676ea7fa3df6e7a96 to your computer and use it in GitHub Desktop.
Kirby 3.5 accordion block by @distantnative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
panel.plugin("distantnative/block-accordion", { | |
blocks: { | |
accordion: { | |
methods: { | |
addRow() { | |
this.content.rows.push({ summary: "", detail: "" }); | |
this.update({ rows: this.content.rows }); | |
}, | |
removeRow(index) { | |
this.content.rows.splice(index, 1); | |
this.update({ rows: this.content.rows }); | |
}, | |
updateRow(index, field, value) { | |
this.content.rows[index][field] = value; | |
this.update({ rows: this.content.rows }); | |
} | |
}, | |
template: ` | |
<div> | |
<details v-for="(row, rowIndex) in content.rows"> | |
<summary> | |
<k-writer | |
:value="row.summary" | |
@input="updateRow(rowIndex, 'summary', $event)" | |
/> | |
<k-button icon="trash" @click="removeRow(rowIndex)" /> | |
</summary> | |
<k-writer | |
:value="row.detail" | |
@input="updateRow(rowIndex, 'detail', $event)" | |
/> | |
</details> | |
<k-button icon="add" @click="addRow" /> | |
</div> | |
` | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment