@wf-financing/ui 1.1.0 → 1.1.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wf-financing/ui",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./dist/index.es.js",
@@ -38,7 +38,7 @@
38
38
  "react-aria": "^3.41.1",
39
39
  "react-intl": "^6.2.5",
40
40
  "styled-components": "^6.1.19",
41
- "@wf-financing/embedded-types": "0.2.4"
41
+ "@wf-financing/embedded-types": "0.2.5"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
package/src/App.tsx CHANGED
@@ -5,7 +5,7 @@ import { createIntl, createIntlCache, IntlShape } from 'react-intl';
5
5
 
6
6
  import { CtaWidget } from './CtaWidget';
7
7
  import enMessages from './locales/en.json';
8
- import { PartnerContext } from './utils/partnerContext';
8
+ import { PartnerContext } from './utils';
9
9
 
10
10
  type AppPropsType = {
11
11
  partnerDesignId: Themes;
@@ -7,7 +7,13 @@ let cachedSdkInstance: IHeadlessWayflyerCtaSdk | null = null;
7
7
 
8
8
  export const getHeadlessSdkInstance = async (companyToken: string, mockedMode?: MockedModeType) => {
9
9
  try {
10
- if (cachedSdkInstance) return cachedSdkInstance;
10
+ if (cachedSdkInstance) {
11
+ if (mockedMode) {
12
+ cachedSdkInstance.setSdkScenario(mockedMode.sdkScenario);
13
+ }
14
+
15
+ return cachedSdkInstance;
16
+ }
11
17
 
12
18
  const existingScript = document.getElementById(WAYFLYER_HEADLESS_SDK_ID) as HTMLScriptElement;
13
19
 
@@ -1,6 +1,6 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { Themes } from '@wayflyer/flyui';
3
- import { CtaResponseTypes, MockedModeType } from '@wf-financing/embedded-types';
3
+ import { SdkScenarios, MockedModeType } from '@wf-financing/embedded-types';
4
4
  import { App } from '../../App';
5
5
  import { CtaBanner } from './CtaBanner';
6
6
 
@@ -31,10 +31,10 @@ const meta: Meta<typeof CtaBanner> = {
31
31
  ...defaultArgs,
32
32
  mockedMode: {
33
33
  isMockedMode: true,
34
- sdkScenario: CtaResponseTypes.GENERIC_OFFER,
34
+ sdkScenario: SdkScenarios.GENERIC_NEW_APPLICATION,
35
35
  },
36
36
  },
37
- decorators: [(Story, context) => <Template {...(context.args as CtaBannerStoryArgs)} />],
37
+ decorators: [(_, context) => <Template {...(context.args as CtaBannerStoryArgs)} />],
38
38
  };
39
39
 
40
40
  export default meta;
@@ -45,7 +45,27 @@ export const GenericOffer: Story = {
45
45
  args: {
46
46
  mockedMode: {
47
47
  isMockedMode: true,
48
- sdkScenario: CtaResponseTypes.GENERIC_OFFER,
48
+ sdkScenario: SdkScenarios.GENERIC_NEW_APPLICATION,
49
+ },
50
+ },
51
+ };
52
+
53
+ export const IndicativeOffer: Story = {
54
+ name: 'Indicative Offer',
55
+ args: {
56
+ mockedMode: {
57
+ isMockedMode: true,
58
+ sdkScenario: SdkScenarios.INDICATIVE_NEW_APPLICATION,
59
+ },
60
+ },
61
+ };
62
+
63
+ export const ContinueApplication: Story = {
64
+ name: 'Continue Application',
65
+ args: {
66
+ mockedMode: {
67
+ isMockedMode: true,
68
+ sdkScenario: SdkScenarios.CONTINUE_APPLICATION,
49
69
  },
50
70
  },
51
71
  };
@@ -34,7 +34,7 @@ export const WithContent: Story = {
34
34
  <div style={{ padding: '20px', background: 'white' }}>
35
35
  <h2>Consent Agreement</h2>
36
36
  <p>Please agree to the terms to proceed.</p>
37
- <button>Continue with Wayflyer</button>
37
+ <button>Continue to Wayflyer</button>
38
38
  <button>Cancel</button>
39
39
  </div>
40
40
  </ConsentModal>
@@ -1,9 +1,10 @@
1
- import { Flex, Image, Text } from '@wayflyer/flyui';
1
+ import { Flex, Image, Text, useDetectDeviceSize } from '@wayflyer/flyui';
2
2
  import { useIntl } from 'react-intl';
3
3
 
4
4
  import { FundingSteps } from './FundingSteps';
5
5
  import { Modal } from './Modal';
6
6
  import { ModalFooter } from './ModalFooter';
7
+ import { useDetectSmallScreen } from '../../hooks';
7
8
 
8
9
  type ConsentModalProps = {
9
10
  isModalOpen: boolean;
@@ -12,11 +13,13 @@ type ConsentModalProps = {
12
13
 
13
14
  export const ConsentModal = ({ isModalOpen, setIsModalOpen }: ConsentModalProps) => {
14
15
  const { formatMessage } = useIntl();
16
+ const isSmallScreen = useDetectSmallScreen();
17
+ const { isMobile } = useDetectDeviceSize();
15
18
 
16
19
  return (
17
20
  <Modal isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen}>
18
- <Image src="https://static.wayflyer.com/flyui-assets/logos/wayflyer-ef.png" />
19
- <Flex margin={['6']} direction="column" gap="10">
21
+ {!isSmallScreen && <Image src="https://static.wayflyer.com/flyui-assets/logos/wayflyer-ef.png" />}
22
+ <Flex direction="column" gap="8" padding={isSmallScreen || isMobile ? '4' : '6'}>
20
23
  <Flex direction="column" gap="6">
21
24
  <Text fontStyle="regular" fontWeight="medium" lineHeight="tight" size="2xl">
22
25
  {formatMessage({ id: 'ctaModal.title' })}
@@ -1,24 +1,17 @@
1
- import { Badge, Flex, Text, useTheme } from '@wayflyer/flyui';
1
+ import { Flex, Text } from '@wayflyer/flyui';
2
2
  import { useIntl } from 'react-intl';
3
3
 
4
4
  import { MODAL_ITEMS } from '../../constants';
5
5
 
6
6
  export const FundingSteps = () => {
7
7
  const { formatMessage } = useIntl();
8
- const theme = useTheme();
9
8
 
10
9
  return (
11
- <Flex direction="column" gap="4">
12
- {MODAL_ITEMS.map(({ id, title, subtitle, Icon, time }) => (
13
- <Flex key={id} direction="column" gap="1">
14
- <Flex gap="2" direction="row" align="center">
15
- <Icon />
16
- <Text fontWeight="medium">{formatMessage(title)}</Text>
17
- <Badge size="small">{formatMessage(time)}</Badge>
18
- </Flex>
19
- <div style={{ paddingLeft: theme.spacing('8') }}>
20
- <Text color="placeholder">{formatMessage(subtitle)}</Text>
21
- </div>
10
+ <Flex direction="column" gap="3">
11
+ {MODAL_ITEMS.map(({ id, title, subtitle }) => (
12
+ <Flex key={id} direction="column">
13
+ <Text fontWeight="medium">{formatMessage(title)}</Text>
14
+ <Text color="placeholder">{formatMessage(subtitle)}</Text>
22
15
  </Flex>
23
16
  ))}
24
17
  </Flex>
@@ -31,7 +31,7 @@ export const Modal = ({ isModalOpen, setIsModalOpen, children }: ModalProps) =>
31
31
  animate={fullSize}
32
32
  exit={small}
33
33
  transition={{ duration: 0.3 }}
34
- style={{ width: '438px', border: 'none', maxWidth: '100vw' }}
34
+ style={{ width: '438px', border: 'none', maxWidth: '90vw', maxHeight: '90vh' }}
35
35
  >
36
36
  <MotionModalOverlay
37
37
  data-id="modal-mask"
@@ -3,7 +3,7 @@ import { IconArrowOnSquareUpRight16Line } from '@wayflyer/flyui-icons/16/line';
3
3
  import { StartHostedApplicationResponseType } from '@wf-financing/embedded-types';
4
4
  import { FormattedMessage } from 'react-intl';
5
5
 
6
- import { useStartHostedApplication } from '../../hooks/useStartHostedApplication';
6
+ import { useStartHostedApplication, useDetectSmallScreen } from '../../hooks';
7
7
 
8
8
  type ModalFooterType = {
9
9
  setOpen: (isOpen: boolean) => void;
@@ -11,6 +11,7 @@ type ModalFooterType = {
11
11
 
12
12
  export const ModalFooter = ({ setOpen }: ModalFooterType) => {
13
13
  const startHostedAppMutation = useStartHostedApplication();
14
+ const isSmallScreen = useDetectSmallScreen();
14
15
 
15
16
  const handleStartApplication = () => {
16
17
  startHostedAppMutation.mutate(undefined, {
@@ -30,7 +31,7 @@ export const ModalFooter = ({ setOpen }: ModalFooterType) => {
30
31
 
31
32
  return (
32
33
  <Flex direction="column" gap="3">
33
- <Flex gap="2">
34
+ <Flex gap="2" direction={isSmallScreen ? 'column' : 'row'}>
34
35
  <Button fullWidth onClick={handleStartApplication} variant="Primary" external>
35
36
  <FormattedMessage id="ctaModal.action" />
36
37
  <IconArrowOnSquareUpRight16Line />
@@ -1,29 +1,17 @@
1
- import {
2
- IconArrowsCwHorizontal24Line,
3
- IconCheckCircle24Line,
4
- IconPersonCircle24Line,
5
- } from '@wayflyer/flyui-icons/24/line';
6
-
7
1
  export const MODAL_ITEMS = [
8
2
  {
9
3
  id: 'step1',
10
4
  title: { id: 'ctaModal.step1.title' },
11
5
  subtitle: { id: 'ctaModal.step1.subtitle' },
12
- Icon: IconPersonCircle24Line,
13
- time: { id: 'ctaModal.step1.time' },
14
6
  },
15
7
  {
16
8
  id: 'step2',
17
9
  title: { id: 'ctaModal.step2.title' },
18
10
  subtitle: { id: 'ctaModal.step2.subtitle' },
19
- Icon: IconArrowsCwHorizontal24Line,
20
- time: { id: 'ctaModal.step2.time' },
21
11
  },
22
12
  {
23
13
  id: 'step3',
24
14
  title: { id: 'ctaModal.step3.title' },
25
15
  subtitle: { id: 'ctaModal.step3.subtitle' },
26
- Icon: IconCheckCircle24Line,
27
- time: { id: 'ctaModal.step3.time' },
28
16
  },
29
17
  ];
@@ -1,3 +1,4 @@
1
1
  export { usePartnerContext } from './usePartnerContext';
2
2
  export { useCtaBanner } from './useCtaBanner';
3
3
  export { useStartHostedApplication } from './useStartHostedApplication';
4
+ export { useDetectSmallScreen } from './useDetectSmallScreen';
@@ -0,0 +1,7 @@
1
+ import { useMediaQuery } from '@wayflyer/flyui';
2
+
3
+ export const useDetectSmallScreen = (): boolean => {
4
+ const query = useMediaQuery();
5
+
6
+ return query('xxs').windowLte;
7
+ };
@@ -2,17 +2,16 @@
2
2
  "common.cancel": "Cancel",
3
3
  "common.dismiss": "Dismiss",
4
4
  "ctaModal.call": "Get funded",
5
- "ctaModal.title": "We work with Wayflyer to provide you capital",
6
- "ctaModal.action": "Continue with Wayflyer",
5
+ "ctaModal.title": "Fuel your growth with capital from Wayflyer",
6
+ "ctaModal.action": "Continue to Wayflyer",
7
7
  "ctaModal.consent": "By proceeding, you consent to us sharing your information with Wayflyer so they can assess your eligibility for financing, in accordance with the Wayflyer ",
8
8
  "ctaModal.consent.privacy_policy": "Privacy Policy.",
9
- "ctaModal.step1.title": "Create your account",
10
- "ctaModal.step1.subtitle": "Tell us about your business and funding needs",
9
+ "ctaModal.step1.title": "Built for businesses like yours",
10
+ "ctaModal.step1.subtitle": "$5B+ deployed to 5,000+ companies since 2019",
11
11
  "ctaModal.step1.time": "2 mins",
12
- "ctaModal.step2.title": "Connect your platforms and apply",
13
- "ctaModal.step2.subtitle": "We’ll analyze your business performance",
12
+ "ctaModal.step2.title": "Your growth, your way",
13
+ "ctaModal.step2.subtitle": "Flexible products with terms that fit your business",
14
14
  "ctaModal.step2.time": "10 mins",
15
- "ctaModal.step3.title": "Accept and receive funds",
16
- "ctaModal.step3.subtitle": "Once approved, funds can be deployed in 24h",
17
- "ctaModal.step3.time": "24 hrs"
15
+ "ctaModal.step3.title": "Quick to get started",
16
+ "ctaModal.step3.subtitle": "Apply in minutes and get capital in hours"
18
17
  }
@@ -1,15 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import { BulletList } from './BulletList';
3
-
4
- const meta: Meta<typeof BulletList> = {
5
- title: 'BulletList',
6
- component: BulletList,
7
- };
8
-
9
- export default meta;
10
-
11
- type Story = StoryObj<typeof BulletList>;
12
-
13
- export const Default: Story = {
14
- render: () => <BulletList items={['Item 1', 'Item 2', 'Item 3']} />,
15
- };