diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-10-15 23:17:05 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-02 22:12:48 -0300 |
commit | 8c1df54b8b170adf81ffc2bfb5d49704b229647f (patch) | |
tree | 8ccbcebcf04ccd5c177c96dce754533f4109b2ef /src/content/dependencies | |
parent | 3fc178e77b076837358274821a148e3047378d45 (diff) |
content, css: generateDotSwitcherTemplate
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateDotSwitcherTemplate.js | 29 |
1 files changed, 29 insertions, 0 deletions
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)))), +}; |