@phun-ky/speccer 3.5.1 → 4.1.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 +9 -0
- package/README.md +15 -43
- package/package.json +70 -32
- package/speccer.css +614 -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/{anatomy.styl → styles/anatomy.styl} +59 -73
- package/src/styles/index.styl +26 -0
- package/src/styles/measure.styl +85 -0
- package/src/styles/spacing.styl +142 -0
- package/src/{typography.styl → styles/typography.styl} +1 -1
- package/src/typography.js +138 -0
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
.dissection
|
|
1
|
+
.ph.speccer.dissection
|
|
2
|
+
font-family sans-serif
|
|
2
3
|
height 1.5rem
|
|
3
4
|
width 1.5rem
|
|
4
5
|
display flex
|
|
@@ -6,14 +7,15 @@
|
|
|
6
7
|
border-radius 100%
|
|
7
8
|
background-color #d4397a
|
|
8
9
|
color white
|
|
9
|
-
font-weight
|
|
10
|
+
font-weight 400
|
|
10
11
|
align-items center
|
|
11
12
|
justify-content center
|
|
12
13
|
line-height 150%
|
|
13
14
|
font-size 16px
|
|
14
15
|
z-index 100000
|
|
16
|
+
box-sizing content-box
|
|
15
17
|
|
|
16
|
-
.dissection:after
|
|
18
|
+
.ph.speccer.dissection:after
|
|
17
19
|
content ""
|
|
18
20
|
position absolute
|
|
19
21
|
height 48px
|
|
@@ -23,32 +25,32 @@
|
|
|
23
25
|
z-index 99999
|
|
24
26
|
|
|
25
27
|
|
|
26
|
-
.dissection.outline:after,
|
|
27
|
-
.dissection.outline.top:after
|
|
28
|
+
.ph.speccer.dissection.outline:after,
|
|
29
|
+
.ph.speccer.dissection.outline.top:after
|
|
28
30
|
height 48px
|
|
29
31
|
width 1px
|
|
30
32
|
top 100%
|
|
31
33
|
right 50%
|
|
32
34
|
|
|
33
|
-
.dissection.outline.left:after
|
|
35
|
+
.ph.speccer.dissection.outline.left:after
|
|
34
36
|
height 1px
|
|
35
37
|
width 48px
|
|
36
38
|
top 50%
|
|
37
39
|
left 100%
|
|
38
40
|
|
|
39
|
-
.dissection.outline.right:after
|
|
41
|
+
.ph.speccer.dissection.outline.right:after
|
|
40
42
|
height 1px
|
|
41
43
|
width 48px
|
|
42
44
|
top 50%
|
|
43
45
|
right 100%
|
|
44
46
|
|
|
45
|
-
.dissection.outline.bottom:after
|
|
47
|
+
.ph.speccer.dissection.outline.bottom:after
|
|
46
48
|
height 48px
|
|
47
49
|
width 1px
|
|
48
50
|
top calc(-100% - 24px)
|
|
49
51
|
right 50%
|
|
50
52
|
|
|
51
|
-
.dissection.button-center:after
|
|
53
|
+
.ph.speccer.dissection.button-center:after
|
|
52
54
|
content ""
|
|
53
55
|
position absolute
|
|
54
56
|
height 48px
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
background-color #d4397a
|
|
58
60
|
z-index 99999
|
|
59
61
|
|
|
60
|
-
.dissection.button-outline:after
|
|
62
|
+
.ph.speccer.dissection.button-outline:after
|
|
61
63
|
content ""
|
|
62
64
|
position absolute
|
|
63
65
|
width 48px
|
|
@@ -67,7 +69,7 @@
|
|
|
67
69
|
background-color #d4397a
|
|
68
70
|
z-index 99999
|
|
69
71
|
|
|
70
|
-
.dissection.button-icon:after
|
|
72
|
+
.ph.speccer.dissection.button-icon:after
|
|
71
73
|
content ""
|
|
72
74
|
position absolute
|
|
73
75
|
width 48px
|
|
@@ -77,7 +79,7 @@
|
|
|
77
79
|
background-color #d4397a
|
|
78
80
|
z-index 99999
|
|
79
81
|
|
|
80
|
-
.dissection.button-icon:before
|
|
82
|
+
.ph.speccer.dissection.button-icon:before
|
|
81
83
|
content ""
|
|
82
84
|
position absolute
|
|
83
85
|
height 1.5rem
|
|
@@ -87,21 +89,7 @@
|
|
|
87
89
|
z-index 99999
|
|
88
90
|
|
|
89
91
|
|
|
90
|
-
.dissection
|
|
91
|
-
height 1.5rem
|
|
92
|
-
width 1.5rem
|
|
93
|
-
display flex
|
|
94
|
-
position absolute
|
|
95
|
-
border-radius 100%
|
|
96
|
-
background-color #d4397a
|
|
97
|
-
color #fff
|
|
98
|
-
font-weight 600
|
|
99
|
-
align-items center
|
|
100
|
-
justify-content center
|
|
101
|
-
line-height 150%
|
|
102
|
-
font-size 16px
|
|
103
|
-
z-index 100000
|
|
104
|
-
box-sizing: content-box;
|
|
92
|
+
.ph.speccer.dissection
|
|
105
93
|
&:after
|
|
106
94
|
content ""
|
|
107
95
|
position absolute
|
|
@@ -215,8 +203,8 @@
|
|
|
215
203
|
border 1px solid #d4397a
|
|
216
204
|
z-index 99999
|
|
217
205
|
|
|
218
|
-
.dissection.outline.top:after,
|
|
219
|
-
.dissection.outline:after
|
|
206
|
+
.ph.speccer.dissection.outline.top:after,
|
|
207
|
+
.ph.speccer.dissection.outline:after
|
|
220
208
|
height 48px
|
|
221
209
|
width 1px
|
|
222
210
|
top 100%
|
|
@@ -225,18 +213,18 @@
|
|
|
225
213
|
[data-anatomy-section]
|
|
226
214
|
counter-reset type
|
|
227
215
|
|
|
228
|
-
.dissection.outline.full.right,
|
|
229
|
-
.dissection.outline.full.left
|
|
216
|
+
.ph.speccer.dissection.outline.full.right,
|
|
217
|
+
.ph.speccer.dissection.outline.full.left
|
|
230
218
|
width 8px
|
|
231
219
|
|
|
232
|
-
.dissection.outline.full.top,
|
|
233
|
-
.dissection.outline.full.bottom
|
|
220
|
+
.ph.speccer.dissection.outline.full.top,
|
|
221
|
+
.ph.speccer.dissection.outline.full.bottom
|
|
234
222
|
height 8px
|
|
235
223
|
|
|
236
|
-
.dissection.outline.full.right:after,
|
|
237
|
-
.dissection.outline.full.left:after,
|
|
238
|
-
.dissection.outline.full.top:after,
|
|
239
|
-
.dissection.outline.full.bottom:after
|
|
224
|
+
.ph.speccer.dissection.outline.full.right:after,
|
|
225
|
+
.ph.speccer.dissection.outline.full.left:after,
|
|
226
|
+
.ph.speccer.dissection.outline.full.top:after,
|
|
227
|
+
.ph.speccer.dissection.outline.full.bottom:after
|
|
240
228
|
content attr(data-dissection-counter)
|
|
241
229
|
height 1.5rem
|
|
242
230
|
width 1.5rem
|
|
@@ -245,59 +233,58 @@
|
|
|
245
233
|
border-radius 100%
|
|
246
234
|
background-color #d4397a
|
|
247
235
|
color #fff
|
|
248
|
-
font-weight 600
|
|
249
236
|
align-items center
|
|
250
237
|
justify-content center
|
|
251
238
|
line-height 150%
|
|
252
239
|
font-size 16px
|
|
253
240
|
z-index 100000
|
|
254
241
|
|
|
255
|
-
.dissection.outline.full.right:after,
|
|
256
|
-
.dissection.outline.full.left:after
|
|
242
|
+
.ph.speccer.dissection.outline.full.right:after,
|
|
243
|
+
.ph.speccer.dissection.outline.full.left:after
|
|
257
244
|
top 50%
|
|
258
245
|
transform translateY(-50%)
|
|
259
246
|
|
|
260
|
-
.dissection.outline.full.top:after,
|
|
261
|
-
.dissection.outline.full.bottom:after
|
|
247
|
+
.ph.speccer.dissection.outline.full.top:after,
|
|
248
|
+
.ph.speccer.dissection.outline.full.bottom:after
|
|
262
249
|
left 50%
|
|
263
250
|
transform translateX(-50%)
|
|
264
251
|
|
|
265
|
-
.dissection.outline.full.right:before,
|
|
266
|
-
.dissection.outline.full.left:before,
|
|
267
|
-
.dissection.outline.full.top:before,
|
|
268
|
-
.dissection.outline.full.bottom:before
|
|
252
|
+
.ph.speccer.dissection.outline.full.right:before,
|
|
253
|
+
.ph.speccer.dissection.outline.full.left:before,
|
|
254
|
+
.ph.speccer.dissection.outline.full.top:before,
|
|
255
|
+
.ph.speccer.dissection.outline.full.bottom:before
|
|
269
256
|
content ""
|
|
270
257
|
position absolute
|
|
271
258
|
background-color #d4397a
|
|
272
259
|
z-index 100000
|
|
273
260
|
display block
|
|
274
261
|
|
|
275
|
-
.dissection.outline.full.right:before,
|
|
276
|
-
.dissection.outline.full.left:before
|
|
262
|
+
.ph.speccer.dissection.outline.full.right:before,
|
|
263
|
+
.ph.speccer.dissection.outline.full.left:before
|
|
277
264
|
top 50%
|
|
278
265
|
transform translateY(-50%)
|
|
279
266
|
height 1px
|
|
280
267
|
width 49px
|
|
281
268
|
|
|
282
|
-
.dissection.outline.full.top:before,
|
|
283
|
-
.dissection.outline.full.bottom:before
|
|
269
|
+
.ph.speccer.dissection.outline.full.top:before,
|
|
270
|
+
.ph.speccer.dissection.outline.full.bottom:before
|
|
284
271
|
left 50%
|
|
285
272
|
transform translateX(-50%)
|
|
286
273
|
width 1px
|
|
287
274
|
height 49px
|
|
288
275
|
|
|
289
|
-
.dissection.outline.enclose.right,
|
|
290
|
-
.dissection.outline.enclose.left
|
|
276
|
+
.ph.speccer.dissection.outline.enclose.right,
|
|
277
|
+
.ph.speccer.dissection.outline.enclose.left
|
|
291
278
|
width 8px
|
|
292
279
|
|
|
293
|
-
.dissection.outline.enclose.top,
|
|
294
|
-
.dissection.outline.enclose.bottom
|
|
280
|
+
.ph.speccer.dissection.outline.enclose.top,
|
|
281
|
+
.ph.speccer.dissection.outline.enclose.bottom
|
|
295
282
|
height 8px
|
|
296
283
|
|
|
297
|
-
.dissection.outline.enclose.right:after,
|
|
298
|
-
.dissection.outline.enclose.left:after,
|
|
299
|
-
.dissection.outline.enclose.top:after,
|
|
300
|
-
.dissection.outline.enclose.bottom:after
|
|
284
|
+
.ph.speccer.dissection.outline.enclose.right:after,
|
|
285
|
+
.ph.speccer.dissection.outline.enclose.left:after,
|
|
286
|
+
.ph.speccer.dissection.outline.enclose.top:after,
|
|
287
|
+
.ph.speccer.dissection.outline.enclose.bottom:after
|
|
301
288
|
content attr(data-dissection-counter)
|
|
302
289
|
height 1.5rem
|
|
303
290
|
width 1.5rem
|
|
@@ -306,49 +293,48 @@
|
|
|
306
293
|
border-radius 100%
|
|
307
294
|
background-color #d4397a
|
|
308
295
|
color #fff
|
|
309
|
-
font-weight 600
|
|
310
296
|
align-items center
|
|
311
297
|
justify-content center
|
|
312
298
|
line-height 150%
|
|
313
299
|
font-size 16px
|
|
314
300
|
z-index 100000
|
|
315
301
|
|
|
316
|
-
.dissection.outline.enclose.right:after,
|
|
317
|
-
.dissection.outline.enclose.left:after
|
|
302
|
+
.ph.speccer.dissection.outline.enclose.right:after,
|
|
303
|
+
.ph.speccer.dissection.outline.enclose.left:after
|
|
318
304
|
top 50%
|
|
319
305
|
transform translateY(-50%)
|
|
320
306
|
|
|
321
|
-
.dissection.outline.enclose.top:after,
|
|
322
|
-
.dissection.outline.enclose.bottom:after
|
|
307
|
+
.ph.speccer.dissection.outline.enclose.top:after,
|
|
308
|
+
.ph.speccer.dissection.outline.enclose.bottom:after
|
|
323
309
|
left 50%
|
|
324
310
|
transform translateX(-50%)
|
|
325
311
|
|
|
326
|
-
.dissection.outline.enclose.right:before,
|
|
327
|
-
.dissection.outline.enclose.left:before,
|
|
328
|
-
.dissection.outline.enclose.top:before,
|
|
329
|
-
.dissection.outline.enclose.bottom:before
|
|
312
|
+
.ph.speccer.dissection.outline.enclose.right:before,
|
|
313
|
+
.ph.speccer.dissection.outline.enclose.left:before,
|
|
314
|
+
.ph.speccer.dissection.outline.enclose.top:before,
|
|
315
|
+
.ph.speccer.dissection.outline.enclose.bottom:before
|
|
330
316
|
content ""
|
|
331
317
|
position absolute
|
|
332
318
|
background-color #d4397a
|
|
333
319
|
z-index 100000
|
|
334
320
|
display block
|
|
335
321
|
|
|
336
|
-
.dissection.outline.enclose.right:before,
|
|
337
|
-
.dissection.outline.enclose.left:before
|
|
322
|
+
.ph.speccer.dissection.outline.enclose.right:before,
|
|
323
|
+
.ph.speccer.dissection.outline.enclose.left:before
|
|
338
324
|
top 50%
|
|
339
325
|
transform translateY(-50%)
|
|
340
326
|
height 1px
|
|
341
327
|
width 49px
|
|
342
328
|
|
|
343
|
-
.dissection.outline.enclose.top:before,
|
|
344
|
-
.dissection.outline.enclose.bottom:before
|
|
329
|
+
.ph.speccer.dissection.outline.enclose.top:before,
|
|
330
|
+
.ph.speccer.dissection.outline.enclose.bottom:before
|
|
345
331
|
left 50%
|
|
346
332
|
transform translateX(-50%)
|
|
347
333
|
width 1px
|
|
348
334
|
height 49px
|
|
349
335
|
|
|
350
|
-
.dissection.button-icon:after,
|
|
351
|
-
.dissection.button-outline:after
|
|
336
|
+
.ph.speccer.dissection.button-icon:after,
|
|
337
|
+
.ph.speccer.dissection.button-outline:after
|
|
352
338
|
content ""
|
|
353
339
|
position absolute
|
|
354
340
|
width 48px
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
$ph-speccer-color-padding = rgb(219, 111, 255);
|
|
2
|
+
$ph-speccer-color-margin = rgb(255, 247, 111);
|
|
3
|
+
$ph-speccer-color-text-light = rgb(255, 255, 255);
|
|
4
|
+
$ph-speccer-color-text-dark = rgb(51, 51, 51);
|
|
5
|
+
$ph-speccer-color-border-dark = rgb(51, 51, 51);
|
|
6
|
+
$ph-speccer-color-text-pink = rgb(255, 58, 168);
|
|
7
|
+
$ph-speccer-color-border-pink = rgb(255, 58, 168);
|
|
8
|
+
$ph-speccer-depth-opacity-400 = 0.4;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
.ph.speccer,
|
|
12
|
+
.ph.speccer::after,
|
|
13
|
+
.ph.speccer::before
|
|
14
|
+
font-family "Menlo for Powerline", "Menlo Regular for Powerline", "DejaVu Sans Mono", Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace !important
|
|
15
|
+
justify-content center
|
|
16
|
+
align-items center
|
|
17
|
+
z-index 99999
|
|
18
|
+
position absolute
|
|
19
|
+
display flex
|
|
20
|
+
font-size 12px
|
|
21
|
+
box-sizing border-box
|
|
22
|
+
transition all 0.2s ease-in
|
|
23
|
+
line-height 12px
|
|
24
|
+
|
|
25
|
+
@require './anatomy.styl'
|
|
26
|
+
@require './spacing.styl'
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
.ph.speccer.measure
|
|
2
|
+
&.width
|
|
3
|
+
color red
|
|
4
|
+
border 1px solid red
|
|
5
|
+
border-bottom none
|
|
6
|
+
height 8px
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
.ph.speccer.measure
|
|
10
|
+
&.width
|
|
11
|
+
&::after
|
|
12
|
+
content attr(data-measure)
|
|
13
|
+
position absolute
|
|
14
|
+
top calc(-100% - 10px)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
.ph.speccer.measure
|
|
18
|
+
&.width
|
|
19
|
+
&.bottom
|
|
20
|
+
color red
|
|
21
|
+
border 1px solid red
|
|
22
|
+
border-top none
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
.ph.speccer.measure
|
|
26
|
+
&.width
|
|
27
|
+
&.bottom
|
|
28
|
+
&::after
|
|
29
|
+
content attr(data-measure)
|
|
30
|
+
position absolute
|
|
31
|
+
top calc(100% + 5px)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
.ph.speccer.measure
|
|
35
|
+
&.width
|
|
36
|
+
&.top
|
|
37
|
+
color red
|
|
38
|
+
border 1px solid red
|
|
39
|
+
border-bottom none
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
.ph.speccer.measure
|
|
43
|
+
&.width
|
|
44
|
+
&.top
|
|
45
|
+
&::after
|
|
46
|
+
content attr(data-measure)
|
|
47
|
+
position absolute
|
|
48
|
+
bottom calc(100% + 5px)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
.ph.speccer.measure
|
|
52
|
+
&.height
|
|
53
|
+
color red
|
|
54
|
+
border 1px solid red
|
|
55
|
+
border-right none
|
|
56
|
+
width 8px
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
.ph.speccer.measure
|
|
60
|
+
&.height
|
|
61
|
+
&::after
|
|
62
|
+
content attr(data-measure)
|
|
63
|
+
position absolute
|
|
64
|
+
top 50%
|
|
65
|
+
left calc(-100% - 25px)
|
|
66
|
+
transform translateY(-50%) rotate(-90deg)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
.ph.speccer.measure
|
|
70
|
+
&.height
|
|
71
|
+
&.right
|
|
72
|
+
color red
|
|
73
|
+
border 1px solid red
|
|
74
|
+
border-left none
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
.ph.speccer.measure
|
|
78
|
+
&.height
|
|
79
|
+
&.right
|
|
80
|
+
&::after
|
|
81
|
+
content attr(data-measure)
|
|
82
|
+
position absolute
|
|
83
|
+
top 50%
|
|
84
|
+
left 100%
|
|
85
|
+
transform translateY(-50%) rotate(90deg)
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
.ph.speccer.spacing
|
|
2
|
+
&:hover
|
|
3
|
+
border 1px solid $ph-speccer-color-border-dark
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.ph.speccer.spacing
|
|
7
|
+
&.is-specced
|
|
8
|
+
&:hover
|
|
9
|
+
& ~ .speccer
|
|
10
|
+
&.margin
|
|
11
|
+
background-color $ph-speccer-color-margin
|
|
12
|
+
&.padding
|
|
13
|
+
background-color $ph-speccer-color-padding
|
|
14
|
+
color $ph-speccer-color-text-light
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
.ph.speccer.spacing
|
|
18
|
+
&.margin
|
|
19
|
+
background-color rgba($ph-speccer-color-margin, .4)
|
|
20
|
+
color $ph-speccer-color-text-dark
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
.ph.speccer.spacing
|
|
24
|
+
&.padding
|
|
25
|
+
background-color rgba($ph-speccer-color-padding, .4)
|
|
26
|
+
color $ph-speccer-color-text-pink
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
.ph.speccer.spacing
|
|
30
|
+
&.margin
|
|
31
|
+
&.bottom,
|
|
32
|
+
&.top
|
|
33
|
+
&:after
|
|
34
|
+
content ""
|
|
35
|
+
position absolute
|
|
36
|
+
height 100%
|
|
37
|
+
border-top 1px solid $ph-speccer-color-border-dark
|
|
38
|
+
border-bottom 1px solid $ph-speccer-color-border-dark
|
|
39
|
+
width 9px
|
|
40
|
+
left 40%
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
.ph.speccer.spacing
|
|
44
|
+
&.margin
|
|
45
|
+
&.bottom,
|
|
46
|
+
&.top
|
|
47
|
+
&:before
|
|
48
|
+
content ""
|
|
49
|
+
position absolute
|
|
50
|
+
height 100%
|
|
51
|
+
border-left 1px solid $ph-speccer-color-border-dark
|
|
52
|
+
margin-left 4px
|
|
53
|
+
width 0
|
|
54
|
+
left 40%
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
.ph.speccer.spacing
|
|
58
|
+
&.margin
|
|
59
|
+
&.left,
|
|
60
|
+
&.right
|
|
61
|
+
&:after
|
|
62
|
+
content ""
|
|
63
|
+
position absolute
|
|
64
|
+
height 9px
|
|
65
|
+
border-right 1px solid $ph-speccer-color-border-pink
|
|
66
|
+
border-left 1px solid $ph-speccer-color-border-pink
|
|
67
|
+
width 100%
|
|
68
|
+
top 10%
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
.ph.speccer.spacing
|
|
72
|
+
&.margin
|
|
73
|
+
&.left,
|
|
74
|
+
&.right
|
|
75
|
+
&:before
|
|
76
|
+
content ""
|
|
77
|
+
position absolute
|
|
78
|
+
height 0
|
|
79
|
+
border-top 1px solid $ph-speccer-color-border-pink
|
|
80
|
+
margin-top 4px
|
|
81
|
+
width 100%
|
|
82
|
+
top 10%
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
.ph.speccer.spacing
|
|
86
|
+
&.padding
|
|
87
|
+
&.bottom,
|
|
88
|
+
&.top
|
|
89
|
+
&:after
|
|
90
|
+
content ""
|
|
91
|
+
position absolute
|
|
92
|
+
height 100%
|
|
93
|
+
border-top 1px solid $ph-speccer-color-border-pink
|
|
94
|
+
border-bottom 1px solid $ph-speccer-color-border-pink
|
|
95
|
+
width 9px
|
|
96
|
+
left 40%
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
.ph.speccer.spacing
|
|
100
|
+
&.padding
|
|
101
|
+
&.bottom,
|
|
102
|
+
&.top
|
|
103
|
+
&:before
|
|
104
|
+
content ""
|
|
105
|
+
position absolute
|
|
106
|
+
height 100%
|
|
107
|
+
border-left 1px solid $ph-speccer-color-border-pink
|
|
108
|
+
margin-left 4px
|
|
109
|
+
width 0
|
|
110
|
+
left 40%
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
.ph.speccer.spacing
|
|
114
|
+
&.padding
|
|
115
|
+
&.left,
|
|
116
|
+
&.right
|
|
117
|
+
&:after
|
|
118
|
+
content ""
|
|
119
|
+
position absolute
|
|
120
|
+
height 9px
|
|
121
|
+
border-right 1px solid $ph-speccer-color-border-pink
|
|
122
|
+
border-left 1px solid $ph-speccer-color-border-pink
|
|
123
|
+
width 100%
|
|
124
|
+
top 10%
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
.ph.speccer.spacing
|
|
128
|
+
&.padding
|
|
129
|
+
&.left,
|
|
130
|
+
&.right
|
|
131
|
+
&:before
|
|
132
|
+
content ""
|
|
133
|
+
position absolute
|
|
134
|
+
height 0
|
|
135
|
+
border-top 1px solid $ph-speccer-color-border-pink
|
|
136
|
+
margin-top 4px
|
|
137
|
+
width 100%
|
|
138
|
+
top 10%
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@require './typography.styl'
|
|
142
|
+
@require './measure.styl'
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/* eslint no-console:0 */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
import * as classnames from './lib/classnames';
|
|
5
|
+
import * as number from './lib/number';
|
|
6
|
+
import * as styles from './lib/styles';
|
|
7
|
+
import * as node from './lib/node';
|
|
8
|
+
import * as css from './lib/css';
|
|
9
|
+
import { SPECCER_TAGS_TO_AVOID } from './lib/constants';
|
|
10
|
+
|
|
11
|
+
export const create = (html, area) => {
|
|
12
|
+
const _el = document.createElement('div');
|
|
13
|
+
_el.innerHTML = html;
|
|
14
|
+
|
|
15
|
+
classnames.set(_el, `ph speccer typography ${area}`);
|
|
16
|
+
return _el;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const element = async el => {
|
|
20
|
+
const _area = el.getAttribute('data-speccer-typography');
|
|
21
|
+
const _el_style = await styles.get(el);
|
|
22
|
+
|
|
23
|
+
if (_el_style.display === 'none' || _el_style.visibility === 'hidden') {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
el.classList.add('is-specced');
|
|
28
|
+
const _parent_style = styles.get(el.parentElement);
|
|
29
|
+
|
|
30
|
+
if (_parent_style.position === 'static') {
|
|
31
|
+
window.requestAnimationFrame(() => {
|
|
32
|
+
el.parentElement.style.position = 'relative';
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const _styles = css.getTypography(_el_style);
|
|
37
|
+
const _el_rect = el.getBoundingClientRect();
|
|
38
|
+
|
|
39
|
+
const html =
|
|
40
|
+
`
|
|
41
|
+
` +
|
|
42
|
+
'font-styles: {' +
|
|
43
|
+
'<ul class="speccer-styles">' +
|
|
44
|
+
` <li><span class="property">font-family:</span> ${_styles['fontFamily']};</li>` +
|
|
45
|
+
` <li><span class="property">font-size:</span> ${_styles['fontSize']} / ${
|
|
46
|
+
parseInt(_styles['fontSize'], 10) / 16
|
|
47
|
+
}rem;</li>` +
|
|
48
|
+
` <li><span class="property">font-weight:</span> ${_styles['fontWeight']};</li>` +
|
|
49
|
+
` <li><span class="property">font-variation-settings:</span> ${_styles['fontVariationSettings']};</li>` +
|
|
50
|
+
` <li><span class="property">line-height:</span> ${_styles['lineHeight']} / ${
|
|
51
|
+
parseInt(_styles['lineHeight'], 10) / 16
|
|
52
|
+
}rem;</li>` +
|
|
53
|
+
` <li><span class="property">letter-spacing:</span> ${_styles['letterSpacing']};</li>` +
|
|
54
|
+
` <li><span class="property">font-style:</span> ${_styles['fontStyle']};</li>` +
|
|
55
|
+
'</ul>' +
|
|
56
|
+
'}';
|
|
57
|
+
const speccerNode = create(html, _area);
|
|
58
|
+
|
|
59
|
+
let tableCorrectionTop = 0;
|
|
60
|
+
let tableCorrectionLeft = 0;
|
|
61
|
+
const tableCorrection = SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0;
|
|
62
|
+
if (tableCorrection) {
|
|
63
|
+
const table = el.parentElement;
|
|
64
|
+
const tableStyle = window.getComputedStyle(table.parentElement);
|
|
65
|
+
node.after(table, speccerNode);
|
|
66
|
+
tableCorrectionTop = table.getBoundingClientRect().top - parseInt(tableStyle.getPropertyValue('padding-top'), 10);
|
|
67
|
+
tableCorrectionLeft =
|
|
68
|
+
table.getBoundingClientRect().left - parseInt(tableStyle.getPropertyValue('padding-left'), 10);
|
|
69
|
+
} else {
|
|
70
|
+
node.after(el, speccerNode);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const rectOfSpeccerNode = speccerNode.getBoundingClientRect();
|
|
74
|
+
|
|
75
|
+
let outlineLeftLeft =
|
|
76
|
+
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) -
|
|
77
|
+
rectOfSpeccerNode.width -
|
|
78
|
+
48 +
|
|
79
|
+
'px';
|
|
80
|
+
|
|
81
|
+
let outlineLeftTop =
|
|
82
|
+
number.to3Decimals(
|
|
83
|
+
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) -
|
|
84
|
+
rectOfSpeccerNode.height / 2 +
|
|
85
|
+
_el_rect.height / 2
|
|
86
|
+
) + 'px';
|
|
87
|
+
let outlineRightLeft =
|
|
88
|
+
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) + _el_rect.width + 48 + 'px';
|
|
89
|
+
|
|
90
|
+
let outlineRightTop =
|
|
91
|
+
number.to3Decimals(
|
|
92
|
+
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) -
|
|
93
|
+
rectOfSpeccerNode.height / 2 +
|
|
94
|
+
_el_rect.height / 2
|
|
95
|
+
) + 'px';
|
|
96
|
+
let outlineTopLeft =
|
|
97
|
+
number.to3Decimals(
|
|
98
|
+
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) -
|
|
99
|
+
rectOfSpeccerNode.width / 2 +
|
|
100
|
+
_el_rect.width / 2
|
|
101
|
+
) + 'px';
|
|
102
|
+
let outlineTopTop =
|
|
103
|
+
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) -
|
|
104
|
+
rectOfSpeccerNode.height -
|
|
105
|
+
48 +
|
|
106
|
+
'px';
|
|
107
|
+
let outlineBottomleft =
|
|
108
|
+
number.to3Decimals(
|
|
109
|
+
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) -
|
|
110
|
+
rectOfSpeccerNode.width / 2 +
|
|
111
|
+
_el_rect.width / 2
|
|
112
|
+
) + 'px';
|
|
113
|
+
let outlineBottomTop =
|
|
114
|
+
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) + _el_rect.height + 48 + 'px';
|
|
115
|
+
|
|
116
|
+
let position = {
|
|
117
|
+
left: outlineLeftLeft,
|
|
118
|
+
top: outlineLeftTop
|
|
119
|
+
};
|
|
120
|
+
if (_area.indexOf('right') !== -1) {
|
|
121
|
+
position = {
|
|
122
|
+
left: outlineRightLeft,
|
|
123
|
+
top: outlineRightTop
|
|
124
|
+
};
|
|
125
|
+
} else if (_area.indexOf('top') !== -1) {
|
|
126
|
+
position = {
|
|
127
|
+
left: outlineTopLeft,
|
|
128
|
+
top: outlineTopTop
|
|
129
|
+
};
|
|
130
|
+
} else if (_area.indexOf('bottom') !== -1) {
|
|
131
|
+
position = {
|
|
132
|
+
left: outlineBottomleft,
|
|
133
|
+
top: outlineBottomTop
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
styles.add(speccerNode, position);
|
|
138
|
+
};
|
package/src/lib/poly.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// CustomEvent poly from MDN: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
|
|
2
|
-
(function() {
|
|
3
|
-
if (typeof window.CustomEvent === 'function') return false;
|
|
4
|
-
|
|
5
|
-
function CustomEvent(event, params) {
|
|
6
|
-
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
|
7
|
-
var evt = document.createEvent('CustomEvent');
|
|
8
|
-
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
|
9
|
-
return evt;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
CustomEvent.prototype = window.Event.prototype;
|
|
13
|
-
|
|
14
|
-
window.CustomEvent = CustomEvent;
|
|
15
|
-
})();
|