Thanks for the hint, this already helped a lot. I’ve now gotten so far as to get Kirby to use my Custom version of k-fields which I copied from Kirbys Core alongside the mixins it required. That way I’ve managed to include some custom UI in the k-field component.
What I’m still struggling with though is setting the data to be displayed inside the button. I’m not able to both access values from my Blueprint or compute them inside the index.php. Long term the value should be computed by accessing the pages field raw_catalog_data and comparing the value of the field with raw_catalog_data[fieldname].
This is my setup so far:
Blueprint
subheadline:
type: text
buttonmessage: "Hello from Blueprint"
text:
type: writer
buttonmessage: "Hello from Blueprint"
tags:
label: Tags
type: tags
buttonmessage: "Hello from Blueprint"
/src/components/mycomponent.vue
<template>
[…]
<slot name="header my-special-header">
[…]
<div class="k-field-header-extra">
<k-button variant="filled" size="xs" icon="split">{{ buttonmessage ?? "No button message set" }}</k-button>
[…]
</header>
</slot>
<slot />
[…]
</div>
</template>
<script>
// The imports below were also copied from Kirby's Core
import { disabled, help, id, label, name, required, type } from "../default-kirby-mixins/props.js";
export const props = {
mixins: [disabled, help, id, label, name, required],
props: {
counter: [Boolean, Object],
endpoints: Object,
input: {
type: [String, Number, Boolean],
default: null
},
translate: Boolean,
type: String,
buttonmessage: String // My additional Prop
}
};
export default {
mixins: [props],
inheritAttrs: false,
emits: ["blur", "focus"]
};
</script>
<style>[…]
</style>
/src/index.js
import mycomponent from './components/mycomponent.vue';
panel.plugin("mms/field-label-extension", {
components: {
"k-field": mycomponent
}
});
/index.php
<?php
Kirby::plugin('mms/field-label-extension', [
'name' => 'Field Label Extension',
'description' => 'Shows a badge next to field labels containing buttonmessage prop',
'version' => '1.0.0',
'panel' => [
'js' => 'index.js',
'css' => 'index.css'
],
'components' => [
'k-field' => [
'props' => [
'buttonmessage' => function ($buttonmessage = "button message from index.php") {
return $buttonmessage;
}
]
]
],
'fields' => [
// This should at least extend text fields
'text' => [
'extends' => 'text',
'props' => [
'buttonmessage' => function ($buttonmessage = "button message from index.php") {
return $buttonmessage;
}
]
]
]
]);
While I can access regular Field Properties like label or type, I’m unable to get the value of the custom property “buttonmessage”
Any ideas?