Skip to content

Commit a3b7ebc

Browse files
committed
(worklet): Connections, update README
1 parent 6979b87 commit a3b7ebc

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/connections/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,77 @@
33
A CSS Houdini Worklet to show connected nodes.
44

55
![CSS Houdini Connections](./assets/connections.png)
6+
7+
## Getting started
8+
9+
### 1. Load the worklet
10+
11+
Using CDN is the easiest way to add the library:
12+
13+
```js
14+
if ('paintWorklet' in CSS) {
15+
CSS.paintWorklet.addModule('https://rawcdn.githack.com/CSSHoudini/css-houdini/6979b873e80f9120f52bd481fbdf2d4c60db6b19/src/connections/dist/connections.js');
16+
}
17+
```
18+
19+
Or, download the latest [Connections Worklet](https://github.com/CSSHoudini/css-houdini/tree/main/src/connections/dist) and import it to your web page:
20+
21+
```js
22+
if ('paintWorklet' in CSS) {
23+
CSS.paintWorklet.addModule('path/to/connections.js');
24+
}
25+
```
26+
27+
#### You can use the polyfill
28+
29+
To add support for all moder browsers, you can load the worklet with [css-paint-polyfill](https://github.com/GoogleChromeLabs/css-paint-polyfill) fallback.
30+
31+
```html
32+
<script>
33+
;(async function() {
34+
if (CSS['paintWorklet'] === undefined)
35+
await import('https://unpkg.com/css-paint-polyfill')
36+
37+
CSS.paintWorklet.addModule('./connections.js')
38+
})()
39+
</script>
40+
```
41+
42+
### 3. Ready to use it in your CSS!
43+
44+
To use **connections** worlet you need define some custom properties with values and add the value `paint(connections)` on `background-image` property.
45+
46+
> The worklet has default values if you don't define these
47+
48+
```css
49+
.element {
50+
--connections-particleColor: rgb(150,180,200);
51+
--connections-lineColor: rgb(150,180,200);
52+
--connections-particleAmount: 40;
53+
--connections-defaultRadius: 2;
54+
--connections-variantRadius: 1;
55+
--connections-linkRadius: 60;
56+
57+
background-image: paint(connections);
58+
}
59+
```
60+
61+
| property | description | default value |
62+
| -------- | ----------- | ------------- |
63+
| --connections-particleColor | Dot color | `rgb(74,74,74)` |
64+
| --connections-lineColor | Line conections color | `rgb(76,76,76)` |
65+
| --connections-particleAmount | Dots number to show on the element | `(w * h) / 1000` Calc of width * height divided to 1000 |
66+
| --connections-defaultRadius | Dot radius | 1.5 |
67+
| --connections-variantRadius | Dot radius variant | 3 |
68+
| --connections-linkRadius | Minimum distance between dots to draw the line connection | 80 |
69+
70+
#### Important informaction
71+
72+
- The current worklet version needs that the values for `--connections-particleColor` and `--connections-lineColor` are **RGB Color** with format `rgb(150,180,200)`.
73+
- If you define a huge values, you can see hundreds of lines in your element.
74+
75+
## License
76+
77+
MIT License
78+
79+
Copyright (c) 2020 CSS Houdini

0 commit comments

Comments
 (0)