@phun-ky/speccer 6.2.5 → 6.4.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/README.md +123 -53
- package/package.json +17 -55
- package/speccer.css +118 -49
- package/speccer.js +1 -1
- package/speccer.js.map +1 -1
- package/speccer.min.css +1 -1
package/README.md
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
1
|
-
# speccer
|
|
1
|
+
# @phun-ky/speccer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](http://commitizen.github.io/cz-cli/) [](http://makeapullrequest.com) [](http://semver.org/spec/v2.0.0.html)      
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> A zero dependency package to show specifications on components in your design system documentation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- [@phun-ky/speccer](#phun-kyspeccer)
|
|
10
|
+
- [About](#about)
|
|
11
|
+
- [Usage](#usage)
|
|
12
|
+
- [ESM](#esm)
|
|
13
|
+
- [Script](#script)
|
|
14
|
+
- [React](#react)
|
|
15
|
+
- [Advanced usage](#advanced-usage)
|
|
16
|
+
- [Lazy](#lazy)
|
|
17
|
+
- [Features](#features)
|
|
18
|
+
- [Element spacing](#element-spacing)
|
|
19
|
+
- [Element dimensions](#element-dimensions)
|
|
20
|
+
- [Subtle measure](#subtle-measure)
|
|
21
|
+
- [Highlight the anatomy of an element](#highlight-the-anatomy-of-an-element)
|
|
22
|
+
- [Subtle anatomy](#subtle-anatomy)
|
|
23
|
+
- [Curly brackets](#curly-brackets)
|
|
24
|
+
- [Element typogpraphy](#element-typogpraphy)
|
|
25
|
+
- [Mark elements](#mark-elements)
|
|
26
|
+
- [Customization](#customization)
|
|
27
|
+
|
|
28
|
+
## About
|
|
10
29
|
|
|
11
|
-
|
|
30
|
+
Speccer was created to make it easier to document components in a design system.
|
|
12
31
|
|
|
13
|
-
|
|
32
|
+
```zsh
|
|
33
|
+
npm i @phun-ky/speccer
|
|
34
|
+
```
|
|
14
35
|
|
|
15
|
-
|
|
36
|
+
See demo here: <https://codepen.io/phun-ky/pen/xaOrYX>
|
|
16
37
|
|
|
17
38
|
## Usage
|
|
18
39
|
|
|
@@ -74,9 +95,50 @@ const Component = () => {
|
|
|
74
95
|
export default Component;
|
|
75
96
|
```
|
|
76
97
|
|
|
98
|
+
## Advanced usage
|
|
99
|
+
|
|
100
|
+
If you want to control speccer a bit more, you have some options. Apply one of these attributes to the script element for different types of initialization:
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
<script src="../speccer.js" data-<manual|instant|dom|lazy></script>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
| Tag | Description |
|
|
107
|
+
| -------------- | ------------------------------------------------------------------- |
|
|
108
|
+
| `data-manual` | Makes `window.speccer()` available to be used when you feel like it |
|
|
109
|
+
| `data-instant` | fires off `speccer()` right away |
|
|
110
|
+
| `data-dom` | Waits for `DOMContentLoaded` |
|
|
111
|
+
| `data-lazy` | Lazy loads `speccer()` per specced element |
|
|
112
|
+
|
|
113
|
+
If no attribute is applied, it will default to `data-dom`, as in, it will initialize when `DOMContentLoaded` is fired.
|
|
114
|
+
|
|
115
|
+
### Lazy
|
|
116
|
+
|
|
117
|
+
If you're importing speccer instead of with a script tag, you can use the following approach to apply lazy loading:
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
import { dissect } from '@phun-ky/speccer';
|
|
121
|
+
|
|
122
|
+
let dissectElementObserver = new IntersectionObserver((entries, observer) => {
|
|
123
|
+
entries.forEach((entry) => {
|
|
124
|
+
const targets = entry.target.querySelectorAll('[data-anatomy]');
|
|
125
|
+
if (entry.intersectionRatio > 0) {
|
|
126
|
+
targets.forEach(dissect.element);
|
|
127
|
+
observer.unobserve(entry.target);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
document.querySelectorAll('[data-anatomy-section]').forEach((el) => {
|
|
133
|
+
dissectElementObserver.observe(el);
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Features
|
|
138
|
+
|
|
77
139
|
### Element spacing
|
|
78
140
|
|
|
79
|
-

|
|
80
142
|
|
|
81
143
|
In your component examples, use the following attribute:
|
|
82
144
|
|
|
@@ -84,23 +146,26 @@ In your component examples, use the following attribute:
|
|
|
84
146
|
<div data-speccer class="..."></div>
|
|
85
147
|
```
|
|
86
148
|
|
|
87
|
-
This will display the element
|
|
149
|
+
This will display the element _and all of it's children_ padding and margin.
|
|
88
150
|
|
|
89
151
|
### Element dimensions
|
|
90
152
|
|
|
91
|
-

|
|
92
154
|
|
|
93
155
|
In your component examples, use the following attribute:
|
|
94
156
|
|
|
95
157
|
```html
|
|
96
|
-
<div
|
|
158
|
+
<div
|
|
159
|
+
data-speccer-measure="[height right|left] | [width top|bottom]"
|
|
160
|
+
class="..."
|
|
161
|
+
></div>
|
|
97
162
|
```
|
|
98
163
|
|
|
99
164
|
Where `height` and `width` comes with placement flags. Default for `height` is `left`, default for `width` is `top`.
|
|
100
165
|
|
|
101
|
-
#### Subtle
|
|
166
|
+
#### Subtle measure
|
|
102
167
|
|
|
103
|
-

|
|
104
169
|
|
|
105
170
|
You can also give a more subtle touch to the measure elements.
|
|
106
171
|
|
|
@@ -112,21 +177,24 @@ This will give a dashed border.
|
|
|
112
177
|
|
|
113
178
|
### Highlight the anatomy of an element
|
|
114
179
|
|
|
115
|
-

|
|
116
181
|
|
|
117
182
|
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.
|
|
118
183
|
|
|
119
184
|
```html
|
|
120
185
|
<div data-anatomy-section>
|
|
121
|
-
<div
|
|
186
|
+
<div
|
|
187
|
+
data-anatomy="outline [full|enclose][curly] [left|right|top|bottom]"
|
|
188
|
+
class="..."
|
|
189
|
+
></div>
|
|
122
190
|
</div>
|
|
123
191
|
```
|
|
124
192
|
|
|
125
193
|
This will place a pin to the outline of the element. Default is `top`.
|
|
126
194
|
|
|
127
|
-
#### Subtle
|
|
195
|
+
#### Subtle anatomy
|
|
128
196
|
|
|
129
|
-

|
|
130
198
|
|
|
131
199
|
You can also give a more subtle touch to the anatomy elements.
|
|
132
200
|
|
|
@@ -136,62 +204,63 @@ You can also give a more subtle touch to the anatomy elements.
|
|
|
136
204
|
</div>
|
|
137
205
|
```
|
|
138
206
|
|
|
139
|
-
|
|
207
|
+
### Curly brackets
|
|
140
208
|
|
|
141
|
-
|
|
209
|
+
You can use curly brackets with the `curly` tag in `data-anatomy` along side `outline full` to provide a more sleek look to the style.
|
|
142
210
|
|
|
143
|
-
!
|
|
211
|
+
> [!NOTE]
|
|
212
|
+
> Only works with `outline full`
|
|
144
213
|
|
|
145
|
-
|
|
214
|
+
The curly brackets are made with SVG paths, and it is required to have the following snippet on your page for it to render:
|
|
146
215
|
|
|
147
216
|
```html
|
|
148
|
-
<
|
|
217
|
+
<svg
|
|
218
|
+
class="ph"
|
|
219
|
+
viewBox="0 0"
|
|
220
|
+
id="ph-speccer-svg"
|
|
221
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
222
|
+
>
|
|
223
|
+
<path
|
|
224
|
+
class="ph path original"
|
|
225
|
+
id="ph-speccer-path"
|
|
226
|
+
fill="none"
|
|
227
|
+
stroke-width="1"
|
|
228
|
+
stroke="currentColor"
|
|
229
|
+
/>
|
|
230
|
+
</svg>
|
|
149
231
|
```
|
|
150
232
|
|
|
151
|
-
This will
|
|
233
|
+
This will give a dashed border, and a more subtle pin style.
|
|
152
234
|
|
|
153
|
-
|
|
235
|
+
### Element typogpraphy
|
|
154
236
|
|
|
155
|
-
|
|
237
|
+

|
|
238
|
+
|
|
239
|
+
In your component examples, use the following attribute.
|
|
156
240
|
|
|
157
241
|
```html
|
|
158
|
-
<
|
|
242
|
+
<div data-speccer-typography="[left|right|top|bottom]" class="...">
|
|
243
|
+
Some text
|
|
244
|
+
</div>
|
|
159
245
|
```
|
|
160
246
|
|
|
161
|
-
|
|
162
|
-
| -------------- | ------------------------------------------------------------------- |
|
|
163
|
-
| `data-manual` | Makes `window.speccer()` available to be used when you feel like it |
|
|
164
|
-
| `data-instant` | fires off `speccer()` right away |
|
|
165
|
-
| `data-dom` | Waits for `DOMContentLoaded` |
|
|
166
|
-
| `data-lazy` | Lazy loads `speccer()` per specced element |
|
|
167
|
-
|
|
168
|
-
If no attribute is applied, it will default to `data-dom`, as in, it will initialize when `DOMContentLoaded` is fired.
|
|
247
|
+
This will place a box to display typography information. Default is `left`.
|
|
169
248
|
|
|
170
|
-
###
|
|
249
|
+
### Mark elements
|
|
171
250
|
|
|
172
|
-
|
|
251
|
+

|
|
173
252
|
|
|
174
|
-
|
|
175
|
-
import { dissect } from '@phun-ky/speccer';
|
|
253
|
+
This will mark the given elements.
|
|
176
254
|
|
|
177
|
-
|
|
178
|
-
entries.forEach((entry) => {
|
|
179
|
-
const targets = entry.target.querySelectorAll('[data-anatomy]');
|
|
180
|
-
if (entry.intersectionRatio > 0) {
|
|
181
|
-
targets.forEach(dissect.element);
|
|
182
|
-
observer.unobserve(entry.target);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
255
|
+
In your component examples, use the following attribute.
|
|
186
256
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
257
|
+
```html
|
|
258
|
+
<div data-speccer-mark …>…</div>
|
|
190
259
|
```
|
|
191
260
|
|
|
192
261
|
## Customization
|
|
193
262
|
|
|
194
|
-

|
|
195
264
|
|
|
196
265
|
Allthough the styling works nicely with dark mode, you can use the provided CSS variables to customize the look and feel. If more control is needed, you can use CSS overrides :)
|
|
197
266
|
|
|
@@ -212,7 +281,8 @@ Allthough the styling works nicely with dark mode, you can use the provided CSS
|
|
|
212
281
|
--ph-speccer-typography-color-text: #57575b;
|
|
213
282
|
--ph-speccer-typography-color-value: var(--ph-speccer-color-contrast);
|
|
214
283
|
--ph-speccer-depth-opacity-400: 0.4;
|
|
215
|
-
--ph-speccer-font-family: 'Menlo for Powerline',
|
|
284
|
+
--ph-speccer-font-family: 'Menlo for Powerline',
|
|
285
|
+
'Menlo Regular for Powerline', 'DejaVu Sans Mono', Consolas, Monaco,
|
|
216
286
|
'Andale Mono', 'Ubuntu Mono', monospace;
|
|
217
287
|
--ph-speccer-font-size: 12px;
|
|
218
288
|
--ph-speccer-line-height: 12px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phun-ky/speccer",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.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": {
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
11
|
"rollup": "rollup -c",
|
|
12
|
-
"prerollup:dev": "npm run clean && npm run
|
|
12
|
+
"prerollup:dev": "npm run clean && npm run styles",
|
|
13
13
|
"rollup:dev": "rollup -c -w",
|
|
14
14
|
"clean": "rm -rf dist/ dts/ ./speccer.css ./speccer.min.css ./speccer.js",
|
|
15
|
-
"build": "npm run clean && npm run rollup && npm run
|
|
15
|
+
"build": "npm run clean && npm run rollup && npm run styles",
|
|
16
16
|
"styles": "npm run stylus && npm run postcss",
|
|
17
17
|
"stylus": "rm -rf ./speccer.css && stylus ./src/styles/index.styl -o ./speccer.css",
|
|
18
18
|
"postcss": "rm -rf ./speccer.min.css && postcss ./speccer.css -o speccer.min.css",
|
|
19
|
-
"dev": "npx browser-sync start --server --files \"dev/*.html\" --index \"dev/index.html\" --serveStatic \"/dev/*.html\"",
|
|
19
|
+
"dev": "npx browser-sync start --server --files \"dev/*.html\" \"*.css\" --index \"dev/index.html\" --serveStatic \"/dev/*.html\"",
|
|
20
20
|
"commit": "npx git-cz",
|
|
21
|
-
"release": "
|
|
21
|
+
"release": "release-it"
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"/speccer.js",
|
|
@@ -26,54 +26,6 @@
|
|
|
26
26
|
"/speccer.min.css",
|
|
27
27
|
"/speccer.css"
|
|
28
28
|
],
|
|
29
|
-
"standard-version": {
|
|
30
|
-
"scripts": {
|
|
31
|
-
"prerelease": "npm run build && git add .",
|
|
32
|
-
"posttag": "git push --follow-tags origin master"
|
|
33
|
-
},
|
|
34
|
-
"types": [
|
|
35
|
-
{
|
|
36
|
-
"type": "chore",
|
|
37
|
-
"section": "Tasks",
|
|
38
|
-
"hidden": true
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"type": "docs",
|
|
42
|
-
"section": "Documentation"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"type": "feat",
|
|
46
|
-
"section": "Feature"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"type": "fix",
|
|
50
|
-
"section": "Bug"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"type": "perf",
|
|
54
|
-
"section": "Performance change"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"type": "refactor",
|
|
58
|
-
"section": "Refactoring"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"type": "release",
|
|
62
|
-
"section": "Create a release commit",
|
|
63
|
-
"hidden": true
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"type": "style",
|
|
67
|
-
"section": "Markup, white-space, formatting, missing semi-colons...",
|
|
68
|
-
"hidden": true
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"type": "test",
|
|
72
|
-
"section": "Adding missing tests",
|
|
73
|
-
"hidden": true
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
},
|
|
77
29
|
"repository": {
|
|
78
30
|
"type": "git",
|
|
79
31
|
"url": "git+https://github.com/phun-ky/speccer.git"
|
|
@@ -81,6 +33,8 @@
|
|
|
81
33
|
"keywords": [
|
|
82
34
|
"html",
|
|
83
35
|
"css",
|
|
36
|
+
"design",
|
|
37
|
+
"design system",
|
|
84
38
|
"javascript",
|
|
85
39
|
"spec",
|
|
86
40
|
"inspect",
|
|
@@ -107,6 +61,7 @@
|
|
|
107
61
|
},
|
|
108
62
|
"homepage": "https://github.com/phun-ky/speccer#readme",
|
|
109
63
|
"devDependencies": {
|
|
64
|
+
"@release-it/conventional-changelog": "^7.0.1",
|
|
110
65
|
"@rollup/plugin-commonjs": "^17.1.0",
|
|
111
66
|
"@rollup/plugin-node-resolve": "^11.2.0",
|
|
112
67
|
"@testing-library/dom": "^7.29.4",
|
|
@@ -124,18 +79,25 @@
|
|
|
124
79
|
"eslint-plugin-prettier": "^4.0.0",
|
|
125
80
|
"eslint-plugin-react": "^7.23.2",
|
|
126
81
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
82
|
+
"git-cz": "^4.9.0",
|
|
127
83
|
"jest": "^26.6.3",
|
|
128
84
|
"network-information-types": "^0.1.1",
|
|
129
85
|
"postcss": "^8.3.0",
|
|
130
86
|
"postcss-cli": "^8.3.1",
|
|
131
87
|
"prettier": "^2.4.1",
|
|
132
88
|
"prettier-eslint": "^13.0.0",
|
|
89
|
+
"release-it": "^16.1.5",
|
|
133
90
|
"rollup": "^2.39.0",
|
|
134
91
|
"rollup-plugin-dts": "^4.0.1",
|
|
135
92
|
"rollup-plugin-terser": "^7.0.2",
|
|
136
|
-
"rollup-plugin-typescript2": "^0.
|
|
137
|
-
"stylus": "^0.
|
|
93
|
+
"rollup-plugin-typescript2": "^0.35.0",
|
|
94
|
+
"stylus": "^0.60.0",
|
|
138
95
|
"tslib": "^2.3.1",
|
|
139
96
|
"typescript": "^4.5.4"
|
|
97
|
+
},
|
|
98
|
+
"config": {
|
|
99
|
+
"commitizen": {
|
|
100
|
+
"path": "./node_modules/git-cz"
|
|
101
|
+
}
|
|
140
102
|
}
|
|
141
103
|
}
|