@phun-ky/speccer 4.2.1 → 4.3.0

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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
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
4
 
5
+ ## [4.3.0](https://github.com/phun-ky/speccer/compare/v4.2.1...v4.3.0) (2022-02-22)
6
+
7
+
8
+ ### Feature
9
+
10
+ * 🎸 Expose API a bit more ([093b465](https://github.com/phun-ky/speccer/commit/093b465653c32ec77fec6bb1d9d9e3adfd59809f))
11
+
12
+
13
+ ### Documentation
14
+
15
+ * ✏️ Move images into assets ([2291b31](https://github.com/phun-ky/speccer/commit/2291b31d768a16f202f2ffed453cfc22f3027e67))
16
+ * ✏️ Update documentation ([ec0807e](https://github.com/phun-ky/speccer/commit/ec0807e8c5d9c7eeaa807b80d7c432bee24d59d4))
17
+
5
18
  ### [4.2.1](https://github.com/phun-ky/speccer/compare/v4.2.0...v4.2.1) (2022-02-22)
6
19
 
7
20
  ## [4.2.0](https://github.com/phun-ky/speccer/compare/v4.1.0...v4.2.0) (2022-02-22)
package/README.md CHANGED
@@ -1,35 +1,46 @@
1
1
  # speccer
2
2
 
3
- > A script to show specifications on html elements in your styleguide
3
+ ![npm version](https://img.shields.io/npm/v/@phun-ky/speccer) ![issues](https://img.shields.io/github/issues/phun-ky/speccer) ![license](https://img.shields.io/npm/l/@phun-ky/speccer) ![size](https://img.shields.io/bundlephobia/min/@phun-ky/speccer)
4
4
 
5
- Speccer was created to make it easier to document components in a style guide.
5
+ > A script to show specifications on components in your design system documentation
6
+
7
+ Speccer was created to make it easier to document components in a design system.
6
8
 
7
9
  $ npm i @phun-ky/speccer
8
10
 
9
11
  See demo here: https://codepen.io/phun-ky/pen/xaOrYX
10
12
 
11
- ![Image of speccer](./speccer.png)
13
+ ![Image of speccer](./assets/speccer.png)
14
+
15
+ ---
12
16
 
13
17
  ## Usage
14
18
 
19
+ ### ESM
20
+
15
21
  Either import and run the required functions:
16
22
 
17
23
  ```javascript
18
- import { speccer } from '@phun-ky/speccer/src/index.js';
24
+ import '@phun-ky/speccer/speccer.min.css';
25
+ import speccer from '@phun-ky/speccer';
19
26
 
20
27
  // do stuff
21
28
  speccer();
22
29
  ```
23
30
 
31
+ ### Script
32
+
24
33
  Or place these `script` and `link` tags in your web page:
25
34
 
26
35
  ```html
27
- <link rel="stylesheet" href="../path/to/speccer.css" />
36
+ <link rel="stylesheet" href="../path/to/speccer.min.css" />
28
37
  <script src="../path/to/speccer.js"></script>
29
38
  ```
30
39
 
31
40
  And then follow the steps below to display the specifications you want :)
32
41
 
42
+ ### React
43
+
33
44
  If you use React, you can use an effect like this:
34
45
 
35
46
  ```javascript
@@ -37,28 +48,21 @@ import React, { useEffect } from 'react';
37
48
  import PropTypes from 'prop-types';
38
49
 
39
50
  import debounce from './lib/debounce';
40
- import '@phun-ky/speccer/speccer.css';
51
+ import '@phun-ky/speccer/speccer.min.css';
41
52
 
42
53
  const Component = () => {
43
54
  let speccerEventFunc;
44
55
 
45
- useEffect(() => {
46
- import('@phun-ky/speccer/src/index.js').then(speccerScript => {
47
- console.info('[@phun-ky/speccer]: Activated speccer ');
56
+ useEffect(async () => {
57
+ const { default: speccer } = await import('@phun-ky/speccer');
48
58
 
49
- const { speccer } = speccerScript;
50
- speccer();
59
+ speccer();
51
60
 
52
- speccerEventFunc = debounce(function () {
53
- console.info('[@phun-ky/speccer]: Event resize triggered');
54
- speccer();
55
- }, 300);
56
-
57
- window.addEventListener('resize', speccerEventFunc);
58
- });
59
- });
61
+ speccerEventFunc = debounce(function () {
62
+ speccer();
63
+ }, 300);
60
64
 
61
- useEffect(() => {
65
+ window.addEventListener('resize', speccerEventFunc);
62
66
  return () => {
63
67
  window.removeEventListener('resize', speccerEventFunc);
64
68
  };
@@ -72,7 +76,7 @@ export default Component;
72
76
 
73
77
  ### Element spacing
74
78
 
75
- ![Image of speccer](./spacing.png)
79
+ ![Image of speccer](./assets/spacing.png)
76
80
 
77
81
  In your component examples, use the following attribute:
78
82
 
@@ -84,7 +88,7 @@ This will display the element <em>and all of it's children</em> padding and marg
84
88
 
85
89
  ### Element dimensions
86
90
 
87
- ![Image of speccer](./measure.png)
91
+ ![Image of speccer](./assets/measure.png)
88
92
 
89
93
  In your component examples, use the following attribute:
90
94
 
@@ -96,7 +100,7 @@ Where `height` and `width` comes with placement flags. Default for `height` is `
96
100
 
97
101
  ### Highlight the anatomy of an element
98
102
 
99
- ![Image of speccer](./anatomy.png)
103
+ ![Image of speccer](./assets/anatomy.png)
100
104
 
101
105
  In your component examples, use the following attribute. Remember to use the `data-anatomy-section` as an attribute on a parent element to scope the marking.
102
106
 
@@ -110,7 +114,7 @@ This will place a pin to the outline of the element. Default is `top`.
110
114
 
111
115
  ### Element typogpraphy
112
116
 
113
- ![Image of speccer](./typography.png)
117
+ ![Image of speccer](./assets/typography.png)
114
118
 
115
119
  In your component examples, use the following attribute.
116
120
 
@@ -142,13 +146,13 @@ If no attribute is applied, it will default to `data-dom`, as in, it will initia
142
146
  If you're importing speccer instead of with a script tag, you can use the following approach to apply lazy loading:
143
147
 
144
148
  ```javascript
145
- import * as Dissect from '@phun-ky/speccer/src/dissect.js';
149
+ import { dissect } from '@phun-ky/speccer';
146
150
 
147
151
  let dissectElementObserver = new IntersectionObserver((entries, observer) => {
148
152
  entries.forEach(entry => {
149
153
  const targets = entry.target.querySelectorAll('[data-anatomy]');
150
154
  if (entry.intersectionRatio > 0) {
151
- targets.forEach(Dissect.element);
155
+ targets.forEach(dissect.element);
152
156
  observer.unobserve(entry.target);
153
157
  }
154
158
  });
@@ -158,3 +162,36 @@ document.querySelectorAll('[data-anatomy-section]').forEach(el => {
158
162
  dissectElementObserver.observe(el);
159
163
  });
160
164
  ```
165
+
166
+ ## Customization
167
+
168
+ You can use the provided CSS variables to customize the look and feel, to a point.
169
+
170
+ ```css
171
+ .ph.speccer {
172
+ --ph-speccer-color-padding: rgba(219, 111, 255, 0.4);
173
+ --ph-speccer-color-padding-hover: #db6fff;
174
+ --ph-speccer-color-margin: rgba(255, 247, 111, 0.4);
175
+ --ph-speccer-color-margin-hover: #fff76f;
176
+ --ph-speccer-color-text-light: #fff;
177
+ --ph-speccer-color-text-dark: #333;
178
+ --ph-speccer-color-contrast: #ff3aa8;
179
+ --ph-speccer-spacing-color: var(--ph-speccer-color-contrast);
180
+ --ph-speccer-measure-color: #f00;
181
+ --ph-speccer-pin-color: var(--ph-speccer-color-contrast);
182
+ --ph-speccer-typography-background-color: #fff;
183
+ --ph-speccer-typography-color-property: #3f85f2;
184
+ --ph-speccer-typography-color-text: #57575b;
185
+ --ph-speccer-typography-color-value: var(--ph-speccer-color-contrast);
186
+ --ph-speccer-depth-opacity-400: 0.4;
187
+ --ph-speccer-font-family: 'Menlo for Powerline', 'Menlo Regular for Powerline', 'DejaVu Sans Mono', Consolas, Monaco,
188
+ 'Andale Mono', 'Ubuntu Mono', monospace;
189
+ --ph-speccer-font-size: 12px;
190
+ --ph-speccer-line-height: 12px;
191
+ --ph-speccer-pin-size: 24px;
192
+ --ph-speccer-pin-space: 48px;
193
+ --ph-speccer-line-width: 1px;
194
+ --ph-speccer-line-width-negative: -1px;
195
+ --ph-speccer-measure-size: 8px;
196
+ }
197
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phun-ky/speccer",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
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": {
@@ -23,7 +23,49 @@
23
23
  "scripts": {
24
24
  "prerelease": "npm run build",
25
25
  "posttag": "git push --follow-tags origin master && npm publish"
26
- }
26
+ },
27
+ "types": [
28
+ {
29
+ "type": "chore",
30
+ "section": "Tasks",
31
+ "hidden": true
32
+ },
33
+ {
34
+ "type": "docs",
35
+ "section": "Documentation"
36
+ },
37
+ {
38
+ "type": "feat",
39
+ "section": "Feature"
40
+ },
41
+ {
42
+ "type": "fix",
43
+ "section": "Bug"
44
+ },
45
+ {
46
+ "type": "perf",
47
+ "section": "Performance change"
48
+ },
49
+ {
50
+ "type": "refactor",
51
+ "section": "Refactoring"
52
+ },
53
+ {
54
+ "type": "release",
55
+ "section": "Create a release commit",
56
+ "hidden": true
57
+ },
58
+ {
59
+ "type": "style",
60
+ "section": "Markup, white-space, formatting, missing semi-colons...",
61
+ "hidden": true
62
+ },
63
+ {
64
+ "type": "test",
65
+ "section": "Adding missing tests",
66
+ "hidden": true
67
+ }
68
+ ]
27
69
  },
28
70
  "repository": {
29
71
  "type": "git",
@@ -88,9 +130,7 @@
88
130
  "regenerator-runtime": "^0.13.7",
89
131
  "rollup": "^2.39.0",
90
132
  "rollup-plugin-terser": "^7.0.2",
91
- "stylus": "^0.56.0"
92
- },
93
- "dependencies": {
133
+ "stylus": "^0.56.0",
94
134
  "eslint-plugin-jsx-a11y": "^6.4.1",
95
135
  "eslint-plugin-react": "^7.23.2",
96
136
  "eslint-plugin-react-hooks": "^4.2.0"