diff options
Diffstat (limited to 'src/content/dependencies/generateColorStyleAttribute.js')
-rw-r--r-- | src/content/dependencies/generateColorStyleAttribute.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/content/dependencies/generateColorStyleAttribute.js b/src/content/dependencies/generateColorStyleAttribute.js new file mode 100644 index 0000000..03d95ac --- /dev/null +++ b/src/content/dependencies/generateColorStyleAttribute.js @@ -0,0 +1,37 @@ +export default { + contentDependencies: ['generateColorStyleVariables'], + extraDependencies: ['html'], + + relations: (relation) => ({ + colorVariables: + relation('generateColorStyleVariables'), + }), + + data: (color) => ({ + color: + color ?? null, + }), + + slots: { + color: { + validate: v => v.isColor, + }, + + context: { + validate: v => v.is( + 'any-content', + 'image-box', + 'primary-only'), + + default: 'any-content', + }, + }, + + generate: (data, relations, slots) => ({ + style: + relations.colorVariables.slots({ + color: slots.color ?? data.color, + context: slots.context, + }).content, + }), +}; |