@treely/strapi-slices 7.7.1 → 7.8.0

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 (38) hide show
  1. package/dist/components/ContextProvider/ContextProvider.d.ts +6 -0
  2. package/dist/components/SliceRenderer/SliceRenderer.d.ts +3 -1
  3. package/dist/components/StrapiLinkButton/StrapiLinkButton.d.ts +1 -0
  4. package/dist/strapi-slices.cjs.development.js +1506 -1369
  5. package/dist/strapi-slices.cjs.development.js.map +1 -1
  6. package/dist/strapi-slices.cjs.production.min.js +1 -1
  7. package/dist/strapi-slices.cjs.production.min.js.map +1 -1
  8. package/dist/strapi-slices.esm.js +1507 -1370
  9. package/dist/strapi-slices.esm.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/components/ContextProvider/ContextProvider.tsx +17 -1
  12. package/src/components/EventCard/EventCard.tsx +1 -0
  13. package/src/components/SliceRenderer/SliceRenderer.tsx +4 -1
  14. package/src/components/StrapiLinkButton/StrapiLinkButton.test.tsx +67 -7
  15. package/src/components/StrapiLinkButton/StrapiLinkButton.tsx +41 -4
  16. package/src/components/portfolio/Contact/Contact.tsx +7 -1
  17. package/src/components/portfolio/SmallCheckout/SmallCheckout.tsx +1 -0
  18. package/src/slices/BlogCards/BlogCards.tsx +2 -0
  19. package/src/slices/Comparison/Comparison.tsx +1 -0
  20. package/src/slices/Cta/Cta.tsx +1 -0
  21. package/src/slices/CtaOnly/CtaOnly.tsx +1 -1
  22. package/src/slices/Facts/Facts.tsx +1 -0
  23. package/src/slices/Hero/Hero.tsx +2 -0
  24. package/src/slices/IconGrid/IconGrid.tsx +1 -0
  25. package/src/slices/ImageGrid/ImageGrid.tsx +1 -0
  26. package/src/slices/ImageTextSequence/ImageTextSequence.tsx +1 -0
  27. package/src/slices/LeftTextRightCard/LeftTextRightCard.tsx +24 -2
  28. package/src/slices/LogoGridWithText/LogoGridWithText.tsx +1 -0
  29. package/src/slices/MapHero/MapHero.tsx +6 -1
  30. package/src/slices/QAndA/QAndA.tsx +21 -2
  31. package/src/slices/QuoteCards/QuoteCards.tsx +20 -2
  32. package/src/slices/SmallHero/SmallHero.tsx +6 -1
  33. package/src/slices/Steps/Steps.tsx +26 -2
  34. package/src/slices/TextCardGrid/TextCardGrid.tsx +1 -0
  35. package/src/slices/TextCarousel/TextCarousel.tsx +20 -1
  36. package/src/slices/TextWithCard/TextWithCard.tsx +1 -0
  37. package/src/slices/TextWithTextCards/TextWithTextCards.tsx +21 -3
  38. package/src/slices/Timeline/Timeline.tsx +1 -0
@@ -1,4 +1,10 @@
1
- import React, { createRef, useEffect, useRef, useState } from 'react';
1
+ import React, {
2
+ createRef,
3
+ useContext,
4
+ useEffect,
5
+ useRef,
6
+ useState,
7
+ } from 'react';
2
8
  import {
3
9
  Box,
4
10
  Center,
@@ -21,6 +27,7 @@ import StrapiDefaultHeader from '../../models/strapi/StrapiDefaultHeader';
21
27
  import strapiMediaUrl from '../../utils/strapiMediaUrl';
22
28
  import strapiLinkUrl from '../../utils/strapiLinkUrl';
23
29
  import StrapiImage from '../../models/strapi/StrapiImage';
30
+ import { AnalyticsContext } from '../../components/ContextProvider/ContextProvider';
24
31
 
25
32
  interface StepsSlice extends StrapiDefaultHeader {
26
33
  steps: {
@@ -38,6 +45,8 @@ export interface StepsProps {
38
45
 
39
46
  export const Steps: React.FC<StepsProps> = ({ slice }: StepsProps) => {
40
47
  const { push } = useRouter();
48
+ const analyticsFunction = useContext(AnalyticsContext);
49
+
41
50
  const [gray900] = useToken('colors', ['gray.900']);
42
51
 
43
52
  const containerRef = useRef<HTMLDivElement>(null);
@@ -50,6 +59,21 @@ export const Steps: React.FC<StepsProps> = ({ slice }: StepsProps) => {
50
59
  const { y: offsetY } = useWindowScroll();
51
60
  const { height: windowHeight } = useWindowSize();
52
61
 
62
+ const handleShapesCardButtonClick = () => {
63
+ if (slice.card?.button) {
64
+ analyticsFunction?.({
65
+ type: 'track',
66
+ props: {
67
+ action: 'click',
68
+ component: 'Steps',
69
+ buttonText: slice.card.button.text,
70
+ buttonUrl: strapiLinkUrl(slice.card.button),
71
+ section: 'card',
72
+ },
73
+ });
74
+ push(strapiLinkUrl(slice.card.button));
75
+ }
76
+ };
53
77
  useEffect(() => {
54
78
  setStepRefs(slice.steps.map(() => createRef()));
55
79
  }, []);
@@ -186,7 +210,7 @@ export const Steps: React.FC<StepsProps> = ({ slice }: StepsProps) => {
186
210
  button={
187
211
  slice.card.button && {
188
212
  text: slice.card.button.text,
189
- onClick: () => push(strapiLinkUrl(slice.card?.button)),
213
+ onClick: handleShapesCardButtonClick,
190
214
  }
191
215
  }
192
216
  />
@@ -272,6 +272,7 @@ export const TextCardGrid: React.FC<TextCardGridProps> = ({
272
272
  ) : undefined
273
273
  }
274
274
  variant={buttonIndex === 0 ? 'outline' : 'ghost'}
275
+ component="TextCardGrid"
275
276
  />
276
277
  ))}
277
278
  </Flex>
@@ -27,6 +27,7 @@ import { IntlContext } from '../../components/ContextProvider';
27
27
  import strapiLinkUrl from '../../utils/strapiLinkUrl';
28
28
  import { useRouter } from 'next/router';
29
29
  import shuffleElements from '../../utils/shuffleElements';
30
+ import { AnalyticsContext } from '../../components/ContextProvider/ContextProvider';
30
31
 
31
32
  interface TextCarouselSlice extends StrapiDefaultHeader {
32
33
  slides: StrapiTextCardWithIcon[];
@@ -47,6 +48,7 @@ export const TextCarousel: React.FC<TextCarouselProps> = ({
47
48
  const [primary50] = useToken('colors', ['primary.50']);
48
49
  const [itemRef, { width: itemWidth }] = useMeasure<HTMLDivElement>();
49
50
  const { formatMessage } = useContext(IntlContext);
51
+ const analyticsFunction = useContext(AnalyticsContext);
50
52
  const { width: windowWidth } = useWindowSize();
51
53
  const { push } = useRouter();
52
54
 
@@ -82,6 +84,22 @@ export const TextCarousel: React.FC<TextCarouselProps> = ({
82
84
 
83
85
  const canMoveLeft = useMemo(() => sliderIndex !== 0, [sliderIndex]);
84
86
 
87
+ const handleSlidesButtonClick = (button?: StrapiLink) => {
88
+ if (button) {
89
+ analyticsFunction?.({
90
+ type: 'track',
91
+ props: {
92
+ action: 'click',
93
+ component: 'TextCarousel',
94
+ buttonText: button.text,
95
+ buttonUrl: strapiLinkUrl(button),
96
+ section: 'slides',
97
+ },
98
+ });
99
+ push(strapiLinkUrl(button));
100
+ }
101
+ };
102
+
85
103
  const { slides, isShuffled = false } = slice;
86
104
 
87
105
  useEffect(() => {
@@ -146,7 +164,7 @@ export const TextCarousel: React.FC<TextCarouselProps> = ({
146
164
  button={
147
165
  button && {
148
166
  text: button.text,
149
- onClick: () => push(strapiLinkUrl(button)),
167
+ onClick: () => handleSlidesButtonClick(button),
150
168
  }
151
169
  }
152
170
  displayAs="column"
@@ -222,6 +240,7 @@ export const TextCarousel: React.FC<TextCarouselProps> = ({
222
240
  link={slice.button}
223
241
  size="xl"
224
242
  mt={['8', null, '14']}
243
+ component="TextCarousel"
225
244
  />
226
245
  </Center>
227
246
  </Wrapper>
@@ -117,6 +117,7 @@ export const TextWithCard: React.FC<TextWithCardProps> = ({
117
117
  colorScheme="white"
118
118
  variant="outline"
119
119
  rightIcon={<ArrowRight />}
120
+ component="TextWithCard"
120
121
  />
121
122
  )}
122
123
  </GridItem>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import {
3
3
  Box,
4
4
  ContactArea,
@@ -20,6 +20,7 @@ import StrapiDefaultHeader from '../../models/strapi/StrapiDefaultHeader';
20
20
  import StrapiContactArea from '../../models/strapi/StrapiContactArea';
21
21
  import StrapiTextCardWithIcon from '../../models/strapi/StrapiTextCardWithIcons';
22
22
  import StrapiImage from '../../models/strapi/StrapiImage';
23
+ import { AnalyticsContext } from '../../components/ContextProvider/ContextProvider';
23
24
 
24
25
  interface TextWithTextCardsSlice extends StrapiDefaultHeader {
25
26
  cards: StrapiTextCardWithIcon[];
@@ -34,9 +35,26 @@ export const TextWithTextCards: React.FC<TextWithTextCardsProps> = ({
34
35
  slice,
35
36
  }: TextWithTextCardsProps) => {
36
37
  const { push } = useRouter();
38
+ const analyticsFunction = useContext(AnalyticsContext);
37
39
  const [white] = useToken('colors', ['white']);
38
40
  const [belowBreakpoint] = useMediaQuery(BREAKPOINT_LG_QUERY);
39
41
 
42
+ const handleContactButtonClick = () => {
43
+ if (slice.contact?.button) {
44
+ analyticsFunction?.({
45
+ type: 'track',
46
+ props: {
47
+ action: 'click',
48
+ component: 'TextWithTextCards',
49
+ buttonText: slice.contact.button.text,
50
+ buttonUrl: strapiLinkUrl(slice.contact.button),
51
+ section: 'contact',
52
+ },
53
+ });
54
+ push(strapiLinkUrl(slice.contact.button));
55
+ }
56
+ };
57
+
40
58
  return (
41
59
  <DefaultSectionContainer backgroundColor={white} title={slice.title}>
42
60
  <>
@@ -116,7 +134,7 @@ export const TextWithTextCards: React.FC<TextWithTextCardsProps> = ({
116
134
  }}
117
135
  link={{
118
136
  text: slice.contact.button.text,
119
- onClick: () => push(strapiLinkUrl(slice.contact?.button)),
137
+ onClick: handleContactButtonClick,
120
138
  }}
121
139
  />
122
140
  )}
@@ -167,7 +185,7 @@ export const TextWithTextCards: React.FC<TextWithTextCardsProps> = ({
167
185
  }}
168
186
  link={{
169
187
  text: slice.contact.button.text,
170
- onClick: () => push(strapiLinkUrl(slice.contact?.button)),
188
+ onClick: handleContactButtonClick,
171
189
  }}
172
190
  />
173
191
  )}
@@ -250,6 +250,7 @@ export const Timeline: React.FC<TimelineProps> = ({ slice }: TimelineProps) => {
250
250
  link={item.button}
251
251
  size="sm"
252
252
  variant="outline"
253
+ component="Timeline"
253
254
  />
254
255
  </Box>
255
256
  )}