@auto-skeleton/core 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +75 -0
  2. package/package.json +4 -2
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # @auto-skeleton/core
2
+
3
+ Framework-agnostic DOM scanner that powers [auto-skeleton](https://github.com/riazzahmedm/react-auto-skeleton). Scans a DOM element and returns a list of bones — the positions and shapes needed to render a skeleton loader.
4
+
5
+ If you're using React, install [`@auto-skeleton/react`](https://www.npmjs.com/package/@auto-skeleton/react) instead — it includes this package.
6
+
7
+ ---
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @auto-skeleton/core
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import { scanBones } from "@auto-skeleton/core";
21
+
22
+ const bones = scanBones(document.getElementById("root"), {
23
+ minSize: 8,
24
+ ignoreSelectors: [".no-skeleton", "[data-live]"]
25
+ });
26
+
27
+ // bones: Array<{ x, y, width, height, radius, kind: "rect" | "circle" }>
28
+ ```
29
+
30
+ Each bone is positioned relative to the root element and ready to render as an absolutely-positioned overlay.
31
+
32
+ ---
33
+
34
+ ## API
35
+
36
+ ### `scanBones(root, options?)`
37
+
38
+ Scans `root` and returns an array of `Bone` objects.
39
+
40
+ | Option | Type | Default | Description |
41
+ |---|---|---|---|
42
+ | `minSize` | `number` | `8` | Minimum element size in px to generate a bone for |
43
+ | `ignoreSelectors` | `string[]` | `[]` | CSS selectors for elements to skip |
44
+
45
+ ### `Bone`
46
+
47
+ ```ts
48
+ type Bone = {
49
+ x: number;
50
+ y: number;
51
+ width: number;
52
+ height: number;
53
+ radius: number;
54
+ kind: "rect" | "circle";
55
+ };
56
+ ```
57
+
58
+ ---
59
+
60
+ ## Data attribute overrides
61
+
62
+ Elements inside the scanned tree can influence scanning behaviour:
63
+
64
+ | Attribute | Effect |
65
+ |---|---|
66
+ | `data-skeleton-ignore` | Skip this element |
67
+ | `data-skeleton-shape="circle\|rect"` | Force a shape |
68
+ | `data-skeleton-lines="N"` | Force N text lines |
69
+ | `data-skeleton-container` | Scan children instead of creating one large bone |
70
+
71
+ ---
72
+
73
+ ## Browser support
74
+
75
+ Latest 2 versions of Chrome, Edge, Firefox, and Safari. Requires `MutationObserver` and `ResizeObserver`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto-skeleton/core",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,8 +11,10 @@
11
11
  "require": "./dist/index.cjs"
12
12
  }
13
13
  },
14
+ "license": "MIT",
14
15
  "files": [
15
- "dist"
16
+ "dist",
17
+ "README.md"
16
18
  ],
17
19
  "scripts": {
18
20
  "build": "tsup",