@wf-financing/ui 3.7.1 → 3.8.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.
- package/CHANGELOG.md +13 -0
- package/dist/index.es.js +17601 -16108
- package/package.json +2 -2
- package/src/App.tsx +17 -2
- package/src/CtaWidget.tsx +21 -10
- package/src/components/banner/AnimationWrapper.tsx +37 -0
- package/src/components/banner/CloseButton.tsx +4 -3
- package/src/components/banner/CtaBanner.snapshot.stories.tsx +4 -1
- package/src/components/banner/CtaBanner.tsx +40 -7
- package/src/components/banner/HeaderActions.tsx +9 -1
- package/src/components/modal/ConsentModal.snapshot.stories.tsx +2 -0
- package/src/main.tsx +3 -0
- package/src/utils/loadFont.ts +1 -1
- package/src/utils/partnerContext.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.1",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/index.es.js",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"react-aria": "^3.41.1",
|
|
37
37
|
"react-intl": "^6.2.5",
|
|
38
38
|
"styled-components": "^6.1.19",
|
|
39
|
-
"@wf-financing/embedded-types": "0.
|
|
39
|
+
"@wf-financing/embedded-types": "0.5.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
package/src/App.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
1
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
3
2
|
import { FlyUIProvider } from '@wayflyer/flyui';
|
|
4
3
|
import { PartnerCallbackType, SdkOptionsType } from '@wf-financing/embedded-types';
|
|
4
|
+
import { useState } from 'react';
|
|
5
5
|
import { createIntl, createIntlCache, IntlShape } from 'react-intl';
|
|
6
6
|
|
|
7
7
|
import { PartnerTheme } from './config';
|
|
@@ -32,6 +32,7 @@ export const App = ({
|
|
|
32
32
|
portalContainer,
|
|
33
33
|
}: AppPropsType) => {
|
|
34
34
|
const [isThemeLoaded, setIsThemeLoaded] = useState(false);
|
|
35
|
+
const [isWidgetDismissed, setIsWidgetDismissed] = useState(false);
|
|
35
36
|
|
|
36
37
|
const locale = 'en';
|
|
37
38
|
|
|
@@ -43,9 +44,23 @@ export const App = ({
|
|
|
43
44
|
createIntlCache(),
|
|
44
45
|
);
|
|
45
46
|
|
|
47
|
+
const onWidgetDismiss = () => {
|
|
48
|
+
setIsWidgetDismissed(true);
|
|
49
|
+
};
|
|
50
|
+
|
|
46
51
|
return (
|
|
47
52
|
<QueryClientProvider client={queryClient}>
|
|
48
|
-
<PartnerContext.Provider
|
|
53
|
+
<PartnerContext.Provider
|
|
54
|
+
value={{
|
|
55
|
+
companyToken,
|
|
56
|
+
options,
|
|
57
|
+
partnerCallback,
|
|
58
|
+
onWidgetClose,
|
|
59
|
+
portalContainer,
|
|
60
|
+
isWidgetDismissed,
|
|
61
|
+
onWidgetDismiss,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
49
64
|
<FlyUIProvider
|
|
50
65
|
theme={theme}
|
|
51
66
|
intl={intl}
|
package/src/CtaWidget.tsx
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnimatePresence } from 'framer-motion';
|
|
2
2
|
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { AnimationWrapper } from './components/banner/AnimationWrapper';
|
|
3
5
|
import { CtaBanner } from './components/banner/CtaBanner';
|
|
4
6
|
import { useCtaBanner, usePartnerContext } from './hooks';
|
|
5
7
|
|
|
6
8
|
export const CtaWidget = () => {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
+
const { isLoading, data, isSuccess } = useCtaBanner();
|
|
10
|
+
const [skipAnimation] = useState(() => isSuccess);
|
|
11
|
+
const { onWidgetClose, isWidgetDismissed } = usePartnerContext();
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const showBanner = !isLoading && data && !isWidgetDismissed;
|
|
14
|
+
|
|
15
|
+
const handleExitComplete = () => {
|
|
16
|
+
if ((!isLoading && !data) || isWidgetDismissed) {
|
|
17
|
+
onWidgetClose();
|
|
15
18
|
}
|
|
16
|
-
}
|
|
19
|
+
};
|
|
17
20
|
|
|
18
|
-
return
|
|
21
|
+
return (
|
|
22
|
+
<AnimatePresence mode="wait" onExitComplete={handleExitComplete}>
|
|
23
|
+
{showBanner && (
|
|
24
|
+
<AnimationWrapper skipAnimation={skipAnimation}>
|
|
25
|
+
<CtaBanner skipAnimation={skipAnimation} />
|
|
26
|
+
</AnimationWrapper>
|
|
27
|
+
)}
|
|
28
|
+
</AnimatePresence>
|
|
29
|
+
);
|
|
19
30
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { motion, MotionProps } from 'framer-motion';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
skipAnimation: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const animationProps: MotionProps = {
|
|
9
|
+
initial: { height: 0, overflow: 'hidden' },
|
|
10
|
+
animate: {
|
|
11
|
+
height: 'auto',
|
|
12
|
+
overflow: 'visible',
|
|
13
|
+
transition: {
|
|
14
|
+
duration: 0.4,
|
|
15
|
+
ease: [0.33, 1, 0.68, 1],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
exit: {
|
|
19
|
+
height: 0,
|
|
20
|
+
overflow: 'hidden',
|
|
21
|
+
transition: {
|
|
22
|
+
duration: 0.4,
|
|
23
|
+
ease: [0.33, 1, 0.68, 1],
|
|
24
|
+
delay: 0.1,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const AnimationWrapper = ({ children, skipAnimation }: PropsWithChildren<Props>) => {
|
|
30
|
+
const initial = skipAnimation ? animationProps.animate : animationProps.initial;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<motion.div key="cta-banner-wrapper" {...animationProps} initial={initial}>
|
|
34
|
+
{children}
|
|
35
|
+
</motion.div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Button, Flex } from '@wayflyer/flyui';
|
|
2
2
|
import { IconX16Line } from '@wayflyer/flyui-icons/16/line';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useDismissCta, usePartnerContext } from '../../hooks';
|
|
5
5
|
|
|
6
6
|
export const CloseButton = ({ isOnDarkTheme }: { isOnDarkTheme: boolean }) => {
|
|
7
|
-
const {
|
|
7
|
+
const { onWidgetDismiss } = usePartnerContext();
|
|
8
8
|
const dismissCta = useDismissCta();
|
|
9
9
|
|
|
10
10
|
const handleCloseWidget = () => {
|
|
11
|
-
|
|
11
|
+
onWidgetDismiss();
|
|
12
|
+
|
|
12
13
|
dismissCta.mutate(undefined, {
|
|
13
14
|
onError: (error) => {
|
|
14
15
|
console.error('Failed to dismiss CTA', error);
|
|
@@ -9,6 +9,9 @@ const defaultArgs = {
|
|
|
9
9
|
companyToken: 'demo-token',
|
|
10
10
|
partnerCallback: () => {},
|
|
11
11
|
onWidgetClose: () => {},
|
|
12
|
+
onWidgetDismiss: () => {},
|
|
13
|
+
isWidgetDismissed: false,
|
|
14
|
+
skipAnimation: false,
|
|
12
15
|
portalContainer,
|
|
13
16
|
};
|
|
14
17
|
|
|
@@ -16,7 +19,7 @@ type CtaBannerStoryArgs = typeof defaultArgs;
|
|
|
16
19
|
|
|
17
20
|
const Template = (args: CtaBannerStoryArgs) => (
|
|
18
21
|
<PartnerContext.Provider value={{ ...args }}>
|
|
19
|
-
<CtaBanner />
|
|
22
|
+
<CtaBanner skipAnimation={false} />
|
|
20
23
|
</PartnerContext.Provider>
|
|
21
24
|
);
|
|
22
25
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Flex, useDetectDeviceSize, useTheme } from '@wayflyer/flyui';
|
|
2
|
-
import {
|
|
2
|
+
import { motion, MotionProps } from 'framer-motion';
|
|
3
|
+
import { css, styled } from 'styled-components';
|
|
3
4
|
|
|
5
|
+
import { MODAL_LOGO_IMAGE_URL, STATIC_BASE_URL } from '../../config';
|
|
6
|
+
import { usePreloadImage } from '../../hooks';
|
|
4
7
|
import { CtaBannerContent } from './CtaBannerContent';
|
|
5
8
|
import { FooterActions } from './FooterActions';
|
|
6
9
|
import { HeaderActions } from './HeaderActions';
|
|
7
|
-
import { usePreloadImage } from '../../hooks';
|
|
8
|
-
import { MODAL_LOGO_IMAGE_URL, STATIC_BASE_URL } from '../../config';
|
|
9
10
|
|
|
10
11
|
const ON_DARK_THEMES = ['athena'];
|
|
11
12
|
const LIGHT_BG_THEMES = ['conjura', 'rocketFuel'];
|
|
12
13
|
const TERTIARY_THEMES = ['reveni'];
|
|
13
14
|
|
|
14
|
-
const BannerContainer = styled.aside<{ $isLightBgTheme: boolean; $isTertiaryTheme: boolean }>`
|
|
15
|
+
const BannerContainer = styled(motion.aside)<{ $isLightBgTheme: boolean; $isTertiaryTheme: boolean }>`
|
|
15
16
|
padding: var(--sizes-spacing-4) var(--sizes-spacing-4) var(--sizes-spacing-4) var(--sizes-spacing-6);
|
|
16
17
|
box-shadow: var(--effects-shadow);
|
|
17
18
|
border-radius: var(--sizes-radius-md);
|
|
@@ -27,6 +28,8 @@ const BannerContainer = styled.aside<{ $isLightBgTheme: boolean; $isTertiaryThem
|
|
|
27
28
|
return $isLightBgTheme ? css`var(--palette-layout-containerSurface)` : css`var(--palette-utility-primaryBrand)`;
|
|
28
29
|
}};
|
|
29
30
|
|
|
31
|
+
transform-origin: top center;
|
|
32
|
+
|
|
30
33
|
@media (max-width: 640px) {
|
|
31
34
|
padding: var(--sizes-spacing-3) var(--sizes-spacing-3) var(--sizes-spacing-3) var(--sizes-spacing-4);
|
|
32
35
|
flex-direction: column;
|
|
@@ -34,7 +37,32 @@ const BannerContainer = styled.aside<{ $isLightBgTheme: boolean; $isTertiaryThem
|
|
|
34
37
|
}
|
|
35
38
|
`;
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
const bannerAnimationProps: MotionProps = {
|
|
41
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
42
|
+
animate: {
|
|
43
|
+
opacity: 1,
|
|
44
|
+
scale: 1,
|
|
45
|
+
transition: {
|
|
46
|
+
delay: 0.1,
|
|
47
|
+
duration: 0.4,
|
|
48
|
+
ease: [0.33, 1, 0.68, 1],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
exit: {
|
|
52
|
+
opacity: 0,
|
|
53
|
+
scaleY: 0.8,
|
|
54
|
+
transition: {
|
|
55
|
+
duration: 0.2,
|
|
56
|
+
ease: [0.12, 0, 0.39, 0],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type Props = {
|
|
62
|
+
skipAnimation: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const CtaBanner = ({ skipAnimation }: Props) => {
|
|
38
66
|
const { isMobile, isTablet } = useDetectDeviceSize();
|
|
39
67
|
const logoImageUrl = `${STATIC_BASE_URL}${MODAL_LOGO_IMAGE_URL}`;
|
|
40
68
|
const { themeName } = useTheme();
|
|
@@ -44,8 +72,13 @@ export const CtaBanner = () => {
|
|
|
44
72
|
usePreloadImage(logoImageUrl);
|
|
45
73
|
|
|
46
74
|
return (
|
|
47
|
-
<BannerContainer
|
|
48
|
-
|
|
75
|
+
<BannerContainer
|
|
76
|
+
$isLightBgTheme={isLightBgTheme}
|
|
77
|
+
$isTertiaryTheme={isTertiaryTheme}
|
|
78
|
+
{...bannerAnimationProps}
|
|
79
|
+
initial={skipAnimation ? bannerAnimationProps.animate : bannerAnimationProps.initial}
|
|
80
|
+
>
|
|
81
|
+
<Flex gap="4" align={isMobile ? 'flex-start' : 'center'} justify="space-between" width="100%">
|
|
49
82
|
<CtaBannerContent isMobile={isMobile} isTablet={isTablet} isOnDarkTheme={isOnDarkTheme} />
|
|
50
83
|
<HeaderActions isOnDarkTheme={isOnDarkTheme} />
|
|
51
84
|
</Flex>
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { useDetectDeviceSize } from '@wayflyer/flyui';
|
|
2
|
+
import styled from 'styled-components';
|
|
2
3
|
import { BannerActionsDesktop } from './BannerActionsDesktop';
|
|
3
4
|
import { CloseButton } from './CloseButton';
|
|
4
5
|
|
|
6
|
+
const MobileButtonContainer = styled.div`
|
|
7
|
+
margin-top: calc(0px - var(--sizes-spacing-3));
|
|
8
|
+
margin-right: calc(0px - var(--sizes-spacing-2));
|
|
9
|
+
`;
|
|
10
|
+
|
|
5
11
|
export const HeaderActions = ({ isOnDarkTheme }: { isOnDarkTheme: boolean }) => {
|
|
6
12
|
const { isMobile } = useDetectDeviceSize();
|
|
7
13
|
|
|
8
14
|
return isMobile ? (
|
|
9
|
-
<
|
|
15
|
+
<MobileButtonContainer>
|
|
16
|
+
<CloseButton isOnDarkTheme={isOnDarkTheme} />
|
|
17
|
+
</MobileButtonContainer>
|
|
10
18
|
) : (
|
|
11
19
|
<BannerActionsDesktop isOnDarkTheme={isOnDarkTheme} />
|
|
12
20
|
);
|
package/src/main.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { PartnerCallbackType, SdkOptionsType } from '@wf-financing/embedded-type
|
|
|
2
2
|
import ReactDOM from 'react-dom/client';
|
|
3
3
|
import { StyleSheetManager } from 'styled-components';
|
|
4
4
|
|
|
5
|
+
import { MotionGlobalConfig } from 'framer-motion';
|
|
5
6
|
import { App } from './App';
|
|
6
7
|
import { PartnerTheme } from './config';
|
|
7
8
|
import { applyFont, createRoots } from './utils';
|
|
@@ -32,6 +33,8 @@ export const mountToTarget = async (
|
|
|
32
33
|
root.unmount();
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
MotionGlobalConfig.skipAnimations = options?.skipAnimations;
|
|
37
|
+
|
|
35
38
|
root.render(
|
|
36
39
|
<StyleSheetManager target={styledComponentsStyleRoot}>
|
|
37
40
|
<App
|
package/src/utils/loadFont.ts
CHANGED
|
@@ -24,7 +24,7 @@ export const loadFont: LoadFontType = async (shadow, fontParams) => {
|
|
|
24
24
|
fontStyles = document.createElement('style');
|
|
25
25
|
fontStyles.id = fontStylesId;
|
|
26
26
|
fontStyles.textContent = `
|
|
27
|
-
:host { font-family: "${fontFamily}", sans-serif; }
|
|
27
|
+
:host { font-family: "${fontFamily}", sans-serif; background-color: transparent !important; overflow: visible !important; }
|
|
28
28
|
::slotted(*) { font-family: inherit; }
|
|
29
29
|
`;
|
|
30
30
|
|