@phun-ky/speccer 5.0.0 → 6.0.2
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 +4 -4
- package/package.json +16 -3
- package/speccer.css +11 -19
- package/speccer.js +2 -1
- package/speccer.js.map +1 -0
- package/speccer.min.css +1 -1
- package/CHANGELOG.md +0 -59
- package/src/browser.js +0 -93
- package/src/dissect.js +0 -211
- package/src/index.js +0 -36
- package/src/lib/attributes.js +0 -13
- package/src/lib/classnames.js +0 -37
- package/src/lib/constants.js +0 -5
- package/src/lib/css.js +0 -37
- package/src/lib/debounce.js +0 -22
- package/src/lib/node.js +0 -7
- package/src/lib/number.js +0 -4
- package/src/lib/resize.js +0 -13
- package/src/lib/styles.js +0 -27
- package/src/measure.js +0 -99
- package/src/spec.js +0 -214
- package/src/styles/anatomy.styl +0 -274
- package/src/styles/index.styl +0 -68
- package/src/styles/measure.styl +0 -88
- package/src/styles/spacing.styl +0 -152
- package/src/styles/typography.styl +0 -86
- package/src/typography.js +0 -141
package/src/styles/spacing.styl
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
.ph.speccer.spacing
|
|
2
|
-
pointer-events auto
|
|
3
|
-
transition none
|
|
4
|
-
border var(--ph-speccer-line-width) solid transparent
|
|
5
|
-
&:hover
|
|
6
|
-
border var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.is-specced
|
|
10
|
-
&:hover
|
|
11
|
-
& ~ .ph.speccer.spacing
|
|
12
|
-
&.margin
|
|
13
|
-
background-color var(--ph-speccer-color-margin-hover)
|
|
14
|
-
&.padding
|
|
15
|
-
background-color var(--ph-speccer-color-padding-hover)
|
|
16
|
-
color var(--ph-speccer-color-text-light)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.ph.speccer.spacing
|
|
20
|
-
&.margin
|
|
21
|
-
background-color var(--ph-speccer-color-margin)
|
|
22
|
-
color var(--ph-speccer-color-text-dark)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.ph.speccer.spacing
|
|
26
|
-
&.padding
|
|
27
|
-
background-color var(--ph-speccer-color-padding)
|
|
28
|
-
color var(--ph-speccer-spacing-color)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.ph.speccer.spacing
|
|
32
|
-
&.margin
|
|
33
|
-
&.bottom,
|
|
34
|
-
&.top
|
|
35
|
-
&::after
|
|
36
|
-
transition none
|
|
37
|
-
content ""
|
|
38
|
-
position absolute
|
|
39
|
-
height 100%
|
|
40
|
-
border-top var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
41
|
-
border-bottom var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
42
|
-
width 9px
|
|
43
|
-
left 40%
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.ph.speccer.spacing
|
|
47
|
-
&.margin
|
|
48
|
-
&.bottom,
|
|
49
|
-
&.top
|
|
50
|
-
&::before
|
|
51
|
-
transition none
|
|
52
|
-
content ""
|
|
53
|
-
position absolute
|
|
54
|
-
height 100%
|
|
55
|
-
border-left var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
56
|
-
margin-left 4px
|
|
57
|
-
width 0
|
|
58
|
-
left 40%
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.ph.speccer.spacing
|
|
62
|
-
&.margin
|
|
63
|
-
&.left,
|
|
64
|
-
&.right
|
|
65
|
-
&::after
|
|
66
|
-
transition none
|
|
67
|
-
content ""
|
|
68
|
-
position absolute
|
|
69
|
-
height 9px
|
|
70
|
-
border-right var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
71
|
-
border-left var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
72
|
-
width 100%
|
|
73
|
-
top 10%
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.ph.speccer.spacing
|
|
77
|
-
&.margin
|
|
78
|
-
&.left,
|
|
79
|
-
&.right
|
|
80
|
-
&::before
|
|
81
|
-
transition none
|
|
82
|
-
content ""
|
|
83
|
-
position absolute
|
|
84
|
-
height 0
|
|
85
|
-
border-top var(--ph-speccer-line-width) solid var(--ph-speccer-color-text-dark)
|
|
86
|
-
margin-top 4px
|
|
87
|
-
width 100%
|
|
88
|
-
top 10%
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.ph.speccer.spacing
|
|
92
|
-
&.padding
|
|
93
|
-
&.bottom,
|
|
94
|
-
&.top
|
|
95
|
-
&::after
|
|
96
|
-
transition none
|
|
97
|
-
content ""
|
|
98
|
-
position absolute
|
|
99
|
-
height 100%
|
|
100
|
-
border-top var(--ph-speccer-line-width) solid var(--ph-speccer-spacing-color)
|
|
101
|
-
border-bottom var(--ph-speccer-line-width) solid var(--ph-speccer-spacing-color)
|
|
102
|
-
width 9px
|
|
103
|
-
left 40%
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.ph.speccer.spacing
|
|
107
|
-
&.padding
|
|
108
|
-
&.bottom,
|
|
109
|
-
&.top
|
|
110
|
-
&::before
|
|
111
|
-
transition none
|
|
112
|
-
content ""
|
|
113
|
-
position absolute
|
|
114
|
-
height 100%
|
|
115
|
-
border-left var(--ph-speccer-line-width) solid var(--ph-speccer-spacing-color)
|
|
116
|
-
margin-left 4px
|
|
117
|
-
width 0
|
|
118
|
-
left 40%
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.ph.speccer.spacing
|
|
122
|
-
&.padding
|
|
123
|
-
&.left,
|
|
124
|
-
&.right
|
|
125
|
-
&::after
|
|
126
|
-
transition none
|
|
127
|
-
content ""
|
|
128
|
-
position absolute
|
|
129
|
-
height 9px
|
|
130
|
-
border-right var(--ph-speccer-line-width) solid var(--ph-speccer-spacing-color)
|
|
131
|
-
border-left var(--ph-speccer-line-width) solid var(--ph-speccer-spacing-color)
|
|
132
|
-
width 100%
|
|
133
|
-
top 10%
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.ph.speccer.spacing
|
|
137
|
-
&.padding
|
|
138
|
-
&.left,
|
|
139
|
-
&.right
|
|
140
|
-
&::before
|
|
141
|
-
transition none
|
|
142
|
-
content ""
|
|
143
|
-
position absolute
|
|
144
|
-
height 0
|
|
145
|
-
border-top var(--ph-speccer-line-width) solid var(--ph-speccer-spacing-color)
|
|
146
|
-
margin-top 4px
|
|
147
|
-
width 100%
|
|
148
|
-
top 10%
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
@require './typography.styl'
|
|
152
|
-
@require './measure.styl'
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
.ph.speccer.typography
|
|
2
|
-
background-color var(--ph-speccer-typography-background-color)
|
|
3
|
-
color var(--ph-speccer-typography-color-text)
|
|
4
|
-
font-size 12px
|
|
5
|
-
padding 8px 24px
|
|
6
|
-
max-width none
|
|
7
|
-
width auto
|
|
8
|
-
display block
|
|
9
|
-
text-align left
|
|
10
|
-
line-height 140%
|
|
11
|
-
border var(--ph-speccer-line-width) solid var(--ph-speccer-pin-color)
|
|
12
|
-
min-width 320px
|
|
13
|
-
|
|
14
|
-
&:hover
|
|
15
|
-
border var(--ph-speccer-line-width) solid var(--ph-speccer-pin-color)
|
|
16
|
-
|
|
17
|
-
&:after
|
|
18
|
-
content ""
|
|
19
|
-
position absolute
|
|
20
|
-
display block
|
|
21
|
-
background-color var(--ph-speccer-pin-color)
|
|
22
|
-
left 100%
|
|
23
|
-
top 50%
|
|
24
|
-
transform translateY(-50%)
|
|
25
|
-
height var(--ph-speccer-line-width)
|
|
26
|
-
width 48px
|
|
27
|
-
|
|
28
|
-
&.left
|
|
29
|
-
&:after
|
|
30
|
-
left 100%
|
|
31
|
-
top 50%
|
|
32
|
-
transform translateY(-50%)
|
|
33
|
-
height var(--ph-speccer-line-width)
|
|
34
|
-
width 48px
|
|
35
|
-
&.right
|
|
36
|
-
&:after
|
|
37
|
-
left auto
|
|
38
|
-
right 100%
|
|
39
|
-
top 50%
|
|
40
|
-
transform translateY(-50%)
|
|
41
|
-
height var(--ph-speccer-line-width)
|
|
42
|
-
width 48px
|
|
43
|
-
&.top
|
|
44
|
-
&:after
|
|
45
|
-
left 50%
|
|
46
|
-
right auto
|
|
47
|
-
top 100%
|
|
48
|
-
transform translateX(-50%)
|
|
49
|
-
height 48px
|
|
50
|
-
width var(--ph-speccer-line-width)
|
|
51
|
-
&.bottom
|
|
52
|
-
&:after
|
|
53
|
-
left 50%
|
|
54
|
-
right auto
|
|
55
|
-
top auto
|
|
56
|
-
bottom 100%
|
|
57
|
-
transform translateX(-50%)
|
|
58
|
-
height 48px
|
|
59
|
-
width var(--ph-speccer-line-width)
|
|
60
|
-
|
|
61
|
-
& .speccer-styles
|
|
62
|
-
list-style none
|
|
63
|
-
width 100%
|
|
64
|
-
padding 0
|
|
65
|
-
margin 0
|
|
66
|
-
line-height 140%
|
|
67
|
-
padding-left 1rem
|
|
68
|
-
font-size 12px
|
|
69
|
-
|
|
70
|
-
& .property
|
|
71
|
-
font-weight normal
|
|
72
|
-
color var(--ph-speccer-typography-color-property)
|
|
73
|
-
text-align left
|
|
74
|
-
padding 0
|
|
75
|
-
font-size 12px
|
|
76
|
-
margin 0
|
|
77
|
-
|
|
78
|
-
& > li
|
|
79
|
-
font-weight normal
|
|
80
|
-
color var(--ph-speccer-typography-color-value)
|
|
81
|
-
text-align left
|
|
82
|
-
padding 0
|
|
83
|
-
font-size 12px
|
|
84
|
-
margin 0
|
|
85
|
-
list-style none
|
|
86
|
-
border none
|
package/src/typography.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
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
|
-
|
|
14
|
-
_el.innerHTML = html;
|
|
15
|
-
|
|
16
|
-
classnames.set(_el, `ph speccer typography ${area}`);
|
|
17
|
-
|
|
18
|
-
return _el;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const element = async (el) => {
|
|
22
|
-
const _area = el.getAttribute('data-speccer-typography');
|
|
23
|
-
const _el_style = await styles.get(el);
|
|
24
|
-
|
|
25
|
-
if (_el_style.display === 'none' || _el_style.visibility === 'hidden') {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
el.classList.add('is-specced');
|
|
30
|
-
|
|
31
|
-
const _parent_style = styles.get(el.parentElement);
|
|
32
|
-
|
|
33
|
-
if (_parent_style.position === 'static') {
|
|
34
|
-
window.requestAnimationFrame(() => {
|
|
35
|
-
el.parentElement.style.position = 'relative';
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const _styles = css.getTypography(_el_style);
|
|
40
|
-
const _el_rect = el.getBoundingClientRect();
|
|
41
|
-
const html =
|
|
42
|
-
`
|
|
43
|
-
` +
|
|
44
|
-
'font-styles: {' +
|
|
45
|
-
'<ul class="speccer-styles">' +
|
|
46
|
-
` <li><span class="property">font-family:</span> ${_styles['fontFamily']};</li>` +
|
|
47
|
-
` <li><span class="property">font-size:</span> ${_styles['fontSize']} / ${
|
|
48
|
-
parseInt(_styles['fontSize'], 10) / 16
|
|
49
|
-
}rem;</li>` +
|
|
50
|
-
` <li><span class="property">font-weight:</span> ${_styles['fontWeight']};</li>` +
|
|
51
|
-
` <li><span class="property">font-variation-settings:</span> ${_styles['fontVariationSettings']};</li>` +
|
|
52
|
-
` <li><span class="property">line-height:</span> ${_styles['lineHeight']} / ${
|
|
53
|
-
parseInt(_styles['lineHeight'], 10) / 16
|
|
54
|
-
}rem;</li>` +
|
|
55
|
-
` <li><span class="property">letter-spacing:</span> ${_styles['letterSpacing']};</li>` +
|
|
56
|
-
` <li><span class="property">font-style:</span> ${_styles['fontStyle']};</li>` +
|
|
57
|
-
'</ul>' +
|
|
58
|
-
'}';
|
|
59
|
-
const speccerNode = create(html, _area);
|
|
60
|
-
|
|
61
|
-
let tableCorrectionTop = 0;
|
|
62
|
-
let tableCorrectionLeft = 0;
|
|
63
|
-
|
|
64
|
-
const tableCorrection = SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0;
|
|
65
|
-
|
|
66
|
-
if (tableCorrection) {
|
|
67
|
-
const table = el.parentElement;
|
|
68
|
-
const tableStyle = window.getComputedStyle(table.parentElement);
|
|
69
|
-
|
|
70
|
-
node.after(table, speccerNode);
|
|
71
|
-
tableCorrectionTop = table.getBoundingClientRect().top - parseInt(tableStyle.getPropertyValue('padding-top'), 10);
|
|
72
|
-
tableCorrectionLeft =
|
|
73
|
-
table.getBoundingClientRect().left - parseInt(tableStyle.getPropertyValue('padding-left'), 10);
|
|
74
|
-
} else {
|
|
75
|
-
node.after(el, speccerNode);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const rectOfSpeccerNode = speccerNode.getBoundingClientRect();
|
|
79
|
-
const outlineLeftLeft =
|
|
80
|
-
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) -
|
|
81
|
-
rectOfSpeccerNode.width -
|
|
82
|
-
48 +
|
|
83
|
-
'px';
|
|
84
|
-
const outlineLeftTop =
|
|
85
|
-
number.to3Decimals(
|
|
86
|
-
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) -
|
|
87
|
-
rectOfSpeccerNode.height / 2 +
|
|
88
|
-
_el_rect.height / 2
|
|
89
|
-
) + 'px';
|
|
90
|
-
const outlineRightLeft =
|
|
91
|
-
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) + _el_rect.width + 48 + 'px';
|
|
92
|
-
const outlineRightTop =
|
|
93
|
-
number.to3Decimals(
|
|
94
|
-
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) -
|
|
95
|
-
rectOfSpeccerNode.height / 2 +
|
|
96
|
-
_el_rect.height / 2
|
|
97
|
-
) + 'px';
|
|
98
|
-
const outlineTopLeft =
|
|
99
|
-
number.to3Decimals(
|
|
100
|
-
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) -
|
|
101
|
-
rectOfSpeccerNode.width / 2 +
|
|
102
|
-
_el_rect.width / 2
|
|
103
|
-
) + 'px';
|
|
104
|
-
const outlineTopTop =
|
|
105
|
-
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) -
|
|
106
|
-
rectOfSpeccerNode.height -
|
|
107
|
-
48 +
|
|
108
|
-
'px';
|
|
109
|
-
const outlineBottomleft =
|
|
110
|
-
number.to3Decimals(
|
|
111
|
-
(tableCorrection ? rectOfSpeccerNode.left - tableCorrectionLeft : el.offsetLeft) -
|
|
112
|
-
rectOfSpeccerNode.width / 2 +
|
|
113
|
-
_el_rect.width / 2
|
|
114
|
-
) + 'px';
|
|
115
|
-
const outlineBottomTop =
|
|
116
|
-
(tableCorrection ? rectOfSpeccerNode.top - tableCorrectionTop : el.offsetTop) + _el_rect.height + 48 + 'px';
|
|
117
|
-
|
|
118
|
-
let position = {
|
|
119
|
-
left: outlineLeftLeft,
|
|
120
|
-
top: outlineLeftTop
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (_area.indexOf('right') !== -1) {
|
|
124
|
-
position = {
|
|
125
|
-
left: outlineRightLeft,
|
|
126
|
-
top: outlineRightTop
|
|
127
|
-
};
|
|
128
|
-
} else if (_area.indexOf('top') !== -1) {
|
|
129
|
-
position = {
|
|
130
|
-
left: outlineTopLeft,
|
|
131
|
-
top: outlineTopTop
|
|
132
|
-
};
|
|
133
|
-
} else if (_area.indexOf('bottom') !== -1) {
|
|
134
|
-
position = {
|
|
135
|
-
left: outlineBottomleft,
|
|
136
|
-
top: outlineBottomTop
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
styles.add(speccerNode, position);
|
|
141
|
-
};
|