@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 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 { anatomy, speccer, activateOnResize } from '@phun-ky/speccer/src/index.js';
18
+ import { speccer } from '@phun-ky/speccer/src/index.js';
19
19
 
20
20
  // do stuff
21
- anatomy();
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 { anatomy, speccer } = speccerScript;
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` and `window.anatomy` available to be used when you feel like it |
138
- | `data-instant` | fires off `anatomy()` and `speccer` right away |
139
- | `data-dom` | Waits for `DOMContentLoaded` |
140
- | `data-lazy` | Lazy loads `anatomy()` and `speccer()` per specced element |
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 { specElement, measureElement, dissectElement } from '@phun-ky/speccer';
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(dissectElement);
151
+ targets.forEach(Dissect.element);
178
152
  observer.unobserve(entry.target);
179
153
  }
180
154
  });
181
155
  });
182
156
 
183
- const observeAnatomySections = section => {
184
- dissectElementObserver.observe(section);
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": "3.5.2",
4
- "description": "A script to show specifications on html elements in your styleguide",
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
- "build": "rimraf ./dist && webpack --mode production",
12
- "commit": "npx git-cz"
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.9.0",
33
- "@babel/plugin-proposal-class-properties": "^7.8.3",
34
- "@babel/plugin-proposal-object-rest-spread": "^7.9.5",
35
- "@babel/plugin-syntax-dynamic-import": "^7.8.3",
36
- "@babel/plugin-transform-async-to-generator": "^7.8.3",
37
- "@babel/preset-env": "^7.9.5",
38
- "@babel/register": "^7.9.0",
39
- "babel-eslint": "^9.0.0",
40
- "babel-loader": "^8.1.0",
41
- "css-loader": "^1.0.1",
42
- "cssnano": "^4.1.10",
43
- "eslint": "^4.19.1",
44
- "eslint-config-prettier": "^2.9.0",
45
- "eslint-loader": "^2.2.1",
46
- "mini-css-extract-plugin": "^0.4.5",
47
- "postcss-loader": "^3.0.0",
48
- "prettier": "^1.19.1",
49
- "rimraf": "^2.7.1",
50
- "style-loader": "^0.23.1",
51
- "stylint": "^1.5.9",
52
- "stylint-loader": "^1.0.0",
53
- "stylus": "^0.54.7",
54
- "stylus-loader": "^3.0.2",
55
- "uglify-js": "^3.8.1",
56
- "uglifyjs-webpack-plugin": "^1.2.5",
57
- "webpack": "^4.42.1",
58
- "webpack-cli": "^3.3.11"
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
  }