@phun-ky/speccer 6.0.0 → 6.0.3
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 +7 -1
- package/speccer.css +0 -5
- package/speccer.js +1 -1
- package/speccer.js.map +1 -1
- package/speccer.min.css +1 -1
- package/CHANGELOG.md +0 -78
- package/dts/browser.d.ts +0 -4
- package/dts/enums/area.d.ts +0 -16
- package/dts/helpers/dissect/index.d.ts +0 -1
- package/dts/helpers/dissect/styles.d.ts +0 -1
- package/dts/helpers/typography/index.d.ts +0 -2
- package/dts/helpers/typography/position.d.ts +0 -4
- package/dts/helpers/typography/template.d.ts +0 -1
- package/dts/index.d.ts +0 -53
- package/dts/interfaces/global.d.ts +0 -6
- package/dts/lib/attributes.d.ts +0 -2
- package/dts/lib/classnames.d.ts +0 -4
- package/dts/lib/constants.d.ts +0 -3
- package/dts/lib/css.d.ts +0 -6
- package/dts/lib/debounce.d.ts +0 -3
- package/dts/lib/node.d.ts +0 -2
- package/dts/lib/number.d.ts +0 -1
- package/dts/lib/position.d.ts +0 -6
- package/dts/lib/resize.d.ts +0 -1
- package/dts/lib/styles.d.ts +0 -2
- package/dts/tasks/dissect.d.ts +0 -2
- package/dts/tasks/index.d.ts +0 -4
- package/dts/tasks/measure.d.ts +0 -1
- package/dts/tasks/spec.d.ts +0 -2
- package/dts/tasks/typography.d.ts +0 -2
- package/dts/types/css.d.ts +0 -19
- package/dts/types/speccer.d.ts +0 -5
- package/src/browser.ts +0 -96
- package/src/enums/area.ts +0 -17
- package/src/helpers/dissect/index.ts +0 -1
- package/src/helpers/dissect/styles.ts +0 -154
- package/src/helpers/typography/index.ts +0 -3
- package/src/helpers/typography/position.ts +0 -54
- package/src/helpers/typography/template.ts +0 -27
- package/src/index.ts +0 -36
- package/src/interfaces/global.ts +0 -7
- package/src/lib/attributes.ts +0 -18
- package/src/lib/classnames.ts +0 -43
- package/src/lib/constants.ts +0 -8
- package/src/lib/css.ts +0 -45
- package/src/lib/debounce.ts +0 -29
- package/src/lib/node.ts +0 -8
- package/src/lib/number.ts +0 -4
- package/src/lib/position.ts +0 -16
- package/src/lib/resize.ts +0 -14
- package/src/lib/styles.ts +0 -31
- package/src/styles/anatomy.styl +0 -274
- package/src/styles/index.styl +0 -72
- package/src/styles/measure.styl +0 -88
- package/src/styles/spacing.styl +0 -142
- package/src/styles/typography.styl +0 -85
- package/src/tasks/dissect.ts +0 -46
- package/src/tasks/index.ts +0 -7
- package/src/tasks/measure.ts +0 -82
- package/src/tasks/spec.ts +0 -170
- package/src/tasks/typography.ts +0 -45
- package/src/types/css.ts +0 -20
- package/src/types/speccer.ts +0 -6
- package/tsconfig.json +0 -21
- package/tslint.json +0 -23
package/dts/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
interface Window {
|
|
3
|
-
speccer: any;
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
declare const create$2: (text?: string | number, tag?: string) => HTMLElement;
|
|
8
|
-
declare const element$3: (el: HTMLElement) => Promise<void>;
|
|
9
|
-
|
|
10
|
-
declare namespace __spacing {
|
|
11
|
-
export {
|
|
12
|
-
create$2 as create,
|
|
13
|
-
element$3 as element,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
declare const create$1: (textContent: string | undefined, area: string, n?: string) => HTMLElement;
|
|
18
|
-
declare const element$2: (el: HTMLElement, dissectIndex: number) => Promise<void>;
|
|
19
|
-
|
|
20
|
-
declare namespace __dissect {
|
|
21
|
-
export {
|
|
22
|
-
create$1 as create,
|
|
23
|
-
element$2 as element,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare const element$1: (el: HTMLElement) => void;
|
|
28
|
-
|
|
29
|
-
declare namespace __measure {
|
|
30
|
-
export {
|
|
31
|
-
element$1 as element,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
declare const create: (html: string, area: string | null) => HTMLDivElement;
|
|
36
|
-
declare const element: (el: HTMLElement) => Promise<void>;
|
|
37
|
-
|
|
38
|
-
declare const __typography_create: typeof create;
|
|
39
|
-
declare const __typography_element: typeof element;
|
|
40
|
-
declare namespace __typography {
|
|
41
|
-
export {
|
|
42
|
-
__typography_create as create,
|
|
43
|
-
__typography_element as element,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
declare const spacing: typeof __spacing;
|
|
48
|
-
declare const dissect: typeof __dissect;
|
|
49
|
-
declare const measure: typeof __measure;
|
|
50
|
-
declare const typography: typeof __typography;
|
|
51
|
-
declare const speccer: () => void;
|
|
52
|
-
|
|
53
|
-
export { speccer as default, dissect, measure, spacing, typography };
|
package/dts/lib/attributes.d.ts
DELETED
package/dts/lib/classnames.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare const set: (el: HTMLElement, cls: string, avoid?: string) => void;
|
|
2
|
-
export declare const toggle: (el: HTMLElement, cls: string, avoid?: string) => void;
|
|
3
|
-
export declare const remove: (el: HTMLElement, cls: string, avoid?: string) => void;
|
|
4
|
-
export declare const cx: (cls: string, cls_obj: {}) => string;
|
package/dts/lib/constants.d.ts
DELETED
package/dts/lib/css.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { SpacingCSSPropertiesType, TypographyCSSPropertiesType } from '../types/css';
|
|
2
|
-
export declare const getNumberValue: (value: string) => number;
|
|
3
|
-
export declare const normalizeNumberValue: (value: string | number) => number;
|
|
4
|
-
export declare const getSpacing: (style: SpacingCSSPropertiesType) => SpacingCSSPropertiesType;
|
|
5
|
-
export declare const getTypography: (style: TypographyCSSPropertiesType) => TypographyCSSPropertiesType;
|
|
6
|
-
export declare const pinSpace: (el: HTMLElement) => number;
|
package/dts/lib/debounce.d.ts
DELETED
package/dts/lib/node.d.ts
DELETED
package/dts/lib/number.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const decimal: (number: string | number, decimals?: number) => string;
|
package/dts/lib/position.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const get_horizontal_center_of_els: (modifier: number, startRect: DOMRect, targetRect: DOMRect) => number;
|
|
2
|
-
export declare const get_vertical_center_of_els: (modifier: number, startRect: DOMRect, targetRect: DOMRect) => number;
|
|
3
|
-
export declare const get_body_correction: () => {
|
|
4
|
-
top: number;
|
|
5
|
-
left: number;
|
|
6
|
-
};
|
package/dts/lib/resize.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const activate: (speccer: Function) => void;
|
package/dts/lib/styles.d.ts
DELETED
package/dts/tasks/dissect.d.ts
DELETED
package/dts/tasks/index.d.ts
DELETED
package/dts/tasks/measure.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const element: (el: HTMLElement) => void;
|
package/dts/tasks/spec.d.ts
DELETED
package/dts/types/css.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare type SpacingCSSPropertiesType = {
|
|
2
|
-
marginTop: string;
|
|
3
|
-
marginBottom: string;
|
|
4
|
-
marginLeft: string;
|
|
5
|
-
marginRight: string;
|
|
6
|
-
paddingTop: string;
|
|
7
|
-
paddingBottom: string;
|
|
8
|
-
paddingLeft: string;
|
|
9
|
-
paddingRight: string;
|
|
10
|
-
};
|
|
11
|
-
export declare type TypographyCSSPropertiesType = {
|
|
12
|
-
lineHeight: string;
|
|
13
|
-
letterSpacing: string;
|
|
14
|
-
fontFamily: string;
|
|
15
|
-
fontSize: string;
|
|
16
|
-
fontStyle: string;
|
|
17
|
-
fontVariationSettings: string;
|
|
18
|
-
fontWeight: string;
|
|
19
|
-
};
|
package/dts/types/speccer.d.ts
DELETED
package/src/browser.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import * as resize from './lib/resize';
|
|
5
|
-
import * as spec from './tasks/spec';
|
|
6
|
-
import * as measure from './tasks/measure';
|
|
7
|
-
import * as dissect from './tasks/dissect';
|
|
8
|
-
|
|
9
|
-
export const dom = (speccer: Function) => {
|
|
10
|
-
if (document.readyState === 'loading') {
|
|
11
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
12
|
-
speccer();
|
|
13
|
-
});
|
|
14
|
-
} else {
|
|
15
|
-
// `DOMContentLoaded` already fired
|
|
16
|
-
speccer();
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const lazy = () => {
|
|
21
|
-
const _spec_observer = new IntersectionObserver((els, observer) => {
|
|
22
|
-
els.forEach((el: IntersectionObserverEntry) => {
|
|
23
|
-
if (el.intersectionRatio > 0) {
|
|
24
|
-
spec.element(el.target as HTMLElement);
|
|
25
|
-
observer.unobserve(el.target);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
document.querySelectorAll('[data-speccer],[data-speccer] *:not(td)').forEach((el) => {
|
|
31
|
-
_spec_observer.observe(el);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const _measure_observer = new IntersectionObserver((els, observer) => {
|
|
35
|
-
els.forEach((el) => {
|
|
36
|
-
if (el.intersectionRatio > 0) {
|
|
37
|
-
measure.element(el.target as HTMLElement);
|
|
38
|
-
observer.unobserve(el.target);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
document.querySelectorAll('[data-speccer-measure]').forEach((el) => {
|
|
44
|
-
_measure_observer.observe(el);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const _dissect_observer = new IntersectionObserver((els, observer) => {
|
|
48
|
-
els.forEach((el) => {
|
|
49
|
-
const targets = el.target.querySelectorAll('[data-anatomy]');
|
|
50
|
-
|
|
51
|
-
if (el.intersectionRatio > 0) {
|
|
52
|
-
targets.forEach(dissect.element);
|
|
53
|
-
observer.unobserve(el.target);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
document.querySelectorAll('[data-anatomy-section]').forEach((el) => {
|
|
59
|
-
_dissect_observer.observe(el);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const manual = (speccer: Function) => {
|
|
64
|
-
window.speccer = speccer;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const activate = (speccer: Function) => {
|
|
68
|
-
const _script = document.currentScript;
|
|
69
|
-
|
|
70
|
-
if (_script) {
|
|
71
|
-
const _speccer_script_src = _script.getAttribute('src');
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
_speccer_script_src &&
|
|
75
|
-
(_speccer_script_src.indexOf('speccer.js') !== -1 ||
|
|
76
|
-
// for codepen
|
|
77
|
-
_speccer_script_src.indexOf('JaXpOK.js') !== -1)
|
|
78
|
-
) {
|
|
79
|
-
if (_script.hasAttribute('data-manual')) {
|
|
80
|
-
manual(speccer);
|
|
81
|
-
} else if (_script.hasAttribute('data-instant')) {
|
|
82
|
-
speccer();
|
|
83
|
-
} else if (_script.hasAttribute('data-dom')) {
|
|
84
|
-
dom(speccer);
|
|
85
|
-
} else if (_script.hasAttribute('data-lazy')) {
|
|
86
|
-
lazy();
|
|
87
|
-
} else {
|
|
88
|
-
dom(speccer);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (!_script.hasAttribute('data-manual') && !_script.hasAttribute('data-lazy')) {
|
|
92
|
-
resize.activate(speccer);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
package/src/enums/area.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export enum SpeccerAreaEnum {
|
|
2
|
-
Empty = '',
|
|
3
|
-
Left = 'left',
|
|
4
|
-
Right = 'right',
|
|
5
|
-
Bottom = 'bottom',
|
|
6
|
-
Top = 'top',
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export enum DissectAreaEnum {
|
|
10
|
-
Outline = 'outline',
|
|
11
|
-
Enclose = 'enclose',
|
|
12
|
-
Full = 'full',
|
|
13
|
-
Left = 'left',
|
|
14
|
-
Right = 'right',
|
|
15
|
-
Bottom = 'bottom',
|
|
16
|
-
Top = 'top',
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { styles } from './styles';
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import * as css from '../../lib/css';
|
|
2
|
-
import * as number from '../../lib/number';
|
|
3
|
-
import { get_body_correction } from '../../lib/position';
|
|
4
|
-
import { get_horizontal_center_of_els, get_vertical_center_of_els } from '../../lib/position';
|
|
5
|
-
import { DissectAreaEnum } from '../../enums/area';
|
|
6
|
-
|
|
7
|
-
export const styles = (area: string, el: HTMLElement, dissectionEl: HTMLElement) => {
|
|
8
|
-
const _el_rect = el.getBoundingClientRect();
|
|
9
|
-
const SPECCER_PIN_SPACE = css.pinSpace(dissectionEl);
|
|
10
|
-
const _dissection_el_rect = dissectionEl.getBoundingClientRect();
|
|
11
|
-
const _body_correction = get_body_correction();
|
|
12
|
-
const _el_offset_top = el.offsetTop + _body_correction.top;
|
|
13
|
-
const _el_offset_left = el.offsetLeft + _body_correction.left;
|
|
14
|
-
const _left_layout_position_left = _el_offset_left - _dissection_el_rect.width - SPECCER_PIN_SPACE + 'px';
|
|
15
|
-
const _left_layout_position_top =
|
|
16
|
-
number.decimal(get_vertical_center_of_els(_el_offset_top, _dissection_el_rect, _el_rect)) + 'px';
|
|
17
|
-
const _right_layout_position_left = _el_offset_left + _el_rect.width + SPECCER_PIN_SPACE + 'px';
|
|
18
|
-
const _right_layout_position_top =
|
|
19
|
-
number.decimal(get_vertical_center_of_els(_el_offset_top, _dissection_el_rect, _el_rect)) + 'px';
|
|
20
|
-
const _top_layout_position_left =
|
|
21
|
-
number.decimal(get_horizontal_center_of_els(_el_offset_left, _dissection_el_rect, _el_rect)) + 'px';
|
|
22
|
-
const _top_layout_position_top = _el_offset_top - _dissection_el_rect.height - SPECCER_PIN_SPACE + 'px';
|
|
23
|
-
const _bottom_layout_position_left =
|
|
24
|
-
number.decimal(get_horizontal_center_of_els(_el_offset_left, _dissection_el_rect, _el_rect)) + 'px';
|
|
25
|
-
const _bottom_layout_position_top = _el_offset_top + _el_rect.height + SPECCER_PIN_SPACE + 'px';
|
|
26
|
-
|
|
27
|
-
let _dissection_styles = {};
|
|
28
|
-
|
|
29
|
-
if (area.indexOf(DissectAreaEnum.Outline) !== -1) {
|
|
30
|
-
if (area.indexOf(DissectAreaEnum.Left) !== -1) {
|
|
31
|
-
if (area.indexOf(DissectAreaEnum.Full) !== -1) {
|
|
32
|
-
_dissection_styles = {
|
|
33
|
-
left: _el_offset_left - 8 + 'px',
|
|
34
|
-
top: _el_offset_top + -1 + 'px',
|
|
35
|
-
height: _el_rect.height + 'px'
|
|
36
|
-
};
|
|
37
|
-
} else if (area.indexOf(DissectAreaEnum.Enclose) !== -1) {
|
|
38
|
-
_dissection_styles = {
|
|
39
|
-
left: _el_offset_left - 1 + 'px',
|
|
40
|
-
top: _el_offset_top + -1 + 'px',
|
|
41
|
-
height: _el_rect.height + 'px',
|
|
42
|
-
width: _el_rect.width + 'px'
|
|
43
|
-
};
|
|
44
|
-
} else {
|
|
45
|
-
_dissection_styles = {
|
|
46
|
-
left: _left_layout_position_left,
|
|
47
|
-
top: _left_layout_position_top
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
} else if (area.indexOf(DissectAreaEnum.Right) !== -1) {
|
|
51
|
-
if (area.indexOf(DissectAreaEnum.Full) !== -1) {
|
|
52
|
-
_dissection_styles = {
|
|
53
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
54
|
-
top: _el_offset_top + -1 + 'px',
|
|
55
|
-
height: _el_rect.height + 'px'
|
|
56
|
-
};
|
|
57
|
-
} else if (area.indexOf(DissectAreaEnum.Enclose) !== -1) {
|
|
58
|
-
_dissection_styles = {
|
|
59
|
-
left: _el_offset_left + -1 + 'px',
|
|
60
|
-
top: _el_offset_top + -1 + 'px',
|
|
61
|
-
height: _el_rect.height + 'px',
|
|
62
|
-
width: _el_rect.width + 'px'
|
|
63
|
-
};
|
|
64
|
-
} else {
|
|
65
|
-
_dissection_styles = {
|
|
66
|
-
left: _right_layout_position_left,
|
|
67
|
-
top: _right_layout_position_top
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
} else if (area.indexOf(DissectAreaEnum.Top) !== -1) {
|
|
71
|
-
if (area.indexOf(DissectAreaEnum.Full) !== -1) {
|
|
72
|
-
_dissection_styles = {
|
|
73
|
-
top: _el_offset_top + -8 + 'px',
|
|
74
|
-
left: _el_offset_left + -1 + 'px',
|
|
75
|
-
width: _el_rect.width + 'px'
|
|
76
|
-
};
|
|
77
|
-
} else if (area.indexOf(DissectAreaEnum.Enclose) !== -1) {
|
|
78
|
-
_dissection_styles = {
|
|
79
|
-
top: _el_offset_top + -1 + 'px',
|
|
80
|
-
left: _el_offset_left + -1 + 'px',
|
|
81
|
-
height: _el_rect.height + 'px',
|
|
82
|
-
width: _el_rect.width + 'px'
|
|
83
|
-
};
|
|
84
|
-
} else {
|
|
85
|
-
_dissection_styles = {
|
|
86
|
-
left: _top_layout_position_left,
|
|
87
|
-
top: _top_layout_position_top
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
} else if (area.indexOf(DissectAreaEnum.Bottom) !== -1) {
|
|
91
|
-
if (area.indexOf(DissectAreaEnum.Full) !== -1) {
|
|
92
|
-
_dissection_styles = {
|
|
93
|
-
top: _el_offset_top + _el_rect.height + 'px',
|
|
94
|
-
left: _el_offset_left + -1 + 'px',
|
|
95
|
-
width: _el_rect.width + 'px'
|
|
96
|
-
};
|
|
97
|
-
} else if (area.indexOf(DissectAreaEnum.Enclose) !== -1) {
|
|
98
|
-
_dissection_styles = {
|
|
99
|
-
top: _el_offset_top + -1 + 'px',
|
|
100
|
-
left: _el_offset_left + -1 + 'px',
|
|
101
|
-
height: _el_rect.height + 'px',
|
|
102
|
-
width: _el_rect.width + 'px'
|
|
103
|
-
};
|
|
104
|
-
} else {
|
|
105
|
-
_dissection_styles = {
|
|
106
|
-
left: _bottom_layout_position_left,
|
|
107
|
-
top: _bottom_layout_position_top
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
if (area.indexOf(DissectAreaEnum.Full) !== -1) {
|
|
112
|
-
_dissection_styles = {
|
|
113
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
114
|
-
top: _el_offset_top + 'px',
|
|
115
|
-
height: _el_rect.height + 'px'
|
|
116
|
-
};
|
|
117
|
-
} else if (area.indexOf(DissectAreaEnum.Enclose) !== -1) {
|
|
118
|
-
_dissection_styles = {
|
|
119
|
-
left: _el_offset_left + _el_rect.width + 'px',
|
|
120
|
-
top: _el_offset_top + -1 + 'px',
|
|
121
|
-
height: _el_rect.height + 'px',
|
|
122
|
-
width: _el_rect.width + 'px'
|
|
123
|
-
};
|
|
124
|
-
} else {
|
|
125
|
-
_dissection_styles = {
|
|
126
|
-
left: _left_layout_position_left,
|
|
127
|
-
top: _left_layout_position_top
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
if (area.indexOf(DissectAreaEnum.Full) !== -1) {
|
|
133
|
-
_dissection_styles = {
|
|
134
|
-
left: _el_offset_left - 8 + 'px',
|
|
135
|
-
top: _el_offset_top + -1 + 'px',
|
|
136
|
-
height: _el_rect.height + 'px'
|
|
137
|
-
};
|
|
138
|
-
} else if (area.indexOf(DissectAreaEnum.Enclose) !== -1) {
|
|
139
|
-
_dissection_styles = {
|
|
140
|
-
left: _el_offset_left - 1 + 'px',
|
|
141
|
-
top: _el_offset_top + -1 + 'px',
|
|
142
|
-
height: _el_rect.height + 'px',
|
|
143
|
-
width: _el_rect.width + 'px'
|
|
144
|
-
};
|
|
145
|
-
} else {
|
|
146
|
-
_dissection_styles = {
|
|
147
|
-
left: _left_layout_position_left,
|
|
148
|
-
top: _left_layout_position_top
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return _dissection_styles;
|
|
154
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as css from '../../lib/css';
|
|
2
|
-
import * as number from '../../lib/number';
|
|
3
|
-
import { get_body_correction } from '../../lib/position';
|
|
4
|
-
import { get_horizontal_center_of_els, get_vertical_center_of_els } from '../../lib/position';
|
|
5
|
-
import { SpeccerAreaEnum } from '../../enums/area';
|
|
6
|
-
|
|
7
|
-
export const position = (
|
|
8
|
-
area: string | null,
|
|
9
|
-
el: HTMLElement,
|
|
10
|
-
speccerEl: HTMLElement
|
|
11
|
-
): { left: string; top: string } => {
|
|
12
|
-
const _el_rect = el.getBoundingClientRect();
|
|
13
|
-
const SPECCER_PIN_SPACE = css.pinSpace(speccerEl);
|
|
14
|
-
const _speccer_el_rect = speccerEl.getBoundingClientRect();
|
|
15
|
-
const _body_correction = get_body_correction();
|
|
16
|
-
const _el_offset_top = el.offsetTop + _body_correction.top;
|
|
17
|
-
const _el_offset_left = el.offsetLeft + _body_correction.left;
|
|
18
|
-
const _left_layout_position_left = _el_offset_left - _speccer_el_rect.width - SPECCER_PIN_SPACE + 'px';
|
|
19
|
-
const _left_layout_position_top =
|
|
20
|
-
number.decimal(get_vertical_center_of_els(_el_offset_top, _speccer_el_rect, _el_rect)) + 'px';
|
|
21
|
-
const _right_layout_position_left = _el_offset_left + _el_rect.width + SPECCER_PIN_SPACE + 'px';
|
|
22
|
-
const _right_layout_position_top =
|
|
23
|
-
number.decimal(get_vertical_center_of_els(_el_offset_top, _speccer_el_rect, _el_rect)) + 'px';
|
|
24
|
-
const _top_layout_position_left =
|
|
25
|
-
number.decimal(get_horizontal_center_of_els(_el_offset_left, _speccer_el_rect, _el_rect)) + 'px';
|
|
26
|
-
const _top_layout_position_top = _el_offset_top - _speccer_el_rect.height - SPECCER_PIN_SPACE + 'px';
|
|
27
|
-
const _bottom_layout_position_left =
|
|
28
|
-
number.decimal(get_horizontal_center_of_els(_el_offset_left, _speccer_el_rect, _el_rect)) + 'px';
|
|
29
|
-
const _bottom_layout_position_top = _el_offset_top + _el_rect.height + SPECCER_PIN_SPACE + 'px';
|
|
30
|
-
|
|
31
|
-
let _position = {
|
|
32
|
-
left: _left_layout_position_left,
|
|
33
|
-
top: _left_layout_position_top
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
if (area && area.indexOf(SpeccerAreaEnum.Right) !== -1) {
|
|
37
|
-
_position = {
|
|
38
|
-
left: _right_layout_position_left,
|
|
39
|
-
top: _right_layout_position_top
|
|
40
|
-
};
|
|
41
|
-
} else if (area && area.indexOf(SpeccerAreaEnum.Top) !== -1) {
|
|
42
|
-
_position = {
|
|
43
|
-
left: _top_layout_position_left,
|
|
44
|
-
top: _top_layout_position_top
|
|
45
|
-
};
|
|
46
|
-
} else if (area && area.indexOf(SpeccerAreaEnum.Bottom) !== -1) {
|
|
47
|
-
_position = {
|
|
48
|
-
left: _bottom_layout_position_left,
|
|
49
|
-
top: _bottom_layout_position_top
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return _position;
|
|
54
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as css from '../../lib/css';
|
|
2
|
-
import * as styles from '../../lib/styles';
|
|
3
|
-
|
|
4
|
-
export const template = async (el: HTMLElement): Promise<string> => {
|
|
5
|
-
const _el_styles = await styles.get(el);
|
|
6
|
-
const _styles = css.getTypography(_el_styles);
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
`
|
|
10
|
-
` +
|
|
11
|
-
'font-styles: {' +
|
|
12
|
-
'<ul class="speccer-styles">' +
|
|
13
|
-
` <li><span class="property">font-family:</span> ${_styles['fontFamily']};</li>` +
|
|
14
|
-
` <li><span class="property">font-size:</span> ${_styles['fontSize']} / ${
|
|
15
|
-
parseInt(_styles['fontSize'], 10) / 16
|
|
16
|
-
}rem;</li>` +
|
|
17
|
-
` <li><span class="property">font-weight:</span> ${_styles['fontWeight']};</li>` +
|
|
18
|
-
` <li><span class="property">font-variation-settings:</span> ${_styles['fontVariationSettings']};</li>` +
|
|
19
|
-
` <li><span class="property">line-height:</span> ${_styles['lineHeight']} / ${
|
|
20
|
-
parseInt(_styles['lineHeight'], 10) / 16
|
|
21
|
-
}rem;</li>` +
|
|
22
|
-
` <li><span class="property">letter-spacing:</span> ${_styles['letterSpacing']};</li>` +
|
|
23
|
-
` <li><span class="property">font-style:</span> ${_styles['fontStyle']};</li>` +
|
|
24
|
-
'</ul>' +
|
|
25
|
-
'}'
|
|
26
|
-
);
|
|
27
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import './interfaces/global';
|
|
5
|
-
import * as __node from './lib/node';
|
|
6
|
-
import * as __spacing from './tasks/spec';
|
|
7
|
-
import * as __dissect from './tasks/dissect';
|
|
8
|
-
import * as __measure from './tasks/measure';
|
|
9
|
-
import * as __typography from './tasks/typography';
|
|
10
|
-
import * as __browser from './browser';
|
|
11
|
-
|
|
12
|
-
export const spacing = __spacing;
|
|
13
|
-
|
|
14
|
-
export const dissect = __dissect;
|
|
15
|
-
|
|
16
|
-
export const measure = __measure;
|
|
17
|
-
|
|
18
|
-
export const typography = __typography;
|
|
19
|
-
|
|
20
|
-
const speccer = () => {
|
|
21
|
-
__node.removeAll('.speccer');
|
|
22
|
-
|
|
23
|
-
const _els_to_be_specced = document.querySelectorAll('[data-speccer],[data-speccer] *:not(td)');
|
|
24
|
-
const _els_to_be_measured = document.querySelectorAll('[data-speccer-measure]');
|
|
25
|
-
const _els_to_be_typography_specced = document.querySelectorAll('[data-speccer-typography]');
|
|
26
|
-
const _els_to_be_dissected = document.querySelectorAll('[data-anatomy-section] [data-anatomy]');
|
|
27
|
-
|
|
28
|
-
_els_to_be_specced.forEach(spacing.element);
|
|
29
|
-
_els_to_be_measured.forEach(measure.element);
|
|
30
|
-
_els_to_be_typography_specced.forEach(typography.element);
|
|
31
|
-
_els_to_be_dissected.forEach(dissect.element);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export default speccer;
|
|
35
|
-
|
|
36
|
-
__browser.activate(speccer);
|
package/src/interfaces/global.ts
DELETED
package/src/lib/attributes.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
export const set = (el: HTMLElement, attrs: {}) => {
|
|
5
|
-
if (!el) return;
|
|
6
|
-
|
|
7
|
-
if (!attrs) return;
|
|
8
|
-
|
|
9
|
-
Object.keys(attrs).forEach((key) => el.setAttribute(key, attrs[key]));
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const remove = (el: HTMLElement, attrs: {}) => {
|
|
13
|
-
if (!el) return;
|
|
14
|
-
|
|
15
|
-
if (!attrs) return;
|
|
16
|
-
|
|
17
|
-
Object.keys(attrs).forEach((key) => el.removeAttribute(key));
|
|
18
|
-
};
|
package/src/lib/classnames.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* eslint no-console:0 */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
export const set = (el: HTMLElement, cls: string, avoid = 'noop') => {
|
|
5
|
-
if (!el) return;
|
|
6
|
-
|
|
7
|
-
if (!cls || (cls && cls.length === 0)) return;
|
|
8
|
-
|
|
9
|
-
cls
|
|
10
|
-
.trim()
|
|
11
|
-
.split(' ')
|
|
12
|
-
.filter((cl) => cl !== avoid)
|
|
13
|
-
.forEach((cl) => el.classList.add(cl));
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const toggle = (el: HTMLElement, cls: string, avoid = 'noop') => {
|
|
17
|
-
if (!el) return;
|
|
18
|
-
|
|
19
|
-
if (!cls || (cls && cls.length === 0)) return;
|
|
20
|
-
|
|
21
|
-
cls
|
|
22
|
-
.trim()
|
|
23
|
-
.split(' ')
|
|
24
|
-
.filter((cl) => cl !== avoid)
|
|
25
|
-
.forEach((cl) => el.classList.toggle(cl));
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const remove = (el: HTMLElement, cls: string, avoid = 'noop') => {
|
|
29
|
-
if (!el) return;
|
|
30
|
-
|
|
31
|
-
if (!cls || (cls && cls.length === 0)) return;
|
|
32
|
-
|
|
33
|
-
cls
|
|
34
|
-
.trim()
|
|
35
|
-
.split(' ')
|
|
36
|
-
.filter((cl) => cl !== avoid)
|
|
37
|
-
.forEach((cl) => el.classList.remove(cl));
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const cx = (cls: string, cls_obj: {}): string =>
|
|
41
|
-
`${cls} ${Object.keys(cls_obj)
|
|
42
|
-
.filter((classname) => cls_obj[classname])
|
|
43
|
-
.join(' ')}`.trim();
|
package/src/lib/constants.ts
DELETED