@caweb/framework 1.9.3 → 1.9.4

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 (101) hide show
  1. package/build/delta.asset.php +1 -1
  2. package/build/delta.css +1 -0
  3. package/build/delta.js +1 -1
  4. package/build/eureka.asset.php +1 -1
  5. package/build/eureka.css +1 -0
  6. package/build/eureka.js +1 -1
  7. package/build/mono.asset.php +1 -1
  8. package/build/mono.css +1 -0
  9. package/build/mono.js +1 -1
  10. package/build/oceanside.asset.php +1 -1
  11. package/build/oceanside.css +1 -0
  12. package/build/oceanside.js +1 -1
  13. package/build/orangecounty.asset.php +1 -1
  14. package/build/orangecounty.css +1 -0
  15. package/build/orangecounty.js +1 -1
  16. package/build/pasorobles.asset.php +1 -1
  17. package/build/pasorobles.css +1 -0
  18. package/build/pasorobles.js +1 -1
  19. package/build/sacramento.asset.php +1 -1
  20. package/build/sacramento.css +1 -0
  21. package/build/sacramento.js +1 -1
  22. package/build/santabarbara.asset.php +1 -1
  23. package/build/santabarbara.css +1 -0
  24. package/build/santabarbara.js +1 -1
  25. package/build/santacruz.asset.php +1 -1
  26. package/build/santacruz.css +1 -0
  27. package/build/santacruz.js +1 -1
  28. package/build/shasta.asset.php +1 -1
  29. package/build/shasta.css +1 -0
  30. package/build/shasta.js +1 -1
  31. package/build/sierra.asset.php +1 -1
  32. package/build/sierra.css +1 -0
  33. package/build/sierra.js +1 -1
  34. package/build/trinity.asset.php +1 -1
  35. package/build/trinity.css +1 -0
  36. package/build/trinity.js +1 -1
  37. package/package.json +4 -4
  38. package/src/scripts/components/header.js +62 -32
  39. package/src/styles/components/structural/_header.scss +1 -1
  40. package/src/styles/components/structural/_type.scss +3 -2
  41. package/src/styles/index.scss +1 -1
  42. package/build/delta.min.asset.php +0 -1
  43. package/build/delta.min.css +0 -23
  44. package/build/delta.min.css.map +0 -1
  45. package/build/delta.min.js +0 -2
  46. package/build/delta.min.js.map +0 -1
  47. package/build/eureka.min.asset.php +0 -1
  48. package/build/eureka.min.css +0 -23
  49. package/build/eureka.min.css.map +0 -1
  50. package/build/eureka.min.js +0 -2
  51. package/build/eureka.min.js.map +0 -1
  52. package/build/mono.min.asset.php +0 -1
  53. package/build/mono.min.css +0 -23
  54. package/build/mono.min.css.map +0 -1
  55. package/build/mono.min.js +0 -2
  56. package/build/mono.min.js.map +0 -1
  57. package/build/oceanside.min.asset.php +0 -1
  58. package/build/oceanside.min.css +0 -23
  59. package/build/oceanside.min.css.map +0 -1
  60. package/build/oceanside.min.js +0 -2
  61. package/build/oceanside.min.js.map +0 -1
  62. package/build/orangecounty.min.asset.php +0 -1
  63. package/build/orangecounty.min.css +0 -23
  64. package/build/orangecounty.min.css.map +0 -1
  65. package/build/orangecounty.min.js +0 -2
  66. package/build/orangecounty.min.js.map +0 -1
  67. package/build/pasorobles.min.asset.php +0 -1
  68. package/build/pasorobles.min.css +0 -23
  69. package/build/pasorobles.min.css.map +0 -1
  70. package/build/pasorobles.min.js +0 -2
  71. package/build/pasorobles.min.js.map +0 -1
  72. package/build/sacramento.min.asset.php +0 -1
  73. package/build/sacramento.min.css +0 -23
  74. package/build/sacramento.min.css.map +0 -1
  75. package/build/sacramento.min.js +0 -2
  76. package/build/sacramento.min.js.map +0 -1
  77. package/build/santabarbara.min.asset.php +0 -1
  78. package/build/santabarbara.min.css +0 -23
  79. package/build/santabarbara.min.css.map +0 -1
  80. package/build/santabarbara.min.js +0 -2
  81. package/build/santabarbara.min.js.map +0 -1
  82. package/build/santacruz.min.asset.php +0 -1
  83. package/build/santacruz.min.css +0 -23
  84. package/build/santacruz.min.css.map +0 -1
  85. package/build/santacruz.min.js +0 -2
  86. package/build/santacruz.min.js.map +0 -1
  87. package/build/shasta.min.asset.php +0 -1
  88. package/build/shasta.min.css +0 -23
  89. package/build/shasta.min.css.map +0 -1
  90. package/build/shasta.min.js +0 -2
  91. package/build/shasta.min.js.map +0 -1
  92. package/build/sierra.min.asset.php +0 -1
  93. package/build/sierra.min.css +0 -23
  94. package/build/sierra.min.css.map +0 -1
  95. package/build/sierra.min.js +0 -2
  96. package/build/sierra.min.js.map +0 -1
  97. package/build/trinity.min.asset.php +0 -1
  98. package/build/trinity.min.css +0 -23
  99. package/build/trinity.min.css.map +0 -1
  100. package/build/trinity.min.js +0 -2
  101. package/build/trinity.min.js.map +0 -1
@@ -2,9 +2,36 @@
2
2
  window.addEventListener('DOMContentLoaded', () => {
3
3
  let location_hash = window.location.hash.replace(/(\|)/g, "\\$1");
4
4
 
5
- const header = document.querySelector('header');
6
- const alerts = document.querySelector('.alerts');
7
- const utilityHeader = document.querySelector('.utility-header');
5
+ const header = document.querySelector('header') ;
6
+ const pageContainer = document.querySelector('#page-container');
7
+
8
+ // array of elements that are compacted
9
+ const compactedElements = [
10
+ document.querySelector('.alerts'),
11
+ document.querySelector('.utility-header'),
12
+ ].filter(Boolean);
13
+
14
+ let compactedElementsHeight = compactedElements.reduce((total, element) => {
15
+ if( element instanceof HTMLElement ){
16
+ return total + element.clientHeight;
17
+ }
18
+
19
+ return total;
20
+
21
+ }, 0);
22
+
23
+ // lets collect the height of any fixed elements above the header.
24
+ let topOffset = 0;
25
+ let current = header?.previousElementSibling;
26
+
27
+ while( current ){
28
+ // if current element has a fixed position, add its height to the topOffset.
29
+ if( current instanceof HTMLElement && window.getComputedStyle(current).position === 'fixed' ){
30
+ topOffset += current.clientHeight ;
31
+ }
32
+ current = current.previousElementSibling;
33
+ }
34
+
8
35
 
9
36
  // scroll to target
10
37
  if( location_hash ){
@@ -12,61 +39,64 @@ window.addEventListener('DOMContentLoaded', () => {
12
39
  let target = document.getElementById(location_hash.substring(1));
13
40
 
14
41
  // if the location hash is not empty, we scroll to the target element
15
- setTimeout(() => {
42
+ requestAnimationFrame(() => {
16
43
  target?.scrollIntoView({
17
44
  behavior: 'smooth'
18
45
  });
19
- }, 1000);
46
+ });
20
47
  }
21
48
 
22
49
  if (!header) {
23
50
  return;
24
51
  }
52
+
25
53
 
26
54
  const compactHeader = () => {
27
- let scrollHeights = 0;
28
-
29
- // lets collect the height of any elements above the header.
30
- let current = header.previousElementSibling;
31
- let miscElementHeights = 0;
32
-
33
- while( current ){
34
- // if current is a div, add its height to the miscElementHeights.
35
- if( 'DIV' === current.tagName ){
36
- miscElementHeights += current.clientHeight ;
37
- }
38
- current = current.previousElementSibling;
39
- }
40
55
 
41
56
  // downscroll code passed the header height
42
57
  if (document.body.scrollTop >= header.offsetHeight ||
43
58
  document.documentElement.scrollTop >= header.offsetHeight
44
59
  ) {
45
- // lets add the scroll heights of any alerts
46
- if( alerts ){
47
- scrollHeights += alerts.clientHeight;
48
- }
49
-
50
- // lets add the scroll heights of the utility header
51
- if( utilityHeader ){
52
- scrollHeights += utilityHeader.clientHeight;
53
- }
54
-
55
- // move the header up to the scroll height, minus any elements above the header
56
- header.style.top = `-${(scrollHeights - miscElementHeights)}px`;
60
+ // move the header up to hide the compacted elements height, minus the top offset.
61
+ header.style.top = `-${(compactedElementsHeight - topOffset)}px`;
57
62
 
58
63
  } else {
59
64
  // reset header to initial position
60
- header.style.top = `${miscElementHeights}px`;
65
+ // we need to set the header's top to the offset.
66
+ if( header ){
67
+ header.style.top = `${topOffset}px`;
68
+ }
69
+
70
+ // if we have a page container, we need to set its top padding to the offset
71
+ if( pageContainer && pageContainer instanceof HTMLElement ){
72
+ pageContainer.style.paddingTop = `${topOffset}px`;
73
+ }
74
+
61
75
  }
62
76
 
63
77
  };
78
+
79
+ // for each element with an id we add the scroll-margin-top
80
+ document.querySelectorAll('#page-container [id]').forEach((element) => {
81
+ if( element instanceof HTMLElement ){
82
+ let scrollMarginHeight = header.clientHeight + topOffset;
83
+
84
+ // if the elements offsetTop is greater than twice the header size,
85
+ // we can assume the header is compacted
86
+ // so we need to subtract the compacted elements height from the scroll margin.
87
+ if( element.offsetTop > scrollMarginHeight * 2 ){
88
+ scrollMarginHeight -= compactedElementsHeight;
89
+ }
90
+
91
+ element.style.scrollMarginTop = `${scrollMarginHeight}px`;
92
+ }
93
+ });
64
94
 
65
95
  // reset position on scroll
66
96
  window.addEventListener(
67
97
  'scroll', compactHeader
68
98
  );
69
99
 
70
- compactHeader()
100
+ compactHeader();
71
101
 
72
102
  });
@@ -4,6 +4,7 @@
4
4
  ----------------------------------------- */
5
5
  header.global-header{
6
6
  position: sticky;
7
+ top: 0;
7
8
  background-color: var(--bs-white, $white);
8
9
  z-index: 15;
9
10
  transition: all 0.3s ease;
@@ -78,4 +79,3 @@ header.global-header{
78
79
  text-align: right;
79
80
  }
80
81
  }
81
-
@@ -45,7 +45,8 @@ a {
45
45
  }
46
46
  }
47
47
 
48
- // add padding to all links except buttons and Divi buttons
48
+ // add padding to all links except buttons and nav links, which have their own padding.
49
49
  #page-container a:not(.btn, .nav-link) {
50
50
  padding: .5rem 0;
51
- }
51
+ }
52
+
@@ -30,4 +30,4 @@
30
30
  // -------------------------------------------------
31
31
  // Themes
32
32
  // -------------------------------------------------
33
- @import "theme/dark";
33
+ @import "theme/dark";
@@ -1 +0,0 @@
1
- <?php return array('dependencies' => array(), 'version' => '4a99e034e3eeb401bbdf');