Skip to content

Commit 31f2273

Browse files
committed
Update docs
1 parent de84858 commit 31f2273

3 files changed

Lines changed: 36 additions & 19 deletions

File tree

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
A [ponyfill](https://ponyfill.com/) that provides client-side support for [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) (aka "CSS variables") in legacy and modern browsers.
1212

13-
- [Documentation](https://jhildenbiddle.github.io/css-vars-ponyfill)
14-
- [Demo](https://codepen.io/jhildenbiddle/pen/ZxYJrR/) (CodePen)
13+
- [Documentation & Demos](https://jhildenbiddle.github.io/css-vars-ponyfill)
1514

1615
## Features
1716

docs/index.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
A [ponyfill](https://ponyfill.com/) that provides client-side support for [CSS custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/--*) (aka "CSS variables") in legacy and modern browsers.
1212

13-
- [Demo](https://codepen.io/jhildenbiddle/pen/ZxYJrR/) (CodePen)
14-
1513
## Features
1614

1715
- Client-side transformation of CSS custom properties to static values
@@ -44,6 +42,17 @@ A [ponyfill](https://ponyfill.com/) that provides client-side support for [CSS c
4442
<br>
4543
<img src="assets/img/safari.svg" style="margin-right: 0.4em; vertical-align: text-bottom;"> Safari 6+
4644

45+
## Demos
46+
47+
- [Loading from CDN using `<script>`](https://glitch.com/edit/#!/css-vars-ponyfill-demo?path=demo.css%3A11%3A1)\
48+
Demonstrates usage with basic HTML and JavaScript.
49+
50+
- [Bundling using ES6 `import`](https://codesandbox.io/s/css-vars-ponyfill-demo-988bm?file=/src/demo.css)\
51+
Demonstrates importing and bundling as an ES6 module.
52+
53+
- [Angular using `options.watch`](https://codesandbox.io/s/css-vars-ponyfill-angular-demo-zqb2w?file=/src/demo.css)\
54+
Demonstrates Angular integration and automated processing of mounted/unmounted component styles.
55+
4756
## Installation
4857

4958
**NPM**
@@ -54,19 +63,21 @@ npm install css-vars-ponyfill
5463

5564
```js
5665
import cssVars from 'css-vars-ponyfill';
66+
67+
cssVars({
68+
// Options...
69+
});
5770
```
5871

5972
**CDN** ([jsdelivr.com](https://www.jsdelivr.com/) shown, also on [unpkg.com](https://unpkg.com/))
6073

6174
```html
62-
<!-- Latest v2.x.x -->
75+
<!-- index.html -->
76+
6377
<script src="https://cdn.jsdelivr.net/npm/css-vars-ponyfill@2"></script>
78+
<script src="main.js"></script>
6479
```
6580

66-
## Usage
67-
68-
This library is offered as a [ponyfill](https://ponyfill.com/), not a polyfill. As a result, a function must be called in order for processing to take place.
69-
7081
```js
7182
/* main.js */
7283

@@ -75,17 +86,21 @@ cssVars({
7586
});
7687
```
7788

89+
## Usage
90+
91+
*This library is offered as a [ponyfill](https://ponyfill.com/), not a polyfill. This means that the `cssVars()` function must be called at least once in order for processing to take place (see [demos](#demos) and [installation](#installation) for details).*
92+
7893
For each `<link>` and `<style>` element processed the ponyfill will:
7994

8095
1. Get the CSS content (including `@import` rules)
81-
1. Parse the CSS and convert it to an AST
82-
1. Parse custom property declarations from `:root` and `:host` rulesets
83-
1. Transform CSS `var()` functions to static values
84-
1. Transforms relative `url()` paths to absolute URLs
85-
1. Fix nested `calc()` functions
86-
1. Convert the AST back to CSS
87-
1. Append legacy-compatible CSS to the DOM
88-
1. Disable the original stylesheet if styles are no longer needed
96+
2. Parse the CSS and convert it to an AST
97+
3. Parse custom property declarations from `:root` and `:host` rulesets
98+
4. Transform CSS `var()` functions to static values
99+
5. Transforms relative `url()` paths to absolute URLs
100+
6. Fix nested `calc()` functions
101+
7. Convert the AST back to CSS
102+
8. Append legacy-compatible CSS to the DOM
103+
9. Disable the original stylesheet if styles are no longer needed
89104

90105
Example:
91106

@@ -920,10 +935,14 @@ cssVars({
920935

921936
- **Will the ponyfill support any of the above scenarios in the future?**
922937

923-
From [this comment](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/31#issuecomment-527674559):
938+
Probably not. See [this comment](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/31#issuecomment-527674559) from [#31](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/31):
924939

925940
> I also have to consider the fact that as time marches on, legacy browser support becomes less of an issue and so it becomes harder to justify time spent supporting them. If feedback proved that this was a critical issue for folks or if we were having this discussion in 2014/2015, I'd be much more likely to take on the work. Since neither of those are the case, it seems focusing on other tasks is a better use of time. That being said, I would be happy to review and assist with a PR if someone else wanted to have a go at it.
926941
942+
- **How can I conditionally load the ponyfill?**
943+
944+
See [this comment](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/64#issuecomment-474233684) from [#64](https://github.com/jhildenbiddle/css-vars-ponyfill/issues/64).
945+
927946
## Attribution
928947

929948
This ponyfill includes code based on the following projects. Many thanks to the authors and contributors for helping to make this project possible.

docs/sidebar.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
- [Documentation](/)
33
- [Changelog](changelog)
44
- **Links**
5-
- [![Code](assets/img/code.svg)Demo (CodePen)](https://codepen.io/jhildenbiddle/pen/ZxYJrR/)
65
- [![Github](assets/img/github.svg)Github](https://github.com/jhildenbiddle/css-vars-ponyfill)
76
- [![NPM](assets/img/npm.svg)NPM](https://www.npmjs.com/package/css-vars-ponyfill)
87
- [![Twitter](assets/img/twitter.svg)@jhildenbiddle](http://twitter.com/jhildenbiddle)

0 commit comments

Comments
 (0)