@phun-ky/speccer 6.0.0 โ†’ 6.0.1

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 (61) hide show
  1. package/package.json +7 -1
  2. package/CHANGELOG.md +0 -78
  3. package/dts/browser.d.ts +0 -4
  4. package/dts/enums/area.d.ts +0 -16
  5. package/dts/helpers/dissect/index.d.ts +0 -1
  6. package/dts/helpers/dissect/styles.d.ts +0 -1
  7. package/dts/helpers/typography/index.d.ts +0 -2
  8. package/dts/helpers/typography/position.d.ts +0 -4
  9. package/dts/helpers/typography/template.d.ts +0 -1
  10. package/dts/index.d.ts +0 -53
  11. package/dts/interfaces/global.d.ts +0 -6
  12. package/dts/lib/attributes.d.ts +0 -2
  13. package/dts/lib/classnames.d.ts +0 -4
  14. package/dts/lib/constants.d.ts +0 -3
  15. package/dts/lib/css.d.ts +0 -6
  16. package/dts/lib/debounce.d.ts +0 -3
  17. package/dts/lib/node.d.ts +0 -2
  18. package/dts/lib/number.d.ts +0 -1
  19. package/dts/lib/position.d.ts +0 -6
  20. package/dts/lib/resize.d.ts +0 -1
  21. package/dts/lib/styles.d.ts +0 -2
  22. package/dts/tasks/dissect.d.ts +0 -2
  23. package/dts/tasks/index.d.ts +0 -4
  24. package/dts/tasks/measure.d.ts +0 -1
  25. package/dts/tasks/spec.d.ts +0 -2
  26. package/dts/tasks/typography.d.ts +0 -2
  27. package/dts/types/css.d.ts +0 -19
  28. package/dts/types/speccer.d.ts +0 -5
  29. package/src/browser.ts +0 -96
  30. package/src/enums/area.ts +0 -17
  31. package/src/helpers/dissect/index.ts +0 -1
  32. package/src/helpers/dissect/styles.ts +0 -154
  33. package/src/helpers/typography/index.ts +0 -3
  34. package/src/helpers/typography/position.ts +0 -54
  35. package/src/helpers/typography/template.ts +0 -27
  36. package/src/index.ts +0 -36
  37. package/src/interfaces/global.ts +0 -7
  38. package/src/lib/attributes.ts +0 -18
  39. package/src/lib/classnames.ts +0 -43
  40. package/src/lib/constants.ts +0 -8
  41. package/src/lib/css.ts +0 -45
  42. package/src/lib/debounce.ts +0 -29
  43. package/src/lib/node.ts +0 -8
  44. package/src/lib/number.ts +0 -4
  45. package/src/lib/position.ts +0 -16
  46. package/src/lib/resize.ts +0 -14
  47. package/src/lib/styles.ts +0 -31
  48. package/src/styles/anatomy.styl +0 -274
  49. package/src/styles/index.styl +0 -72
  50. package/src/styles/measure.styl +0 -88
  51. package/src/styles/spacing.styl +0 -142
  52. package/src/styles/typography.styl +0 -85
  53. package/src/tasks/dissect.ts +0 -46
  54. package/src/tasks/index.ts +0 -7
  55. package/src/tasks/measure.ts +0 -82
  56. package/src/tasks/spec.ts +0 -170
  57. package/src/tasks/typography.ts +0 -45
  58. package/src/types/css.ts +0 -20
  59. package/src/types/speccer.ts +0 -6
  60. package/tsconfig.json +0 -21
  61. package/tslint.json +0 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phun-ky/speccer",
3
- "version": "6.0.0",
3
+ "version": "6.0.1",
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": {
@@ -19,6 +19,12 @@
19
19
  "commit": "npx git-cz",
20
20
  "release": "npx standard-version"
21
21
  },
22
+ "files": [
23
+ "/speccer.js",
24
+ "/speccer.js.map",
25
+ "/speccer.min.css",
26
+ "/speccer.css"
27
+ ],
22
28
  "standard-version": {
23
29
  "scripts": {
24
30
  "prerelease": "npm run build",
package/CHANGELOG.md DELETED
@@ -1,78 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
-
5
- ## [6.0.0](https://github.com/phun-ky/speccer/compare/v5.0.0...v6.0.0) (2022-02-23)
6
-
7
-
8
- ### โš  BREAKING CHANGES
9
-
10
- * ๐Ÿงจ The script is now converted to TypeScript. The internal API has changed,
11
- but now the usage. I've set this as a breaking change to reflect the
12
- size of the change. There has also been some internal optimizations
13
- regarding positioning of the speccer elements
14
-
15
- ### Refactoring
16
-
17
- * ๐Ÿ’ก Converted to TypeScript ([ab90bae](https://github.com/phun-ky/speccer/commit/ab90bae5794235ffd13d250500caca98b0a818b5))
18
-
19
-
20
- ### Feature
21
-
22
- * ๐ŸŽธ Add source map ([de3812d](https://github.com/phun-ky/speccer/commit/de3812dc4a28d274aabfb16cf088f78cf07b2b7e))
23
-
24
- ## [5.0.0](https://github.com/phun-ky/speccer/compare/v4.3.2...v5.0.0) (2022-02-22)
25
-
26
-
27
- ### โš  BREAKING CHANGES
28
-
29
- * ๐Ÿงจ Speccer is not supporting older browsers any more, to cut down on
30
- maintenance. Babel is now removed, but you can still polyfill or use
31
- babel for your own needs if you import the source files instead of the
32
- build files.
33
-
34
- ### Tasks
35
-
36
- * ๐Ÿค– Remove babel, do not support older browsers anymore ([9ed11c0](https://github.com/phun-ky/speccer/commit/9ed11c06da3d1ac1b80d4cbbc6859146c596cd6f))
37
-
38
- ### [4.3.2](https://github.com/phun-ky/speccer/compare/v4.3.1...v4.3.2) (2022-02-22)
39
-
40
-
41
- ### Bug
42
-
43
- * And supply the minified version.. ([8cfb69a](https://github.com/phun-ky/speccer/commit/8cfb69a5dc86f1e9c9ccea3f890781a3961a0a7f))
44
-
45
- ### [4.3.1](https://github.com/phun-ky/speccer/compare/v4.3.0...v4.3.1) (2022-02-22)
46
-
47
-
48
- ### Bug
49
-
50
- * Use named exports ([7a4535e](https://github.com/phun-ky/speccer/commit/7a4535e65c04b33365258323376d6710fcb813c3))
51
-
52
- ## [4.3.0](https://github.com/phun-ky/speccer/compare/v4.2.1...v4.3.0) (2022-02-22)
53
-
54
-
55
- ### Feature
56
-
57
- * ๐ŸŽธ Expose API a bit more ([093b465](https://github.com/phun-ky/speccer/commit/093b465653c32ec77fec6bb1d9d9e3adfd59809f))
58
-
59
-
60
- ### Documentation
61
-
62
- * โœ๏ธ Move images into assets ([2291b31](https://github.com/phun-ky/speccer/commit/2291b31d768a16f202f2ffed453cfc22f3027e67))
63
- * โœ๏ธ Update documentation ([ec0807e](https://github.com/phun-ky/speccer/commit/ec0807e8c5d9c7eeaa807b80d7c432bee24d59d4))
64
-
65
- ### [4.2.1](https://github.com/phun-ky/speccer/compare/v4.2.0...v4.2.1) (2022-02-22)
66
-
67
- ## [4.2.0](https://github.com/phun-ky/speccer/compare/v4.1.0...v4.2.0) (2022-02-22)
68
-
69
-
70
- ### Features
71
-
72
- * Use CSS variables ([21c3eb3](https://github.com/phun-ky/speccer/commit/21c3eb3f173ee96b0bf452bae44f76155fcf3cdf))
73
-
74
- ## [4.1.0](https://github.com/phun-ky/speccer/compare/v4.0.0...v4.1.0) (2022-02-22)
75
-
76
- ### Features
77
-
78
- - Add release script ([4cb72cb](https://github.com/phun-ky/speccer/commit/4cb72cbea7dd1d6bcb8f1102384b14eecaa9eef0))
package/dts/browser.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const dom: (speccer: Function) => void;
2
- export declare const lazy: () => void;
3
- export declare const manual: (speccer: Function) => void;
4
- export declare const activate: (speccer: Function) => void;
@@ -1,16 +0,0 @@
1
- export declare enum SpeccerAreaEnum {
2
- Empty = "",
3
- Left = "left",
4
- Right = "right",
5
- Bottom = "bottom",
6
- Top = "top"
7
- }
8
- export declare enum DissectAreaEnum {
9
- Outline = "outline",
10
- Enclose = "enclose",
11
- Full = "full",
12
- Left = "left",
13
- Right = "right",
14
- Bottom = "bottom",
15
- Top = "top"
16
- }
@@ -1 +0,0 @@
1
- export { styles } from './styles';
@@ -1 +0,0 @@
1
- export declare const styles: (area: string, el: HTMLElement, dissectionEl: HTMLElement) => {};
@@ -1,2 +0,0 @@
1
- export { position } from './position';
2
- export { template } from './template';
@@ -1,4 +0,0 @@
1
- export declare const position: (area: string | null, el: HTMLElement, speccerEl: HTMLElement) => {
2
- left: string;
3
- top: string;
4
- };
@@ -1 +0,0 @@
1
- export declare const template: (el: HTMLElement) => Promise<string>;
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 };
@@ -1,6 +0,0 @@
1
- export {};
2
- declare global {
3
- interface Window {
4
- speccer: any;
5
- }
6
- }
@@ -1,2 +0,0 @@
1
- export declare const set: (el: HTMLElement, attrs: {}) => void;
2
- export declare const remove: (el: HTMLElement, attrs: {}) => void;
@@ -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;
@@ -1,3 +0,0 @@
1
- export declare const SPECCER_LITERALS: string[];
2
- export declare const SPECCER_TAGS_TO_AVOID: string[];
3
- export declare const SPECCER_DEFAULT_PIN_SPACE = 48;
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;
@@ -1,3 +0,0 @@
1
- export declare const waitForFrame: () => Promise<number>;
2
- declare const debounce: (func: Function, wait: number, immediate?: boolean | undefined) => Function;
3
- export default debounce;
package/dts/lib/node.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const after: (el: HTMLElement | null, newSibling: HTMLElement) => Element | null;
2
- export declare const removeAll: (selector: string, el?: Document) => void;
@@ -1 +0,0 @@
1
- export declare const decimal: (number: string | number, decimals?: number) => string;
@@ -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
- };
@@ -1 +0,0 @@
1
- export declare const activate: (speccer: Function) => void;
@@ -1,2 +0,0 @@
1
- export declare const add: (el: HTMLElement, styles: [] | object) => Promise<void>;
2
- export declare const get: (el: HTMLElement) => Promise<CSSStyleDeclaration>;
@@ -1,2 +0,0 @@
1
- export declare const create: (textContent: string | undefined, area: string, n?: string) => HTMLElement;
2
- export declare const element: (el: HTMLElement, dissectIndex: number) => Promise<void>;
@@ -1,4 +0,0 @@
1
- export * as typography from './typography';
2
- export * as dissect from './dissect';
3
- export * as measure from './measure';
4
- export * as spec from './spec';
@@ -1 +0,0 @@
1
- export declare const element: (el: HTMLElement) => void;
@@ -1,2 +0,0 @@
1
- export declare const create: (text?: string | number, tag?: string) => HTMLElement;
2
- export declare const element: (el: HTMLElement) => Promise<void>;
@@ -1,2 +0,0 @@
1
- export declare const create: (html: string, area: string | null) => HTMLDivElement;
2
- export declare const element: (el: HTMLElement) => Promise<void>;
@@ -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
- };
@@ -1,5 +0,0 @@
1
- import { SpacingCSSPropertiesType } from './css';
2
- export declare type SpeccerElType = {
3
- styles?: SpacingCSSPropertiesType;
4
- rect?: DOMRectReadOnly;
5
- };
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,3 +0,0 @@
1
- export { position } from './position';
2
-
3
- export { template } from './template';
@@ -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
- };