2.0.2 • Published 9 months ago

@frankhoodbs/css-custom-properties-list v2.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

CSS Custom Properties List

A simple utility to fetch and list all CSS Custom Properties (often known as CSS Variables) defined in the :root selector of stylesheets from the same domain.

Version License

Features

  1. Domain Filtering: Only parses stylesheets from the same domain to avoid cross-origin issues.
  2. Focus on :root Selector: Specifically targets custom properties defined under the :root selector.

Usage

Import the utility function:

import { cssCustomPropertiesList } from '@frankhoodbs/css-custom-properties-list';

To get a list of custom properties from all stylesheets in the document:

const propertiesList = cssCustomPropertiesList(document.styleSheets);

console.log(propertiesList);

This will return an array of arrays, where each inner array contains two strings: the custom property name and its value. For example:

[
  ['--primary-color', '#ff4500'],
  ['--font-size', '16px']
]

Utility Functions

isSameDomain(styleSheet: CSSStyleSheet)

Determines whether a given stylesheet is from the same domain as the current page.

isStyleRule(rule: CSSRule)

Checks if a given rule is a style rule.

cssCustomPropertiesList(styleSheets: StyleSheetList)

The main utility function which accepts a list of stylesheets and returns the custom properties as described above.

2.0.2

9 months ago

2.0.1

9 months ago

1.2.12

9 months ago

1.2.11

9 months ago

1.2.9

11 months ago

1.2.10

11 months ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.17

1 year ago

1.1.16

1 year ago

1.1.15

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.1

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.17

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago