kirby-color-palette
kirby-color-palette copied to clipboard
Enable structured colors with dynamic options
Hi Sylvain Great job this plugin. I'm trying to use dynamic options from a structured field. For the color, it works, but the tooltip does not get the name. What am I missing?
My color-palette field:
type: color-palette
options: query
query:
fetch: site.colors.toStructure
value: "{{structureItem.color}}"
tooltip: "{{structureItem.name}}"
My structured field:
label: Colors used within pages
type: structure
fields:
name:
type: text
label: Name
color:
extends: fields/styles/color
Thank you
@sylvainjule how to do that?
The plugin uses the core Query functions, which sanitizes the query result and returns only the text / value pair. This will probably require switching to a dedicated query method, I'll try to implement it soon.
Is it just me are has this stopped working (trying it in Kirby 3.9.5
)
I found the issue: to determine wether the options are from a query, you are testing Object.keys(option).length == 2
(https://github.com/sylvainjule/kirby-color-palette/blob/master/src/components/field/ColorPalette.vue#L147). In recent versions of Kirby, the option has more keys: disabled
, icon
, info
, text
, value
. I have no idea where they come from, but removing the length check should solve the issue. Or is there a particular reason your are checking for the length? Of course we could just check for a length of 5, but this could break again in future versions.
I can create a PR (but I had to switch from parcel to kirbyup, since I couldn't get it running with parcel).