Skip to content

Commit

Permalink
feat(block): Added simple accordion block
Browse files Browse the repository at this point in the history
  • Loading branch information
holmey committed Apr 1, 2023
1 parent 2f3bbe5 commit 80e6b27
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 1 deletion.
4 changes: 3 additions & 1 deletion site/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*
!.gitignore
!.gitignore
!/block-factory
!/block-factory/*
86 changes: 86 additions & 0 deletions site/plugins/block-factory/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
.k-block-type-box {
position: relative;
padding: 10px;
border-radius: 5px;
}

.k-block-type-box.box-text {
background: #cce3ff;
}

.k-block-type-box.box-bolt {
background: #ffd9b3;
}

.k-block-type-box.box-alert {
background: #fcc;
}

.k-block-type-box.box-neutral {
background: #ccc;
}

.k-block-type-box-icon {
position: absolute;
top: 10px;
right: 10px;
}

details {
margin-left: 1rem;
}

details summary {
margin-left: -1rem;
margin-bottom: 0.5rem;
font-weight: 600;
}

details summary .k-writer {
display: inline-block;
width: calc(100% - 2rem);
}

.k-block-container:hover .fieldtype {
display: block;
}

.k-block-type-card-heading {
margin: 1rem 0;
}

.k-block-type-card-category {
margin-top: 1rem;
color: #333;
}

.k-block-type-faq-heading {
margin: 1rem 0;
}

.k-block-type-faq-item {
margin-bottom: 1rem;
}

.k-block-type-testimonial-quote footer {
margin-top: 1rem;
}

.k-block-type-testimonial-quote p {
border-left: 2px solid black;
padding-left: 0.75rem;
max-width: 25rem;
}

.k-block-type-testimonial-voice {
display: flex;
align-items: center;
}

.k-block-type-testimonial-voice img {
margin-right: 10px;
}

.k-block-type-testimonial-voice input {
border: none;
}
17 changes: 17 additions & 0 deletions site/plugins/block-factory/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
panel.plugin("cookbook/block-factory", {
blocks: {
accordion: `
<div>
<div v-if="content.summary">
<details>
<summary>{{ content.summary }}</summary>
<div v-if="content.details" v-html="content.details"></div>
</details>
</div>
<div v-else>
No content yet
</div>
</div>
`,
},
});
15 changes: 15 additions & 0 deletions site/plugins/block-factory/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

Kirby::plugin('cookbook/block-factory', [
'blueprints' => [
'blocks/accordion' => __DIR__ . '/blueprints/blocks/accordion.yml'
],
'snippets' => [
'blocks/accordion' => __DIR__ . '/snippets/blocks/accordion.php'
],
'translations' => [
'en' => [
'field.blocks.accordion.name' => 'Accordion block'
]
],
]);

0 comments on commit 80e6b27

Please sign in to comment.