From 8c1df54b8b170adf81ffc2bfb5d49704b229647f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 15 Oct 2024 23:17:05 -0300 Subject: content, css: generateDotSwitcherTemplate --- .../dependencies/generateDotSwitcherTemplate.js | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/content/dependencies/generateDotSwitcherTemplate.js (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateDotSwitcherTemplate.js b/src/content/dependencies/generateDotSwitcherTemplate.js new file mode 100644 index 00000000..6d350b22 --- /dev/null +++ b/src/content/dependencies/generateDotSwitcherTemplate.js @@ -0,0 +1,29 @@ +export default { + extraDependencies: ['html', 'language'], + + slots: { + attributes: { + type: 'attributes', + mutable: false, + }, + + options: { + validate: v => v.strictArrayOf(v.isHTML), + }, + + initialOptionIndex: {type: 'number'}, + }, + + generate: (slots, {html, language}) => + html.tag('span', {class: 'dot-switcher'}, + slots.attributes, + + language.formatListWithoutSeparator( + slots.options + .map((option, index) => + html.tag('span', + index === slots.initialOptionIndex && + {class: 'current'}, + + option)))), +}; -- cgit 1.3.0-6-gf8a5