@phun-ky/speccer 3.5.2 → 4.2.1
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.
- package/CHANGELOG.md +18 -0
- package/README.md +15 -43
- package/package.json +70 -32
- package/speccer.css +582 -2
- package/speccer.js +1680 -1
- package/speccer.min.css +1 -0
- package/src/browser.js +87 -0
- package/src/dissect.js +204 -0
- package/src/index.js +21 -818
- package/src/lib/attributes.js +13 -0
- package/src/lib/classnames.js +37 -0
- package/src/lib/constants.js +5 -0
- package/src/lib/css.js +37 -0
- package/src/lib/debounce.js +22 -0
- package/src/lib/node.js +7 -0
- package/src/lib/number.js +4 -0
- package/src/lib/resize.js +13 -0
- package/src/lib/styles.js +27 -0
- package/src/measure.js +88 -0
- package/src/spec.js +183 -0
- package/src/styles/anatomy.styl +274 -0
- package/src/styles/index.styl +68 -0
- package/src/styles/measure.styl +88 -0
- package/src/styles/spacing.styl +152 -0
- package/src/{typography.styl → styles/typography.styl} +13 -13
- package/src/typography.js +138 -0
- package/src/anatomy.styl +0 -358
- package/src/lib/poly.js +0 -15
- package/src/lib/style.js +0 -12
- package/src/lib/throttle.js +0 -19
- package/src/speccer.styl +0 -162
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
### [4.2.1](https://github.com/phun-ky/speccer/compare/v4.2.0...v4.2.1) (2022-02-22)
|
|
6
|
+
|
|
7
|
+
## [4.2.0](https://github.com/phun-ky/speccer/compare/v4.1.0...v4.2.0) (2022-02-22)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* Use CSS variables ([21c3eb3](https://github.com/phun-ky/speccer/commit/21c3eb3f173ee96b0bf452bae44f76155fcf3cdf))
|
|
13
|
+
|
|
14
|
+
## [4.1.0](https://github.com/phun-ky/speccer/compare/v4.0.0...v4.1.0) (2022-02-22)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- Add release script ([4cb72cb](https://github.com/phun-ky/speccer/commit/4cb72cbea7dd1d6bcb8f1102384b14eecaa9eef0))
|
package/README.md
CHANGED
|
@@ -15,10 +15,10 @@ See demo here: https://codepen.io/phun-ky/pen/xaOrYX
|
|
|
15
15
|
Either import and run the required functions:
|
|
16
16
|
|
|
17
17
|
```javascript
|
|
18
|
-
import {
|
|
18
|
+
import { speccer } from '@phun-ky/speccer/src/index.js';
|
|
19
19
|
|
|
20
20
|
// do stuff
|
|
21
|
-
|
|
21
|
+
speccer();
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Or place these `script` and `link` tags in your web page:
|
|
@@ -30,8 +30,6 @@ Or place these `script` and `link` tags in your web page:
|
|
|
30
30
|
|
|
31
31
|
And then follow the steps below to display the specifications you want :)
|
|
32
32
|
|
|
33
|
-
**_NOTE_** The activateOnResize function is using a throttled event for the [Window: resize event](https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event), this might give you some issues in an SPA.
|
|
34
|
-
|
|
35
33
|
If you use React, you can use an effect like this:
|
|
36
34
|
|
|
37
35
|
```javascript
|
|
@@ -48,14 +46,12 @@ const Component = () => {
|
|
|
48
46
|
import('@phun-ky/speccer/src/index.js').then(speccerScript => {
|
|
49
47
|
console.info('[@phun-ky/speccer]: Activated speccer ');
|
|
50
48
|
|
|
51
|
-
const {
|
|
52
|
-
anatomy();
|
|
49
|
+
const { speccer } = speccerScript;
|
|
53
50
|
speccer();
|
|
54
51
|
|
|
55
|
-
speccerEventFunc = debounce(function() {
|
|
52
|
+
speccerEventFunc = debounce(function () {
|
|
56
53
|
console.info('[@phun-ky/speccer]: Event resize triggered');
|
|
57
54
|
speccer();
|
|
58
|
-
anatomy();
|
|
59
55
|
}, 300);
|
|
60
56
|
|
|
61
57
|
window.addEventListener('resize', speccerEventFunc);
|
|
@@ -132,12 +128,12 @@ If you want to control speccer a bit more, you have some options. Apply one of t
|
|
|
132
128
|
<script src="../speccer.js" data-<manual|instant|dom|lazy></script>
|
|
133
129
|
```
|
|
134
130
|
|
|
135
|
-
| Tag | Description
|
|
136
|
-
| -------------- |
|
|
137
|
-
| `data-manual` | Makes `window.speccer`
|
|
138
|
-
| `data-instant` | fires off `
|
|
139
|
-
| `data-dom` | Waits for `DOMContentLoaded`
|
|
140
|
-
| `data-lazy` | Lazy loads `
|
|
131
|
+
| Tag | Description |
|
|
132
|
+
| -------------- | ------------------------------------------------------------------- |
|
|
133
|
+
| `data-manual` | Makes `window.speccer()` available to be used when you feel like it |
|
|
134
|
+
| `data-instant` | fires off `speccer()` right away |
|
|
135
|
+
| `data-dom` | Waits for `DOMContentLoaded` |
|
|
136
|
+
| `data-lazy` | Lazy loads `speccer()` per specced element |
|
|
141
137
|
|
|
142
138
|
If no attribute is applied, it will default to `data-dom`, as in, it will initialize when `DOMContentLoaded` is fired.
|
|
143
139
|
|
|
@@ -146,43 +142,19 @@ If no attribute is applied, it will default to `data-dom`, as in, it will initia
|
|
|
146
142
|
If you're importing speccer instead of with a script tag, you can use the following approach to apply lazy loading:
|
|
147
143
|
|
|
148
144
|
```javascript
|
|
149
|
-
import
|
|
145
|
+
import * as Dissect from '@phun-ky/speccer/src/dissect.js';
|
|
150
146
|
|
|
151
|
-
let specElementObserver = new IntersectionObserver((entries, observer) => {
|
|
152
|
-
entries.forEach(entry => {
|
|
153
|
-
if (entry.intersectionRatio > 0) {
|
|
154
|
-
specElement(entry.target);
|
|
155
|
-
observer.unobserve(entry.target);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
document.querySelectorAll('[data-speccer],[data-speccer] *:not(td)').forEach(el => {
|
|
160
|
-
specElementObserver.observe(el);
|
|
161
|
-
});
|
|
162
|
-
let measureElementObserver = new IntersectionObserver((entries, observer) => {
|
|
163
|
-
entries.forEach(entry => {
|
|
164
|
-
if (entry.intersectionRatio > 0) {
|
|
165
|
-
measureElement(entry.target);
|
|
166
|
-
observer.unobserve(entry.target);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
document.querySelectorAll('[data-speccer-measure]').forEach(el => {
|
|
171
|
-
measureElementObserver.observe(el);
|
|
172
|
-
});
|
|
173
147
|
let dissectElementObserver = new IntersectionObserver((entries, observer) => {
|
|
174
148
|
entries.forEach(entry => {
|
|
175
149
|
const targets = entry.target.querySelectorAll('[data-anatomy]');
|
|
176
150
|
if (entry.intersectionRatio > 0) {
|
|
177
|
-
targets.forEach(
|
|
151
|
+
targets.forEach(Dissect.element);
|
|
178
152
|
observer.unobserve(entry.target);
|
|
179
153
|
}
|
|
180
154
|
});
|
|
181
155
|
});
|
|
182
156
|
|
|
183
|
-
|
|
184
|
-
dissectElementObserver.observe(
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
document.querySelectorAll('[data-anatomy-section]').forEach(observeAnatomySections);
|
|
157
|
+
document.querySelectorAll('[data-anatomy-section]').forEach(el => {
|
|
158
|
+
dissectElementObserver.observe(el);
|
|
159
|
+
});
|
|
188
160
|
```
|
package/package.json
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phun-ky/speccer",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A script to show
|
|
3
|
+
"version": "4.2.1",
|
|
4
|
+
"description": "A script to annotate, show spacing specs and to display typography information in documentation/website on HTML elements",
|
|
5
5
|
"main": "speccer.js",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"rollup": "rollup -c",
|
|
12
|
+
"rollup:dev": "npm run clean && rollup -c -w",
|
|
13
|
+
"clean": "rm -rf ./speccer.css ./speccer.min.css ./speccer.js",
|
|
14
|
+
"build": "npm run clean && npm run rollup && npm run stylus && npm run postcss",
|
|
15
|
+
"styles": "npm run stylus && npm run postcss",
|
|
16
|
+
"stylus": "rm -rf ./speccer.css && stylus ./src/styles/index.styl -o ./speccer.css",
|
|
17
|
+
"postcss": "rm -rf ./speccer.min.css && postcss ./speccer.css -o speccer.min.css",
|
|
18
|
+
"dev": "node ./scripts/server.js",
|
|
19
|
+
"commit": "npx git-cz",
|
|
20
|
+
"release": "npx standard-version"
|
|
21
|
+
},
|
|
22
|
+
"standard-version": {
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prerelease": "npm run build",
|
|
25
|
+
"posttag": "git push --follow-tags origin master && npm publish"
|
|
26
|
+
}
|
|
13
27
|
},
|
|
14
28
|
"repository": {
|
|
15
29
|
"type": "git",
|
|
@@ -20,7 +34,22 @@
|
|
|
20
34
|
"css",
|
|
21
35
|
"javascript",
|
|
22
36
|
"spec",
|
|
23
|
-
"inspect"
|
|
37
|
+
"inspect",
|
|
38
|
+
"annotation",
|
|
39
|
+
"annotate",
|
|
40
|
+
"pin",
|
|
41
|
+
"specifications",
|
|
42
|
+
"anatomy",
|
|
43
|
+
"dissection",
|
|
44
|
+
"dissect",
|
|
45
|
+
"documentation",
|
|
46
|
+
"information",
|
|
47
|
+
"specification",
|
|
48
|
+
"specs",
|
|
49
|
+
"html-elements",
|
|
50
|
+
"inspect",
|
|
51
|
+
"spacing",
|
|
52
|
+
"speccer"
|
|
24
53
|
],
|
|
25
54
|
"author": "Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>",
|
|
26
55
|
"license": "MIT",
|
|
@@ -29,32 +58,41 @@
|
|
|
29
58
|
},
|
|
30
59
|
"homepage": "https://github.com/phun-ky/speccer#readme",
|
|
31
60
|
"devDependencies": {
|
|
32
|
-
"@babel/core": "^7.
|
|
33
|
-
"@babel/plugin-proposal-
|
|
34
|
-
"@babel/plugin-
|
|
35
|
-
"@babel/
|
|
36
|
-
"@babel/
|
|
37
|
-
"@babel/
|
|
38
|
-
"@babel
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"eslint
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
61
|
+
"@babel/core": "^7.2.2",
|
|
62
|
+
"@babel/plugin-proposal-export-default-from": "^7.12.13",
|
|
63
|
+
"@babel/plugin-transform-runtime": "^7.12.17",
|
|
64
|
+
"@babel/preset-env": "^7.2.3",
|
|
65
|
+
"@babel/register": "^7.12.13",
|
|
66
|
+
"@babel/runtime": "^7.12.18",
|
|
67
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
68
|
+
"@rollup/plugin-commonjs": "^17.1.0",
|
|
69
|
+
"@rollup/plugin-node-resolve": "^11.2.0",
|
|
70
|
+
"@testing-library/dom": "^7.29.4",
|
|
71
|
+
"@testing-library/jest-dom": "^5.11.9",
|
|
72
|
+
"@testing-library/user-event": "^12.7.1",
|
|
73
|
+
"babel-eslint": "^10.1.0",
|
|
74
|
+
"babel-jest": "^26.6.3",
|
|
75
|
+
"browser-sync": "^2.27.7",
|
|
76
|
+
"cssnano": "^5.0.4",
|
|
77
|
+
"eslint": "^7.32.0",
|
|
78
|
+
"eslint-config-airbnb": "^18.2.1",
|
|
79
|
+
"eslint-config-prettier": "^8.3.0",
|
|
80
|
+
"eslint-plugin-import": "^2.24.2",
|
|
81
|
+
"eslint-plugin-jest": "^24.4.2",
|
|
82
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
83
|
+
"jest": "^26.6.3",
|
|
84
|
+
"postcss": "^8.3.0",
|
|
85
|
+
"postcss-cli": "^8.3.1",
|
|
86
|
+
"prettier": "^2.4.1",
|
|
87
|
+
"prettier-eslint": "^13.0.0",
|
|
88
|
+
"regenerator-runtime": "^0.13.7",
|
|
89
|
+
"rollup": "^2.39.0",
|
|
90
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
91
|
+
"stylus": "^0.56.0"
|
|
92
|
+
},
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"eslint-plugin-jsx-a11y": "^6.4.1",
|
|
95
|
+
"eslint-plugin-react": "^7.23.2",
|
|
96
|
+
"eslint-plugin-react-hooks": "^4.2.0"
|
|
59
97
|
}
|
|
60
98
|
}
|