gatsby-matrix-theme 53.26.3 → 53.26.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [53.26.5](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/compare/v53.26.4...v53.26.5) (2026-07-15)
2
+
3
+
4
+ ### Config
5
+
6
+ * update theme to enable multiple slash redirect to homepage ([e125109](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/e125109b2d02837869917f0636b30a98ce9baea0))
7
+
8
+ ## [53.26.4](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/compare/v53.26.3...v53.26.4) (2026-07-10)
9
+
10
+
11
+ ### Code Refactoring
12
+
13
+ * coupon uses shared useCopyCtaRedirect hook ([588e4b8](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/588e4b89b0e7649efb23ec0c9ef6ec43b5b7b499))
14
+
15
+
16
+ ### Config
17
+
18
+ * update theme ([bea914b](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/bea914b75ad3e2b65e8fc6647306685331f1c723))
19
+
20
+
21
+ * Merge branch 'refactor/coupon-use-copy-cta-redirect' into 'master' ([47921c9](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/commit/47921c9fea0673585ae31d31badbec0ffacaf409))
22
+
1
23
  ## [53.26.3](https://gitlab.com/g2m-gentoo/team-floyd/themes/matrix-theme/compare/v53.26.2...v53.26.3) (2026-07-09)
2
24
 
3
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-matrix-theme",
3
- "version": "53.26.3",
3
+ "version": "53.26.5",
4
4
  "main": "index.js",
5
5
  "description": "Matrix Theme NPM Package",
6
6
  "author": "",
@@ -26,7 +26,7 @@
26
26
  "@react-icons/all-files": "^4.1.0",
27
27
  "@gigmedia/enigma-utils": "^1.20.0",
28
28
  "gatsby": "^5.11.0",
29
- "gatsby-core-theme": "44.31.1",
29
+ "gatsby-core-theme": "44.33.0",
30
30
  "gatsby-plugin-sharp": "^5.11.0",
31
31
  "gatsby-plugin-sitemap": "^6.13.1",
32
32
  "gatsby-transformer-sharp": "^5.11.0",
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable react/jsx-no-target-blank */
2
- import React, { useState, useRef, useEffect } from 'react';
2
+ import React from 'react';
3
3
  import PropTypes from 'prop-types';
4
- import useCtaClickHandler from 'gatsby-core-theme/src/hooks/useCtaClickHandler/index';
5
4
  import { prettyTracker } from 'gatsby-core-theme/src/helpers/getters';
6
5
  import { getCtaDataAttributes } from 'gatsby-core-theme/src/helpers/tracker';
6
+ import useCopyCtaRedirect from 'gatsby-core-theme/src/hooks/useCopyCtaRedirect/index';
7
7
  import useTranslate from '~hooks/useTranslate/useTranslate';
8
8
  import CopyIcon from '../../../images/icons/copy-icon';
9
9
  import CheckCircleIcon from '../../../images/icons/check-circle';
@@ -33,38 +33,12 @@ const Coupon = ({
33
33
  rel = 'nofollow sponsored',
34
34
  redirectDelay = 2000
35
35
  }) => {
36
- const [copySuccess, setCopySuccess] = useState('');
37
- const redirectTimer = useRef(null);
38
- const isPending = useRef(false); // a redirect is scheduled
39
- const allowNavigation = useRef(false); // the next click is our own re-dispatch
40
-
41
- // Reuses the core CTA tracking: `fireTracking` drops the affiliate cookie /
42
- // fires the pixel; `ctaRef` points at the coupon anchor we redirect through.
43
- const { ctaRef, fireTracking } = useCtaClickHandler({
44
- pageTemplate,
45
- moduleName,
46
- tracker,
47
- clickedElement,
48
- modulePosition,
49
- itemPosition
50
- });
51
-
52
- // Clear a scheduled redirect if the component unmounts mid-flow
53
- useEffect(
54
- () => () => {
55
- if (redirectTimer.current) clearTimeout(redirectTimer.current);
56
- },
57
- []
58
- );
59
-
60
36
  // Resolve translations unconditionally so the hook order stays stable across
61
37
  // the copy/redirect state change (Rules of Hooks — useTranslate uses useContext).
62
38
  const prefixLabel = useTranslate(translationKey, defaultTranslation);
63
39
  const noCouponLabel = useTranslate('no_coupon_available', 'Not Needed');
64
40
  const codeCopiedLabel = useTranslate('code_copied', 'CODE COPIED');
65
41
 
66
- if (!code) return null;
67
-
68
42
  const inactive = status === 'inactive';
69
43
  const isBet365 = shortCode === 'bet365';
70
44
 
@@ -73,76 +47,24 @@ const Coupon = ({
73
47
  // Only act as a CTA when we have a valid outbound link for an active operator
74
48
  const ctaEnabled = actLikeCta && !!prettyLink && !inactive && !isBet365;
75
49
 
76
- const handleClick = async (e) => {
77
- // Our own re-dispatched click: let the anchor navigate + GTM record it
78
- if (allowNavigation.current) {
79
- allowNavigation.current = false;
80
- return;
81
- }
82
-
83
- e.preventDefault();
84
- e.stopPropagation();
85
-
86
- if (inactive || isBet365) return;
87
- // Ignore extra clicks while a redirect is already queued
88
- if (isPending.current) return;
89
-
90
- let copied = false;
91
- try {
92
- await navigator.clipboard.writeText(code);
93
- copied = true;
94
- } catch (err) {
95
- copied = false;
96
- }
97
-
98
- if (!ctaEnabled) {
99
- // Original behaviour: flip the label immediately, no redirect
100
- setCopySuccess(copied);
101
- return;
102
- }
103
-
104
- // t=0: code is on the clipboard — flip to "copied" and drop the tracking cookie
105
- setCopySuccess(true);
106
- fireTracking();
107
- isPending.current = true;
108
-
109
- // t=redirectDelay: open the operator in a new tab by re-dispatching a real
110
- // click on the anchor (so GTM's outbound-click trigger fires), then revert
111
- // the "copied" state. The delay stays within the browser's transient-activation
112
- // window so the programmatic open is not blocked as a popup.
113
- redirectTimer.current = setTimeout(() => {
114
- isPending.current = false;
115
-
116
- if (ctaAsButton) {
117
- if (prettyLink) window.open(prettyLink, '_blank');
118
- setCopySuccess(false);
119
- return;
120
- }
121
-
122
- const anchor = ctaRef.current;
123
- if (!anchor) return;
124
-
125
- // Re-dispatch a real click so the anchor navigates (new tab) and GTM's
126
- // outbound-click trigger still fires. `allowNavigation` lets our own
127
- // handler fall through instead of intercepting the click again.
128
- allowNavigation.current = true;
129
- const clickEvent = new MouseEvent('click', {
130
- bubbles: true,
131
- cancelable: true,
132
- view: window
133
- });
134
- const opened = anchor.dispatchEvent(clickEvent);
135
-
136
- // If a wrapping anchor (e.g. a parent PrettyLink) cancelled the default
137
- // navigation, open the operator manually so the tab still opens.
138
- if (!opened && prettyLink) {
139
- window.open(prettyLink, '_blank');
140
- }
50
+ // Shared copy track open-operator flow. 'anchor' mode re-dispatches a click
51
+ // on `ctaRef` (the <a> below); 'button' mode opens `prettyLink` directly.
52
+ const { copySuccess, ctaRef, handleCopyClick } = useCopyCtaRedirect({
53
+ code,
54
+ enabled: ctaEnabled,
55
+ disabled: inactive || isBet365,
56
+ redirectLink: prettyLink,
57
+ redirectMode: ctaAsButton ? 'button' : 'anchor',
58
+ redirectDelay,
59
+ pageTemplate,
60
+ moduleName,
61
+ tracker,
62
+ clickedElement,
63
+ modulePosition,
64
+ itemPosition
65
+ });
141
66
 
142
- // Revert to the default label once the redirect has fired.
143
- setCopySuccess(false);
144
- }, redirectDelay);
145
- };
67
+ if (!code) return null;
146
68
 
147
69
  const couponClass = `${styles.coupon} ${copySuccess ? styles.copied : ''}
148
70
  ${code === null ? styles.noCode : ''}
@@ -178,7 +100,7 @@ const Coupon = ({
178
100
  href={prettyLink}
179
101
  target="_blank"
180
102
  rel={rel}
181
- onClick={handleClick}
103
+ onClick={handleCopyClick}
182
104
  className={couponClass}
183
105
  {...getCtaDataAttributes(operator, {
184
106
  tracker,
@@ -191,7 +113,7 @@ const Coupon = ({
191
113
  </a>
192
114
  ) : (
193
115
  <button
194
- onClick={handleClick}
116
+ onClick={handleCopyClick}
195
117
  type="button"
196
118
  className={couponClass}
197
119
  disabled={inactive || isBet365}