diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-12-29 23:58:38 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-12-30 16:26:36 -0400 |
commit | 3fb01a3022a3f47c0e1e6e76771a35fce23a128b (patch) | |
tree | c8b23f194b1c632b02c926cb1b3eeb0b1084cca7 /src/content/dependencies/generateColorStyleAttribute.js | |
parent | f400a43640e7106d181d55365a9617c3d12e5891 (diff) |
content: generateColorStyleAttribute
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..af8633a --- /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', + 'page-root', + 'primary-only'), + + default: 'any-content', + }, + }, + + generate: (data, relations, slots) => ({ + style: + relations.colorVariables.slots({ + color: slots.color ?? data.color, + context: slots.context, + }).content, + }), +}; |