This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retrieves all CSS custom properties (variables) from the document's style sheets. | |
* @returns {[string, string][]} An array of key-value pairs where the key is the CSS variable name and the value is its definition. | |
*/ | |
const getAllCssVariables = () => | |
[...document.styleSheets] | |
.filter(({ href }) => !href || href.startsWith(window.location.origin)) | |
.flatMap(({ cssRules }) => | |
[...cssRules] | |
.filter(({ type }) => type === 1) |