From 5fbcd16a3c39f400201a85cf28bd75965f58ed1f Mon Sep 17 00:00:00 2001 From: sounmind Date: Sat, 22 Jun 2024 23:29:12 -0400 Subject: [PATCH] feat: add util functions for html and css --- html-css-utils.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 html-css-utils.js diff --git a/html-css-utils.js b/html-css-utils.js new file mode 100644 index 0000000..26d31e6 --- /dev/null +++ b/html-css-utils.js @@ -0,0 +1,34 @@ +/** + * Processes a template literal to combine strings and interpolated values into a single HTML string. + * + * @param {TemplateStringsArray} strings - An array of string literals. + * @param {...string} values - Interpolated values within the template literal. + * @returns {string} The combined HTML string. + */ +export function html(strings, ...values) { + let htmlString = strings[0]; + + for (let i = 0; i < values.length; i++) { + htmlString += values[i] + strings[i + 1]; + } + + return htmlString; +} + +/** + * Processes a template literal to combine strings and interpolated values into a single CSS string. + * + * @param {TemplateStringsArray} strings - An array of string literals. + * @param {...string} values - Interpolated values within the template literal. + * @returns {string} The combined CSS string. + */ +export function css(strings, ...values) { + const GlobalCSS = ``; + + return html` + ${GlobalCSS} + + `; +}