Skip to content

Commit c92617d

Browse files
committedMay 17, 2021
init
0 parents  commit c92617d

File tree

7 files changed

+155
-0
lines changed

7 files changed

+155
-0
lines changed
 

‎.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# OS files
2+
.DS_Store
3+
4+
# npm modules
5+
/node_modules
6+
7+
# Composer files
8+
/vendor

‎LICENSE.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Jon Gacnik
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Kirby Fields Block
2+
3+
Kirby [block preview](https://getkirby.com/docs/reference/plugins/extensions/blocks) plugin to directly render block fields, allowing for inline editing.
4+
5+
<img src="https://files.jongacnik.com/kirby-fields-preview-1.png" width="975" height="auto" />
6+
7+
## Usage
8+
9+
### Block definition
10+
11+
When creating a custom block in your blueprints, pass `preview: fields` to utilize this plugin
12+
13+
```yaml
14+
blockname:
15+
name: Block Name
16+
preview: fields # required
17+
wysiwyg: true # recommended
18+
fields:
19+
text:
20+
label: Text
21+
type: text
22+
```
23+
24+
Setting `wysiwyg: true` prevents drawer from automatically opening when creating a new block.
25+
26+
### Disable block title
27+
28+
You can disable the block title bar by passing `label: false`
29+
30+
```yaml
31+
blockname:
32+
name: Block Name
33+
preview: fields
34+
wysiwyg: true
35+
label: false # disables block title bar
36+
fields:
37+
text:
38+
label: Text
39+
type: text
40+
```
41+
42+
<details>
43+
<summary>Example</summary>
44+
<img src="https://files.jongacnik.com/kirby-fields-preview-2.png" width="975" height="auto" />
45+
</details>
46+
47+
## Notes
48+
49+
- The block `icon` will appear in the title bar.
50+
- Currently does not support blocks with tabs.
51+
52+
## Installation
53+
54+
```
55+
composer require jg/kirby-fields-block
56+
```
57+
58+
<details>
59+
<summary>Other installation methods</summary>
60+
61+
### Download
62+
63+
Download and copy this repository to `/site/plugins/kirby-fields-block`.
64+
65+
### Git submodule
66+
67+
```
68+
git submodule add https://github.com/jongacnik/kirby-fields-block.git site/plugins/kirby-fields-block
69+
```
70+
</details>

‎composer.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "jg/kirby-fields-block",
3+
"description": "Kirby Fields Block",
4+
"type": "kirby-plugin",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Jon Gacnik",
9+
"email": "jon@folderstudio.com"
10+
}
11+
],
12+
"require": {
13+
"getkirby/composer-installer": "^1.1"
14+
}
15+
}

‎index.css

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.k-block-fields-preview {
2+
margin: -0.75rem;
3+
}
4+
5+
.k-block-fields-preview .k-block-title {
6+
padding: 0.75rem;
7+
background: #f7f7f7;
8+
border-bottom: 1px solid #efefef;
9+
border-bottom: 1px solid rgb(229,229,229);
10+
border-bottom: 1px solid rgba(0,0,0,.1);
11+
}
12+
13+
.k-block-fields-preview .k-form {
14+
padding: 1.25rem 1.5rem 1.5rem 1.5rem;
15+
}

‎index.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
panel.plugin("jg/fields-block", {
2+
blocks: {
3+
fields: `
4+
<div class="k-block-fields-preview">
5+
<template>
6+
<k-block-title
7+
:content="content"
8+
:fieldset="fieldset"
9+
@dblclick="$emit('open')"
10+
v-if="fieldset.label === null || fieldset.label"
11+
/>
12+
<k-form
13+
ref="form"
14+
:autofocus="true"
15+
:fields="fieldset.tabs.content.fields"
16+
:value="$helper.clone(content)"
17+
@input="$emit('update', $event)"
18+
/>
19+
</template>
20+
</div>
21+
`
22+
}
23+
});

‎index.php

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
Kirby::plugin('jg/fields-block', []);

0 commit comments

Comments
 (0)
Please sign in to comment.