Skip to content

Instantly share code, notes, and snippets.

@johannschopplich
Last active December 3, 2020 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johannschopplich/b062f80e8fdddb1676ea7fa3df6e7a96 to your computer and use it in GitHub Desktop.
Save johannschopplich/b062f80e8fdddb1676ea7fa3df6e7a96 to your computer and use it in GitHub Desktop.
Kirby 3.5 accordion block by @distantnative
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