-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhtml-css-utils.js
34 lines (30 loc) · 1.01 KB
/
html-css-utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 = `<link rel="stylesheet" href="./global-styles.css" />`;
return html`
${GlobalCSS}
<style>
${html(strings, ...values)}
</style>
`;
}