@phun-ky/speccer 5.0.0 → 6.0.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dts/browser.d.ts +4 -0
  3. package/dts/enums/area.d.ts +16 -0
  4. package/dts/helpers/dissect/index.d.ts +1 -0
  5. package/dts/helpers/dissect/styles.d.ts +1 -0
  6. package/dts/helpers/typography/index.d.ts +2 -0
  7. package/dts/helpers/typography/position.d.ts +4 -0
  8. package/dts/helpers/typography/template.d.ts +1 -0
  9. package/dts/index.d.ts +53 -0
  10. package/dts/interfaces/global.d.ts +6 -0
  11. package/dts/lib/attributes.d.ts +2 -0
  12. package/dts/lib/classnames.d.ts +4 -0
  13. package/dts/lib/constants.d.ts +3 -0
  14. package/dts/lib/css.d.ts +6 -0
  15. package/dts/lib/debounce.d.ts +3 -0
  16. package/dts/lib/node.d.ts +2 -0
  17. package/dts/lib/number.d.ts +1 -0
  18. package/dts/lib/position.d.ts +6 -0
  19. package/dts/lib/resize.d.ts +1 -0
  20. package/dts/lib/styles.d.ts +2 -0
  21. package/dts/tasks/dissect.d.ts +2 -0
  22. package/dts/tasks/index.d.ts +4 -0
  23. package/dts/tasks/measure.d.ts +1 -0
  24. package/dts/tasks/spec.d.ts +2 -0
  25. package/dts/tasks/typography.d.ts +2 -0
  26. package/dts/types/css.d.ts +19 -0
  27. package/dts/types/speccer.d.ts +5 -0
  28. package/package.json +10 -3
  29. package/speccer.css +16 -19
  30. package/speccer.js +2 -1
  31. package/speccer.js.map +1 -0
  32. package/speccer.min.css +1 -1
  33. package/src/{browser.js → browser.ts} +16 -13
  34. package/src/enums/area.ts +17 -0
  35. package/src/helpers/dissect/index.ts +1 -0
  36. package/src/helpers/dissect/styles.ts +154 -0
  37. package/src/helpers/typography/index.ts +3 -0
  38. package/src/helpers/typography/position.ts +54 -0
  39. package/src/helpers/typography/template.ts +27 -0
  40. package/src/{index.js → index.ts} +17 -17
  41. package/src/interfaces/global.ts +7 -0
  42. package/src/lib/attributes.ts +18 -0
  43. package/src/lib/classnames.ts +43 -0
  44. package/src/lib/{constants.js → constants.ts} +3 -0
  45. package/src/lib/css.ts +45 -0
  46. package/src/lib/debounce.ts +29 -0
  47. package/src/lib/node.ts +8 -0
  48. package/src/lib/number.ts +4 -0
  49. package/src/lib/position.ts +16 -0
  50. package/src/lib/{resize.js → resize.ts} +5 -4
  51. package/src/lib/styles.ts +31 -0
  52. package/src/styles/index.styl +4 -0
  53. package/src/styles/spacing.styl +0 -10
  54. package/src/styles/typography.styl +11 -12
  55. package/src/tasks/dissect.ts +46 -0
  56. package/src/tasks/index.ts +7 -0
  57. package/src/tasks/measure.ts +82 -0
  58. package/src/tasks/spec.ts +170 -0
  59. package/src/tasks/typography.ts +45 -0
  60. package/src/types/css.ts +20 -0
  61. package/src/types/speccer.ts +6 -0
  62. package/tsconfig.json +21 -0
  63. package/tslint.json +23 -0
  64. package/src/dissect.js +0 -211
  65. package/src/lib/attributes.js +0 -13
  66. package/src/lib/classnames.js +0 -37
  67. package/src/lib/css.js +0 -37
  68. package/src/lib/debounce.js +0 -22
  69. package/src/lib/node.js +0 -7
  70. package/src/lib/number.js +0 -4
  71. package/src/lib/styles.js +0 -27
  72. package/src/measure.js +0 -99
  73. package/src/spec.js +0 -214
  74. package/src/typography.js +0 -141
package/src/dissect.js DELETED
@@ -1,211 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
- import * as styles from './lib/styles';
4
- import * as node from './lib/node';
5
- import * as classnames from './lib/classnames';
6
- import { SPECCER_LITERALS, SPECCER_TAGS_TO_AVOID } from './lib/constants';
7
-
8
- export const create = (e = '', t, n = 'span') => {
9
- const _el = document.createElement(n);
10
- const o = document.createTextNode(e);
11
-
12
- if (t.indexOf('full') === -1 && t.indexOf('enclose') === -1) {
13
- _el.appendChild(o);
14
- } else if (t.indexOf('full') !== -1 || t.indexOf('enclose') !== -1) {
15
- _el.setAttribute('data-dissection-counter', e);
16
- }
17
-
18
- classnames.set(_el, `ph speccer dissection ${t}`);
19
-
20
- return _el;
21
- };
22
-
23
- export const element = (el, dissectIndex) => {
24
- const _el_rect = el.getBoundingClientRect();
25
- const _area = el.getAttribute('data-anatomy');
26
- const _dissection_node = create(SPECCER_LITERALS[dissectIndex], _area);
27
- const _is_table_correction_needed = SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0;
28
-
29
- let _table_top = 0;
30
- let _table_left = 0;
31
-
32
- if (_is_table_correction_needed) {
33
- const table = el.closest('table');
34
- const tableStyle = styles.get(table.parentElement);
35
-
36
- node.after(table, _dissection_node);
37
-
38
- const _table_rect = table.getBoundingClientRect();
39
-
40
- _table_top = _table_rect.top - parseInt(tableStyle.getPropertyValue('padding-top'), 10);
41
- _table_left = _table_rect.left - parseInt(tableStyle.getPropertyValue('padding-left'), 10);
42
- } else {
43
- node.after(el, _dissection_node);
44
- }
45
-
46
- const _el_offset_left = el.offsetLeft;
47
- const _el_offset_top = el.offsetTop;
48
- const _dissection_node_rect = _dissection_node.getBoundingClientRect();
49
- const _outline_left_position_left =
50
- (_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) -
51
- _dissection_node_rect.width -
52
- 48 +
53
- 'px';
54
- const _outline_left_position_top =
55
- (_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) +
56
- _el_rect.height / 2 -
57
- _dissection_node_rect.height / 2 +
58
- 'px';
59
- const _outline_right_position_left =
60
- (_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) + _el_rect.width + 48 + 'px';
61
- const _outline_right_position_top =
62
- (_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) +
63
- _el_rect.height / 2 -
64
- _dissection_node_rect.height / 2 +
65
- 'px';
66
- const _outline_top_position_left =
67
- (_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) +
68
- _el_rect.width / 2 -
69
- _dissection_node_rect.width / 2 +
70
- 'px';
71
- const _outline_top_position_top =
72
- (_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) -
73
- _dissection_node_rect.height -
74
- 48 +
75
- 'px';
76
- const _outline_bottom_position_left =
77
- (_is_table_correction_needed ? _el_rect.left - _table_left : _el_offset_left) +
78
- _el_rect.width / 2 -
79
- _dissection_node_rect.width / 2 +
80
- 'px';
81
- const _outline_bottom_position_top =
82
- (_is_table_correction_needed ? _el_rect.top - _table_top : _el_offset_top) + _el_rect.height + 48 + 'px';
83
-
84
- let _dissection_node_styles = {};
85
-
86
- if (_area.indexOf('outline') !== -1) {
87
- if (_area.indexOf('left') !== -1) {
88
- if (_area.indexOf('full') !== -1) {
89
- _dissection_node_styles = {
90
- left: _el_offset_left - 8 + 'px',
91
- top: _el_offset_top + -1 + 'px',
92
- height: _el_rect.height + 'px'
93
- };
94
- } else if (_area.indexOf('enclose') !== -1) {
95
- _dissection_node_styles = {
96
- left: _el_offset_left - 1 + 'px',
97
- top: _el_offset_top + -1 + 'px',
98
- height: _el_rect.height + 'px',
99
- width: _el_rect.width + 'px'
100
- };
101
- } else {
102
- _dissection_node_styles = {
103
- left: _outline_left_position_left,
104
- top: _outline_left_position_top
105
- };
106
- }
107
- } else if (_area.indexOf('right') !== -1) {
108
- if (_area.indexOf('full') !== -1) {
109
- _dissection_node_styles = {
110
- left: _el_offset_left + _el_rect.width + 'px',
111
- top: _el_offset_top + -1 + 'px',
112
- height: _el_rect.height + 'px'
113
- };
114
- } else if (_area.indexOf('enclose') !== -1) {
115
- _dissection_node_styles = {
116
- left: _el_offset_left + -1 + 'px',
117
- top: _el_offset_top + -1 + 'px',
118
- height: _el_rect.height + 'px',
119
- width: _el_rect.width + 'px'
120
- };
121
- } else {
122
- _dissection_node_styles = {
123
- left: _outline_right_position_left,
124
- top: _outline_right_position_top
125
- };
126
- }
127
- } else if (_area.indexOf('top') !== -1) {
128
- if (_area.indexOf('full') !== -1) {
129
- _dissection_node_styles = {
130
- top: _el_offset_top + -8 + 'px',
131
- left: _el_offset_left + -1 + 'px',
132
- width: _el_rect.width + 'px'
133
- };
134
- } else if (_area.indexOf('enclose') !== -1) {
135
- _dissection_node_styles = {
136
- top: _el_offset_top + -1 + 'px',
137
- left: _el_offset_left + -1 + 'px',
138
- height: _el_rect.height + 'px',
139
- width: _el_rect.width + 'px'
140
- };
141
- } else {
142
- _dissection_node_styles = {
143
- left: _outline_top_position_left,
144
- top: _outline_top_position_top
145
- };
146
- }
147
- } else if (_area.indexOf('bottom') !== -1) {
148
- if (_area.indexOf('full') !== -1) {
149
- _dissection_node_styles = {
150
- top: _el_offset_top + _el_rect.height + 'px',
151
- left: _el_offset_left + -1 + 'px',
152
- width: _el_rect.width + 'px'
153
- };
154
- } else if (_area.indexOf('enclose') !== -1) {
155
- _dissection_node_styles = {
156
- top: _el_offset_top + -1 + 'px',
157
- left: _el_offset_left + -1 + 'px',
158
- height: _el_rect.height + 'px',
159
- width: _el_rect.width + 'px'
160
- };
161
- } else {
162
- _dissection_node_styles = {
163
- left: _outline_bottom_position_left,
164
- top: _outline_bottom_position_top
165
- };
166
- }
167
- } else {
168
- if (_area.indexOf('full') !== -1) {
169
- _dissection_node_styles = {
170
- left: _el_offset_left + _el_rect.width + 'px',
171
- top: _el_offset_top + 'px',
172
- height: _el_rect.height + 'px'
173
- };
174
- } else if (_area.indexOf('enclose') !== -1) {
175
- _dissection_node_styles = {
176
- left: _el_offset_left + _el_rect.width + 'px',
177
- top: _el_offset_top + -1 + 'px',
178
- height: _el_rect.height + 'px',
179
- width: _el_rect.width + 'px'
180
- };
181
- } else {
182
- _dissection_node_styles = {
183
- left: _outline_left_position_left,
184
- top: _outline_left_position_top
185
- };
186
- }
187
- }
188
- } else {
189
- if (_area.indexOf('full') !== -1) {
190
- _dissection_node_styles = {
191
- left: _el_offset_left - 8 + 'px',
192
- top: _el_offset_top + -1 + 'px',
193
- height: _el_rect.height + 'px'
194
- };
195
- } else if (_area.indexOf('enclose') !== -1) {
196
- _dissection_node_styles = {
197
- left: _el_offset_left - 1 + 'px',
198
- top: _el_offset_top + -1 + 'px',
199
- height: _el_rect.height + 'px',
200
- width: _el_rect.width + 'px'
201
- };
202
- } else {
203
- _dissection_node_styles = {
204
- left: _outline_left_position_left,
205
- top: _outline_left_position_top
206
- };
207
- }
208
- }
209
-
210
- styles.add(_dissection_node, _dissection_node_styles);
211
- };
@@ -1,13 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- export const set = (el, attrs) => {
5
- if (!el) return;
6
- if (!attrs || (attrs && attrs.length === 0)) return;
7
- Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
8
- };
9
- export const remove = (el, attrs) => {
10
- if (!el) return;
11
- if (!attrs || (attrs && attrs.length === 0)) return;
12
- Object.keys(attrs).forEach(key => el.removeAttribute(key));
13
- };
@@ -1,37 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- export const set = (el, cls, avoid = 'noop') => {
5
- if (!el) return;
6
- if (!cls || (cls && cls.length === 0)) return;
7
- cls
8
- .trim()
9
- .split(' ')
10
- .filter(cl => cl !== avoid)
11
- .forEach(cl => el.classList.add(cl));
12
- };
13
-
14
- export const toggle = (el, cls, avoid = 'noop') => {
15
- if (!el) return;
16
- if (!cls || (cls && cls.length === 0)) return;
17
- cls
18
- .trim()
19
- .split(' ')
20
- .filter(cl => cl !== avoid)
21
- .forEach(cl => el.classList.toggle(cl));
22
- };
23
-
24
- export const remove = (el, cls, avoid = 'noop') => {
25
- if (!el) return;
26
- if (!cls || (cls && cls.length === 0)) return;
27
- cls
28
- .trim()
29
- .split(' ')
30
- .filter(cl => cl !== avoid)
31
- .forEach(cl => el.classList.remove(cl));
32
- };
33
-
34
- export const cx = (cls, cls_obj) =>
35
- `${cls} ${Object.keys(cls_obj)
36
- .filter(classname => cls_obj[classname])
37
- .join(' ')}`.trim();
package/src/lib/css.js DELETED
@@ -1,37 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- export const getNumberValue = value => parseInt(value, 10);
5
-
6
- export const normalizeNumberValue = value => {
7
- const _value = parseFloat(value);
8
- return (_value >= 0 && _value < 1) || (_value <= 0 && _value > -1) ? 0 : _value;
9
- };
10
-
11
- export const getSpacing = style => {
12
- const { marginTop, marginBottom, marginLeft, marginRight, paddingTop, paddingBottom, paddingLeft, paddingRight } =
13
- style;
14
- return {
15
- marginTop,
16
- marginBottom,
17
- marginLeft,
18
- marginRight,
19
- paddingTop,
20
- paddingBottom,
21
- paddingLeft,
22
- paddingRight
23
- };
24
- };
25
-
26
- export const getTypography = style => {
27
- const { lineHeight, letterSpacing, fontFamily, fontSize, fontStyle, fontVariationSettings, fontWeight } = style;
28
- return {
29
- lineHeight,
30
- letterSpacing,
31
- fontFamily,
32
- fontSize,
33
- fontStyle,
34
- fontVariationSettings,
35
- fontWeight
36
- };
37
- };
@@ -1,22 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- export const waitForFrame = () => new Promise(requestAnimationFrame);
5
-
6
- const debounce = function (func, wait, immediate) {
7
- var timeout;
8
- return function () {
9
- var context = this,
10
- args = arguments;
11
- var later = function () {
12
- timeout = null;
13
- if (!immediate) func.apply(context, args);
14
- };
15
- var callNow = immediate && !timeout;
16
- clearTimeout(timeout);
17
- timeout = setTimeout(later, wait);
18
- if (callNow) func.apply(context, args);
19
- };
20
- };
21
-
22
- export default debounce;
package/src/lib/node.js DELETED
@@ -1,7 +0,0 @@
1
- export const after = (el, newSibling) => el.insertAdjacentElement('afterend', newSibling);
2
-
3
- export const removeAll = (selector, el = document) => {
4
- [].forEach.call(el.querySelectorAll(selector), function (e) {
5
- e.remove();
6
- });
7
- };
package/src/lib/number.js DELETED
@@ -1,4 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- export const to3Decimals = number => parseFloat(number).toFixed(3);
package/src/lib/styles.js DELETED
@@ -1,27 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
- import { waitForFrame } from './debounce';
4
-
5
- export const add = async (el, styles) => {
6
- if (!el) return;
7
- if (
8
- !styles ||
9
- (styles && styles.length === 0 && styles.constructor === String) ||
10
- (styles && styles.length === 0 && styles.constructor === Array) ||
11
- (styles && Object.keys(styles).length === 0 && styles.constructor === Object)
12
- ) {
13
- return;
14
- }
15
-
16
- await waitForFrame();
17
- if (typeof styles === 'string' || Array.isArray(styles)) {
18
- styles.forEach(style => (el.style[style.key] = style.value));
19
- } else {
20
- Object.keys(styles).forEach(key => (el.style[key] = styles[key]));
21
- }
22
- };
23
-
24
- export const get = async el => {
25
- await waitForFrame();
26
- return window.getComputedStyle ? getComputedStyle(el, null) : el.currentStyle;
27
- };
package/src/measure.js DELETED
@@ -1,99 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- import * as classnames from './lib/classnames';
5
- import * as styles from './lib/styles';
6
- import * as node from './lib/node';
7
-
8
- import { SPECCER_TAGS_TO_AVOID } from './lib/constants';
9
-
10
- const create = (text = '', area = '', tag = 'span') => {
11
- const _el = document.createElement(tag);
12
-
13
- _el.setAttribute('title', text + 'px');
14
- _el.setAttribute('data-measure', parseInt(text, 10) + 'px');
15
-
16
- classnames.set(_el, `ph speccer measure ${area}`);
17
-
18
- return _el;
19
- };
20
-
21
- export const element = (el) => {
22
- if (!el) return;
23
-
24
- const _el_rect = el.getBoundingClientRect();
25
- const _area = el.getAttribute('data-speccer-measure');
26
-
27
- if (_area === '') {
28
- return;
29
- }
30
-
31
- const _el_offset_top = el.offsetTop;
32
- const _el_offset_left = el.offsetLeft;
33
-
34
- if (_area.indexOf('width') !== -1) {
35
- if (_area.indexOf('bottom') !== -1) {
36
- const _measure_node = create(_el_rect.width, 'width bottom');
37
-
38
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
39
- node.after(el.closest('table'), _measure_node);
40
- } else {
41
- node.after(el, _measure_node);
42
- }
43
-
44
- styles.add(_measure_node, {
45
- left: _el_offset_left + 'px',
46
- top: _el_offset_top + _el_rect.height + 1 + 'px',
47
- width: _el_rect.width + 'px'
48
- });
49
- } else {
50
- const _measure_node = create(_el_rect.width, 'width top');
51
-
52
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
53
- node.after(el.closest('table'), _measure_node);
54
- } else {
55
- node.after(el, _measure_node);
56
- }
57
-
58
- const _measure_node_rect = _measure_node.getBoundingClientRect();
59
-
60
- styles.add(_measure_node, {
61
- left: _el_offset_left + 'px',
62
- top: _el_offset_top - _measure_node_rect.height + 1 + 'px',
63
- width: _el_rect.width + 'px'
64
- });
65
- }
66
- } else if (_area.indexOf('height') !== -1) {
67
- if (_area.indexOf('right') !== -1) {
68
- const _measure_node = create(_el_rect.height, 'height right');
69
-
70
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
71
- node.after(el.closest('table'), _measure_node);
72
- } else {
73
- node.after(el, _measure_node);
74
- }
75
-
76
- styles.add(_measure_node, {
77
- left: _el_offset_left + _el_rect.width + 'px',
78
- top: _el_offset_top + 'px',
79
- height: _el_rect.height + 'px'
80
- });
81
- } else {
82
- const _measure_node = create(_el_rect.height, 'height left');
83
-
84
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
85
- node.after(el.closest('table'), _measure_node);
86
- } else {
87
- node.after(el, _measure_node);
88
- }
89
-
90
- const _measure_node_rect = _measure_node.getBoundingClientRect();
91
-
92
- styles.add(_measure_node, {
93
- left: _el_offset_left - _measure_node_rect.width + 'px',
94
- top: _el_offset_top + 'px',
95
- height: _el_rect.height + 'px'
96
- });
97
- }
98
- }
99
- };
package/src/spec.js DELETED
@@ -1,214 +0,0 @@
1
- /* eslint no-console:0 */
2
- 'use strict';
3
-
4
- import * as classnames from './lib/classnames';
5
- import * as css from './lib/css';
6
- import * as node from './lib/node';
7
- import * as styles from './lib/styles';
8
- import { SPECCER_TAGS_TO_AVOID } from './lib/constants';
9
-
10
- export const create = (text = '', tag = 'span') => {
11
- const _el = document.createElement(tag);
12
- const textContent = document.createTextNode(text);
13
-
14
- _el.appendChild(textContent);
15
- _el.setAttribute('title', text + 'px');
16
- classnames.set(_el, 'ph speccer spacing');
17
-
18
- return _el;
19
- };
20
-
21
- export const element = async (el) => {
22
- const _speccer_el = {};
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_el_style = styles.get(el.parentElement);
32
-
33
- if (_parent_el_style.position === 'static') {
34
- window.requestAnimationFrame(() => {
35
- el.parentElement.style.position = 'relative';
36
- });
37
- }
38
-
39
- _speccer_el.styles = css.getSpacing(_el_style);
40
- _speccer_el.rect = el.getBoundingClientRect();
41
-
42
- if (_speccer_el.styles['marginTop'] !== '0px') {
43
- const _speccer_margin_top_el = create(css.getNumberValue(_speccer_el.styles.marginTop));
44
-
45
- classnames.set(_speccer_margin_top_el, 'margin top');
46
- styles.add(_speccer_margin_top_el, {
47
- height: _speccer_el.styles.marginTop,
48
- width: _speccer_el.rect.width + 'px',
49
- left: css.normalizeNumberValue(_speccer_el.rect.x - el.parentElement.getBoundingClientRect().x) + 'px',
50
- top:
51
- css.normalizeNumberValue(
52
- _speccer_el.rect.y - el.parentElement.getBoundingClientRect().y - parseInt(_speccer_el.styles.marginTop, 10)
53
- ) + 'px'
54
- });
55
-
56
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
57
- node.after(el.closest('table'), _speccer_margin_top_el);
58
- } else {
59
- node.after(el, _speccer_margin_top_el);
60
- }
61
- }
62
-
63
- if (_speccer_el.styles['marginRight'] !== '0px') {
64
- const _speccer_margin_right_el = create(css.getNumberValue(_speccer_el.styles.marginRight));
65
-
66
- classnames.set(_speccer_margin_right_el, 'margin right');
67
-
68
- styles.add(_speccer_margin_right_el, {
69
- height: _speccer_el.rect.height + 'px',
70
- width: _speccer_el.styles.marginRight,
71
- left:
72
- css.normalizeNumberValue(
73
- _speccer_el.rect.x - el.parentElement.getBoundingClientRect().x + parseInt(_speccer_el.rect.width, 10)
74
- ) + 'px',
75
- top: css.normalizeNumberValue(_speccer_el.rect.y - el.parentElement.getBoundingClientRect().y) + 'px'
76
- });
77
-
78
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
79
- node.after(el.closest('table'), _speccer_margin_right_el);
80
- } else {
81
- node.after(el, _speccer_margin_right_el);
82
- }
83
- }
84
-
85
- if (_speccer_el.styles['marginBottom'] !== '0px') {
86
- const _speccer_margin_bottom_el = create(css.getNumberValue(_speccer_el.styles.marginBottom));
87
-
88
- classnames.set(_speccer_margin_bottom_el, 'margin bottom');
89
-
90
- styles.add(_speccer_margin_bottom_el, {
91
- height: _speccer_el.styles.marginBottom,
92
- width: _speccer_el.rect.width + 'px',
93
- left: css.normalizeNumberValue(_speccer_el.rect.x - el.parentElement.getBoundingClientRect().x) + 'px',
94
- top:
95
- css.normalizeNumberValue(
96
- _speccer_el.rect.y - el.parentElement.getBoundingClientRect().y + parseInt(_speccer_el.rect.height, 10)
97
- ) + 'px'
98
- });
99
-
100
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
101
- node.after(el.closest('table'), _speccer_margin_bottom_el);
102
- } else {
103
- node.after(el, _speccer_margin_bottom_el);
104
- }
105
- }
106
-
107
- if (_speccer_el.styles['marginLeft'] !== '0px') {
108
- const _speccer_margin_left_el = create(css.getNumberValue(_speccer_el.styles.marginLeft));
109
-
110
- classnames.set(_speccer_margin_left_el, 'margin left');
111
-
112
- styles.add(_speccer_margin_left_el, {
113
- height: _speccer_el.rect.height + 'px',
114
- width: _speccer_el.styles.marginLeft,
115
- left:
116
- css.normalizeNumberValue(
117
- _speccer_el.rect.x - el.parentElement.getBoundingClientRect().x - parseInt(_speccer_el.styles.marginLeft, 10)
118
- ) + 'px',
119
- top: css.normalizeNumberValue(_speccer_el.rect.y - el.parentElement.getBoundingClientRect().y) + 'px'
120
- });
121
-
122
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
123
- node.after(el.closest('table'), _speccer_margin_left_el);
124
- } else {
125
- node.after(el, _speccer_margin_left_el);
126
- }
127
- }
128
-
129
- if (_speccer_el.styles['paddingTop'] !== '0px') {
130
- const _speccer_padding_top_el = create(css.getNumberValue(_speccer_el.styles.paddingTop));
131
-
132
- classnames.set(_speccer_padding_top_el, 'padding top');
133
-
134
- styles.add(_speccer_padding_top_el, {
135
- height: _speccer_el.styles.paddingTop,
136
- width: _speccer_el.rect.width + 'px',
137
- left: css.normalizeNumberValue(_speccer_el.rect.x - el.parentElement.getBoundingClientRect().x) + 'px',
138
- top: css.normalizeNumberValue(_speccer_el.rect.y - el.parentElement.getBoundingClientRect().y) + 'px'
139
- });
140
-
141
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
142
- node.after(el.closest('table'), _speccer_padding_top_el);
143
- } else {
144
- node.after(el, _speccer_padding_top_el);
145
- }
146
- }
147
-
148
- if (_speccer_el.styles['paddingBottom'] !== '0px') {
149
- const _speccer_padding_bottom_el = create(css.getNumberValue(_speccer_el.styles.paddingBottom));
150
-
151
- classnames.set(_speccer_padding_bottom_el, 'padding bottom');
152
-
153
- styles.add(_speccer_padding_bottom_el, {
154
- height: _speccer_el.styles.paddingBottom,
155
- width: _speccer_el.rect.width + 'px',
156
- left: css.normalizeNumberValue(_speccer_el.rect.x - el.parentElement.getBoundingClientRect().x) + 'px',
157
- top:
158
- css.normalizeNumberValue(
159
- _speccer_el.rect.y -
160
- el.parentElement.getBoundingClientRect().y +
161
- (parseInt(_speccer_el.rect.height, 10) - parseInt(_speccer_el.styles.paddingBottom, 10))
162
- ) + 'px'
163
- });
164
-
165
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
166
- node.after(el.closest('table'), _speccer_padding_bottom_el);
167
- } else {
168
- node.after(el, _speccer_padding_bottom_el);
169
- }
170
- }
171
-
172
- if (_speccer_el.styles['paddingRight'] !== '0px') {
173
- const _speccer_padding_right_el = create(css.getNumberValue(_speccer_el.styles.paddingRight));
174
-
175
- classnames.set(_speccer_padding_right_el, 'padding right');
176
-
177
- styles.add(_speccer_padding_right_el, {
178
- height: _speccer_el.rect.height + 'px',
179
- width: _speccer_el.styles.paddingRight,
180
- left:
181
- css.normalizeNumberValue(
182
- _speccer_el.rect.x -
183
- el.parentElement.getBoundingClientRect().x +
184
- (parseInt(_speccer_el.rect.width, 10) - parseInt(_speccer_el.styles.paddingRight, 10))
185
- ) + 'px',
186
- top: css.normalizeNumberValue(_speccer_el.rect.y - el.parentElement.getBoundingClientRect().y) + 'px'
187
- });
188
-
189
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
190
- node.after(el.closest('table'), _speccer_padding_right_el);
191
- } else {
192
- node.after(el, _speccer_padding_right_el);
193
- }
194
- }
195
-
196
- if (_speccer_el.styles['paddingLeft'] !== '0px') {
197
- const _speccer_padding_left_el = create(css.getNumberValue(_speccer_el.styles.paddingLeft));
198
-
199
- classnames.set(_speccer_padding_left_el, 'padding left');
200
-
201
- styles.add(_speccer_padding_left_el, {
202
- height: _speccer_el.rect.height + 'px',
203
- width: _speccer_el.styles.paddingLeft,
204
- left: css.normalizeNumberValue(_speccer_el.rect.x - el.parentElement.getBoundingClientRect().x) + 'px',
205
- top: css.normalizeNumberValue(_speccer_el.rect.y - el.parentElement.getBoundingClientRect().y) + 'px'
206
- });
207
-
208
- if (SPECCER_TAGS_TO_AVOID.indexOf(el.nodeName) >= 0) {
209
- node.after(el.closest('table'), _speccer_padding_left_el);
210
- } else {
211
- node.after(el, _speccer_padding_left_el);
212
- }
213
- }
214
- };