Skip to content

Commit 093dbbd

Browse files
Merge branch 'dev' into uds-2004
2 parents 4309338 + 14bf82c commit 093dbbd

File tree

6 files changed

+142
-27
lines changed

6 files changed

+142
-27
lines changed

packages/component-header-footer/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [@asu/component-header-footer-v1.0.10](https://github.com/asu/asu-unity-stack/compare/@asu/component-header-footer-v1.0.9...@asu/component-header-footer-v1.0.10) (2025-05-13)
2+
3+
4+
### Bug Fixes
5+
6+
* **component-header-footer:** fix footer mobile column styles ([4654ef9](https://github.com/asu/asu-unity-stack/commit/4654ef95a727261b6f73aaeeea9b5ce88f6ed813))
7+
18
# [@asu/component-header-footer-v1.0.9](https://github.com/asu/asu-unity-stack/compare/@asu/component-header-footer-v1.0.8...@asu/component-header-footer-v1.0.9) (2025-05-06)
29

310

packages/component-header-footer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@asu/component-header-footer",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "ASU Global Header and Footer",
55
"main": "./dist/asuHeaderFooter.cjs.js",
66
"browser": "./dist/asuHeaderFooter.umd.js",

packages/component-header-footer/src/footer/index.styles.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ const StyledFooter = styled.footer`
3232
a:focus,
3333
button:focus {
3434
outline: none;
35-
box-shadow: 0 0 0 2px var(--color-base-white),
36-
0 0 0 4px var(--color-base-grey-7) !important;
35+
box-shadow: 0 0 0 2px var(--color-base-white), 0 0 0 4px var(--color-base-grey-7) !important;
36+
-webkit-tap-highlight-color: transparent;
37+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
3738
}
3839
}
3940

packages/static-site/src/pages/DataLayerGuide.tsx

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { FC } from "react";
22
import { Link } from "react-router-dom";
33
import { PagePaths } from "~/routes/config";
4+
import { default as watchDataLayer } from "~/utils/watchDataLayerBookmarklet?raw";
5+
6+
export const bookmarklet = `javascript:(${watchDataLayer.toString()
7+
// remove line breaks
8+
.replace(/\n/g,"")
9+
// remove comments
10+
.replace(/\/\*.*?\*\//g, "")
11+
// replace multiple spaces with a single space
12+
.replace(/\s+/g, " ")})();`
413

514
const gtmCodes = {
615
universal: "GTM-KDWN8Z",
@@ -16,13 +25,13 @@ const GtmCodeExample: FC<{ gtmCode: string }> = ({ gtmCode }) => {
1625
*/
1726

1827
const headScript = `
19-
<!-- Google Tag Manager -->
20-
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
21-
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
22-
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
23-
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
24-
})(window,document,'script','dataLayer','${gtmCode}');</script>
25-
<!-- End Google Tag Manager -->`;
28+
<!-- Google Tag Manager -->
29+
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
30+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
31+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
32+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
33+
})(window,document,'script','dataLayer','${gtmCode}');</script>
34+
<!-- End Google Tag Manager -->`;
2635
const bodyScript = `
2736
<!-- Google Tag Manager (noscript) -->
2837
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=${gtmCode}"
@@ -67,6 +76,11 @@ const DataLayerGuide = () => {
6776
Adding the data layer to your site or application
6877
</a>
6978
</li>
79+
<li>
80+
<a href="#watchdatalayer">
81+
Watching the data layer
82+
</a>
83+
</li>
7084
</ul>
7185

7286
<a id="gtm"></a>
@@ -131,7 +145,7 @@ const DataLayerGuide = () => {
131145
<p>
132146
To implement Google Tag Manager, insert the appropriate snippets
133147
found below within the body tag of your HTML as close to the top of
134-
the page as possible. Further details can be found in the
148+
the page as possible. Further details can be found in the{" "}
135149
<a href="https://developers.google.com/tag-manager/quickstart">
136150
Google Tag Manager Quickstart Guide
137151
</a>
@@ -151,7 +165,7 @@ const DataLayerGuide = () => {
151165

152166
<p>
153167
Some units have their own GTM IDs. When multiple GTM IDs need to be
154-
used in a single site or application, follow the guidance on
168+
used in a single site or application, follow the guidance on{" "}
155169
<a href="https://developers.google.com/tag-manager/devguide#multiple-containers">
156170
Multiple Containers on a Page
157171
</a>
@@ -184,7 +198,7 @@ const DataLayerGuide = () => {
184198
</p>
185199

186200
<p>
187-
Follow the instructions for
201+
Follow the instructions for{" "}
188202
<a href="https://developers.google.com/tag-platform/tag-manager/web/datalayer">
189203
creating the Data Layer
190204
</a>{" "}
@@ -204,7 +218,11 @@ const DataLayerGuide = () => {
204218
Add event listeners to your code to capture click and change events
205219
related to your `data-ga` attributes and to push that event to the
206220
data layer. As a help to get you started, the
207-
`unity-bootstrap-theme` package&apos;s `dist/js/data-layer.js` file can
221+
`unity-bootstrap-theme` package&apos;s{" "}
222+
<a href="https://github.com/ASU/asu-unity-stack/blob/dev/packages/unity-bootstrap-theme/src/js/data-layer.js" target="_blank" rel="noreferrer">
223+
src/js/data-layer.js
224+
</a>{" "}
225+
file can
208226
serve as a starting point or as a reference for implementing your
209227
own data layer push code.
210228
</p>
@@ -214,29 +232,70 @@ const DataLayerGuide = () => {
214232
behavior similar to the following code snippet if you implement the
215233
Bootstrap header: <br />
216234
</p>
235+
<p>
236+
Including the following script tag will automatically initialize the GA push events and header scroll
237+
behavior and should be placed in the <strong>{`<head>`}</strong> tag of your HTML.
238+
The script has event listeners to initialize on the window load event.
239+
</p>
217240
<pre>
218241
<code>
219242
{`
220-
<script type="text/javascript" src="example/path/to/@asu/unity-bootstrap-theme/js/data-layer.js"></head> </script></head>
221-
<script type="text/javascript" src="./@asu/unity-bootstrap-theme/js/global-header.js"></head> </script></head>
243+
<script type="text/javascript" src="example/path/to/@asu/unity-bootstrap-theme/js/unity-bootstrap.umd.js"/>
222244
`}
223245
</code>
224246
</pre>
225247
<p>
226-
Then, the following code should be placed towards the bottom of your
227-
html doc or deferred. This initializes the data layer and the global
228-
header classes
248+
If for some reason your setup includes the script after the window load event has already occurred, you can call the initialization functions directly, by using the global variable <strong>{`unityBootstrap`}</strong>.
229249
</p>
230250
<pre>
231-
{" "}
232251
<code>
233252
{`
234-
<script></head>
235-
window.initDataLayer();
236-
window.initGlobalHeader();
237-
</script></head>
253+
<script>
254+
/* Only use if the script did not automatically initialize with the window load event */
255+
unityBootstrap.initDataLayer();
256+
unityBootstrap.initGlobalHeader();
257+
</script>
238258
`}
239-
</code>{" "}
259+
</code>
260+
</pre>
261+
262+
<a id="watchdatalayer"></a>
263+
<h2>Watching the data layer</h2>
264+
<p>
265+
Drag this link to your bookmarks bar. When you are on a page with
266+
data layer events, clicking the bookmarklet will execute a tiny
267+
script which will output data layer events to the console.<br/><br/>
268+
<a href={bookmarklet}>Watch DataLayer</a>
269+
</p>
270+
<h3>
271+
Only Run Code You Trust
272+
</h3>
273+
<p>
274+
As a user, always exercise caution when running code. Only click
275+
or add bookmarklets if at least one of the following applies:
276+
<ul>
277+
<li>
278+
The source is reputable.
279+
</li>
280+
<li>
281+
You understand JavaScript and have reviewed the code
282+
yourself.
283+
</li>
284+
<li>
285+
A trusted individual who knows JavaScript has reviewed the
286+
code for you.
287+
</li>
288+
</ul>
289+
290+
291+
</p>
292+
<h3>Bookmarklet Source code</h3>
293+
<pre>
294+
<code>
295+
{`
296+
${watchDataLayer.toString()}
297+
`}
298+
</code>
240299
</pre>
241300
</div>
242301
</div>

packages/static-site/src/utils/baseUrl.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
import { PagePaths } from '../routes/config';
2+
13
export const getBaseUrl = () => {
24

5+
const pages = Object.values(PagePaths)
6+
.filter((page) => page !== '/')
7+
.map((page) => page.replace(/\//g, ''));
8+
39
if (typeof window === 'undefined') return '/';
410

511
const pathname = window.location.pathname;
612

7-
const segments = pathname.split('/').filter(Boolean);
8-
return segments.length > 0 ? `/${segments[0]}` : '/';
13+
const segments = pathname.split('/')
14+
.filter(Boolean)
15+
.filter((segment) => !pages.includes(segment))
16+
.filter((segment) => segment.indexOf(".") === -1);
17+
18+
return `/${segments.join('/')}`;
919

1020
};
1121

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
() => {
2+
const w = window
3+
, dl = w.dataLayer || []
4+
/* used to provide styling in the console */
5+
, styleKey = '\x1B[38;2;155;145;134;2m'
6+
, styleValue = '\x1B[38;2;223;55;48;2m'
7+
, styleDefault = '\x1B[0;3m'
8+
, styleHeading = '\x1B[0;34;1m'
9+
/* provide a global variable */
10+
, tableFnName = 'showDataLayerTable';
11+
/* display all watched events as console table */
12+
w[tableFnName] = () => console.table(dl.slice().filter(i =>
13+
typeof i.name !== 'undefined'));
14+
15+
if (typeof w.onbeforeunload !== 'function') {
16+
/* initial click of bookmarklet */
17+
dl.push = new Proxy(dl.push,{
18+
apply: (target, thisArg, args) => {
19+
console.log(`${styleHeading}dataLayer event\n${styleDefault}
20+
{ ${(Object.entries(args[0]).map( ([k,v]) => (
21+
`${styleKey}${k}${styleDefault}: ${styleValue}'${v}'${styleDefault}`
22+
))).sort().join(', ')}${styleDefault} }`);
23+
return Reflect.apply(target, thisArg, args);
24+
}
25+
});
26+
alert(`DataLayer events will be displayed in console. Rerun bookmarklet or
27+
call ${tableFnName}() from the console to display a table of all events.\n\n
28+
29+
A prompt will warn you before leaving the page, this is normal and will allow
30+
you to inspect the dataLayer events, that would have reloaded the page.\n\n
31+
32+
Follow the prompt to reload or leave the page if you are done watching events.`);
33+
w.onbeforeunload = (e) => '';
34+
} else {
35+
/* if already initialized, output recorded events */
36+
w[tableFnName]();
37+
}
38+
}

0 commit comments

Comments
 (0)