Skip to content

Commit 71264f5

Browse files
committed
✨ added block/field/section/tab blueprints and new stats field
Signed-off-by: Bruno Meilick <b@bnomei.com>
1 parent a9571f9 commit 71264f5

10 files changed

Lines changed: 212 additions & 3 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ You can use the schema in Sublime Text by cloning this repo to your local machin
5151

5252
## Blueprint detection
5353

54-
Since Kirby reuses some types like `file`, `info`, `pages` in fields and sections the schema can not always determine which blueprint you are working on with absolute certainty. For now, I introduced a `blueprint` property to solve this. Use it in your `file`, `page`, `user` and `site` blueprints.
54+
Since Kirby reuses some types like `file`, `info`, `pages` in fields and sections the schema cannot always determine which blueprint you are working on with absolute certainty. For now, I introduced a `blueprint` property to solve this. Use it in your `block`, `field`, `file`, `page`, `section`, `site`, `tab` and `user` blueprints.
5555

5656
```diff
5757
+ blueprint: site
@@ -73,6 +73,13 @@ fields:
7373
type: text
7474
```
7575

76+
> [!IMPORTANT]
77+
> Adding the `blueprint` property does not affect Kirby in any way. It is just a hint for your IDE. It's safe to share such blueprints with colleagues that do not have the schema installed.
78+
79+
## Validate
80+
81+
Check out the test files in the `tests` folder on how to programmatically validate your blueprints with the schema. You can use a similar setup in your CI pipeline.
82+
7683
## Disclaimer
7784

7885
This schema is provided "as is" with no guarantee. Use it at your own risk and always test it yourself before using it in a production environment. If you find any issues, please [create a new issue](https://github.com/bnomei/kirby3-schema/issues/new).

kirby5-blueprints.schema.json

Lines changed: 129 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
{
7676
"$ref": "#/$defs/fields/structure"
7777
},
78+
{
79+
"$ref": "#/$defs/fields/stats"
80+
},
7881
{
7982
"$ref": "#/$defs/fields/tags"
8083
},
@@ -120,6 +123,9 @@
120123
{
121124
"$ref": "#/$defs/sections/stats"
122125
},
126+
{
127+
"$ref": "#/$defs/blueprints/block"
128+
},
123129
{
124130
"$ref": "#/$defs/blueprints/file"
125131
},
@@ -129,6 +135,9 @@
129135
{
130136
"$ref": "#/$defs/blueprints/site"
131137
},
138+
{
139+
"$ref": "#/$defs/blueprints/tab"
140+
},
132141
{
133142
"$ref": "#/$defs/blueprints/user"
134143
}
@@ -493,6 +502,12 @@
493502
"@title": {
494503
"$ref": "#/$defs/stringOrTranslated"
495504
},
505+
"@label": {
506+
"$ref": "#/$defs/stringOrTranslated"
507+
},
508+
"@name": {
509+
"$ref": "#/$defs/stringOrTranslated"
510+
},
496511
"@create": {
497512
"type": "object",
498513
"properties": {
@@ -645,6 +660,45 @@
645660
}
646661
},
647662
"blueprints": {
663+
"block": {
664+
"type": "object",
665+
"required": [
666+
"blueprint"
667+
],
668+
"additionalProperties": false,
669+
"properties": {
670+
"blueprint": {
671+
"enum": [
672+
"block"
673+
]
674+
},
675+
"name": {
676+
"$ref": "#/$defs/blueprint-properties/@name"
677+
},
678+
"icon": {
679+
"$ref": "#/$defs/blueprint-properties/@icon"
680+
},
681+
"preview": {
682+
"$ref": "#/$defs/nonEmptyString"
683+
},
684+
"wysiwyg": {
685+
"type": "boolean",
686+
"default": false
687+
},
688+
"fields": {
689+
"$ref": "#/$defs/wrappers/fields"
690+
},
691+
"sections": {
692+
"$ref": "#/$defs/wrappers/sections"
693+
},
694+
"columns": {
695+
"$ref": "#/$defs/wrappers/columns"
696+
},
697+
"tabs": {
698+
"$ref": "#/$defs/wrappers/tabs"
699+
}
700+
}
701+
},
648702
"file": {
649703
"type": "object",
650704
"required": [
@@ -712,8 +766,8 @@
712766
"$ref": "#/$defs/numberInPixel"
713767
},
714768
"crop": {
715-
"type": "boolean",
716-
"default": false
769+
"type": "boolean",
770+
"default": false
717771
}
718772
}
719773
},
@@ -869,6 +923,38 @@
869923
"$ref": "#/$defs/wrappers/tabs"
870924
}
871925
}
926+
},
927+
"tab": {
928+
"type": "object",
929+
"required": [
930+
"blueprint"
931+
],
932+
"additionalProperties": false,
933+
"properties": {
934+
"blueprint": {
935+
"enum": [
936+
"tab"
937+
]
938+
},
939+
"label": {
940+
"$ref": "#/$defs/blueprint-properties/@label"
941+
},
942+
"icon": {
943+
"$ref": "#/$defs/blueprint-properties/@icon"
944+
},
945+
"fields": {
946+
"$ref": "#/$defs/wrappers/fields"
947+
},
948+
"sections": {
949+
"$ref": "#/$defs/wrappers/sections"
950+
},
951+
"columns": {
952+
"$ref": "#/$defs/wrappers/columns"
953+
},
954+
"tabs": {
955+
"$ref": "#/$defs/wrappers/tabs"
956+
}
957+
}
872958
}
873959
},
874960
"field-properties": {
@@ -3147,6 +3233,38 @@
31473233
}
31483234
}
31493235
},
3236+
"stats": {
3237+
"type": "object",
3238+
"required": [
3239+
"type"
3240+
],
3241+
"additionalProperties": false,
3242+
"properties": {
3243+
"type": {
3244+
"enum": [
3245+
"stats"
3246+
]
3247+
},
3248+
"blueprint": {
3249+
"enum": [
3250+
"field"
3251+
]
3252+
},
3253+
"headline": {
3254+
"$ref": "#/$defs/field-properties/@headline"
3255+
},
3256+
"label": {
3257+
"$ref": "#/$defs/field-properties/@label"
3258+
},
3259+
"reports": {
3260+
"$ref": "#/$defs/blueprint-properties/@reports"
3261+
},
3262+
"size": {
3263+
"$ref": "#/$defs/field-properties/@size",
3264+
"default": "large"
3265+
}
3266+
}
3267+
},
31503268
"tags": {
31513269
"required": [
31523270
"type"
@@ -3969,6 +4087,9 @@
39694087
"fields"
39704088
]
39714089
},
4090+
"blueprint": {
4091+
"const": "section"
4092+
},
39724093
"fields": {
39734094
"$ref": "#/$defs/wrappers/fields"
39744095
}
@@ -4315,6 +4436,9 @@
43154436
{
43164437
"$ref": "#/$defs/fields/structure"
43174438
},
4439+
{
4440+
"$ref": "#/$defs/fields/stats"
4441+
},
43184442
{
43194443
"$ref": "#/$defs/fields/tags"
43204444
},
@@ -4369,6 +4493,9 @@
43694493
},
43704494
{
43714495
"$ref": "#/$defs/sections/pages"
4496+
},
4497+
{
4498+
"$ref": "#/$defs/sections/stats"
43724499
}
43734500
]
43744501
}

tests/blueprints.test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
const validate = require('./validate')
22

3+
test('block', () => {
4+
expect(validate('./tests/fixtures/blueprints/block.yml')).toBeTruthy();
5+
});
6+
7+
test('field', () => {
8+
expect(validate('./tests/fixtures/blueprints/field.yml')).toBeTruthy();
9+
});
10+
311
test('file', () => {
412
expect(validate('./tests/fixtures/blueprints/file.yml')).toBeTruthy();
513
});
@@ -8,10 +16,18 @@ test('page', () => {
816
expect(validate('./tests/fixtures/blueprints/page.yml')).toBeTruthy();
917
});
1018

19+
test('section', () => {
20+
expect(validate('./tests/fixtures/blueprints/section.yml')).toBeTruthy();
21+
});
22+
1123
test('site', () => {
1224
expect(validate('./tests/fixtures/blueprints/site.yml')).toBeTruthy();
1325
});
1426

1527
test('user', () => {
1628
expect(validate('./tests/fixtures/blueprints/user.yml')).toBeTruthy();
1729
});
30+
31+
test('tab', () => {
32+
expect(validate('./tests/fixtures/blueprints/tab.yml')).toBeTruthy();
33+
});

tests/fields.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ test('structure', () => {
9696
expect(validate('./tests/fixtures/fields/structure.yml')).toBeTruthy();
9797
});
9898

99+
test('stats', () => {
100+
expect(validate('./tests/fixtures/fields/stats.yml')).toBeTruthy();
101+
});
102+
99103
test('tags', () => {
100104
expect(validate('./tests/fixtures/fields/tags.yml')).toBeTruthy();
101105
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
blueprint: block
2+
icon: bars
3+
name: field.blocks.accordion.name
4+
fields:
5+
summary:
6+
label: Summary
7+
type: writer
8+
marks: false
9+
placeholder: Enter summary…
10+
details:
11+
label: Detail
12+
type: writer
13+
marks: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
blueprint: field
2+
type: text
3+
label: Text
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
blueprint: section
2+
type: info
3+
label: some section
4+
text: options

tests/fixtures/blueprints/tab.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
blueprint: tab
2+
label: some tab
3+
icon: home
4+
5+
sections:
6+
pages:
7+
type: pages
8+
into:
9+
type: info

tests/fixtures/fields/stats.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
blueprint: field
2+
type: stats
3+
# Available size options: small, medium, large, huge. Default is large
4+
size: large
5+
reports:
6+
- label: Revenue
7+
value: €29,682
8+
info: +112.5%
9+
link: https://getkirby.com/shop
10+
theme: positive
11+
- label: Orders
12+
value: 265
13+
info: +82.8%
14+
theme: positive
15+
- label: Avg. Transaction
16+
value: €112.01
17+
info: +16.3%
18+
theme: positive
19+
- label: Refunds
20+
value: €15.20
21+
info: +10.5%
22+
theme: positive
23+
- label: Discount sales
24+
value: €1,422
25+
info: n/a

tests/fixtures/sections/stats.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
blueprint: section
12
type: stats
23
# Available size options: small, medium, large, huge. Default is large
34
size: huge

0 commit comments

Comments
 (0)