diff --git a/packages/trader/src/AppV2/Components/OnboardingGuide/__tests__/guide-tooltip.spec.tsx b/packages/trader/src/AppV2/Components/OnboardingGuide/__tests__/guide-tooltip.spec.tsx index a5fd04375b05..a70b926c6107 100644 --- a/packages/trader/src/AppV2/Components/OnboardingGuide/__tests__/guide-tooltip.spec.tsx +++ b/packages/trader/src/AppV2/Components/OnboardingGuide/__tests__/guide-tooltip.spec.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; -import { TooltipRenderProps } from 'react-joyride'; -import GuideTooltip from '../guide-tooltip'; +import GuideTooltip, { GuideTooltipProps } from '../guide-tooltip'; jest.mock('react-joyride', () => jest.fn(() =>
Joyride
)); @@ -17,8 +16,9 @@ const mock_props = { title: 'Title', content: 'Step content', }, + setStepIndex: jest.fn(), tooltipProps: {}, -} as unknown as TooltipRenderProps; +} as unknown as GuideTooltipProps; describe('GuideTooltip', () => { it('should render correct content for tooltip if isLastStep === false', () => { @@ -38,4 +38,10 @@ describe('GuideTooltip', () => { expect(screen.getByText('Done')).toBeInTheDocument(); expect(screen.queryByText('Next')).not.toBeInTheDocument(); }); + + it('should render scroll icon if title of the step is scroll-icon', () => { + mock_props.step.title = 'scroll-icon'; + render(); + expect(screen.getByText('Swipe up to see the chart')).toBeInTheDocument(); + }); }); diff --git a/packages/trader/src/AppV2/Components/OnboardingGuide/guide-container.tsx b/packages/trader/src/AppV2/Components/OnboardingGuide/guide-container.tsx index 48a0c87f752a..7120516cea94 100644 --- a/packages/trader/src/AppV2/Components/OnboardingGuide/guide-container.tsx +++ b/packages/trader/src/AppV2/Components/OnboardingGuide/guide-container.tsx @@ -9,6 +9,7 @@ type TGuideContainerProps = { }; const GuideContainer = ({ should_run, onFinishGuide }: TGuideContainerProps) => { + const [step_index, setStepIndex] = React.useState(0); const steps = [ { content: , @@ -35,13 +36,37 @@ const GuideContainer = ({ should_run, onFinishGuide }: TGuideContainerProps) => target: '.trade-params', title: , }, + { + content: '', + disableBeacon: false, + offset: 0, + spotlightPadding: 0, + styles: { + spotlight: { + display: 'none', + }, + arrow: { + display: 'none', + }, + }, + target: '.purchase-button__wrapper', + title: 'scroll-icon', + }, + { + content: , + disableBeacon: true, + spotlightPadding: 8, + offset: 4, + target: '.trade__chart-tooltip', + title: , + placement: 'bottom' as Step['placement'], + }, { content: , disableBeacon: true, - // TODO: remove disableScrolling after 4 step wil be added disableScrolling: false, offset: -4, - target: '.trade__bottom', + target: '.trade__parameter', title: , }, { @@ -73,11 +98,12 @@ const GuideContainer = ({ should_run, onFinishGuide }: TGuideContainerProps) => arrow: { length: 4, spread: 8, + display: step_index === 3 ? 'none' : 'inline-flex', }, }, }} + run={should_run} showSkipButton - tooltipComponent={GuideTooltip} steps={steps} spotlightPadding={0} scrollToFirstStep @@ -90,7 +116,8 @@ const GuideContainer = ({ should_run, onFinishGuide }: TGuideContainerProps) => borderRadius: 'unset', }, }} - run={should_run} + stepIndex={step_index} + tooltipComponent={props => } /> ); }; diff --git a/packages/trader/src/AppV2/Components/OnboardingGuide/guide-tooltip.tsx b/packages/trader/src/AppV2/Components/OnboardingGuide/guide-tooltip.tsx index d2a464093922..7a2782002936 100644 --- a/packages/trader/src/AppV2/Components/OnboardingGuide/guide-tooltip.tsx +++ b/packages/trader/src/AppV2/Components/OnboardingGuide/guide-tooltip.tsx @@ -1,42 +1,75 @@ import React from 'react'; -import { Button, CaptionText, IconButton } from '@deriv-com/quill-ui'; -import { LabelPairedXmarkSmBoldIcon } from '@deriv/quill-icons'; +import { Button, CaptionText, IconButton, Text } from '@deriv-com/quill-ui'; +import { LabelPairedChevronsUpXlBoldIcon, LabelPairedXmarkSmBoldIcon } from '@deriv/quill-icons'; import { Localize } from '@deriv/translations'; import { TooltipRenderProps } from 'react-joyride'; +import { useSwipeable } from 'react-swipeable'; +import { setTime } from '@deriv/shared'; -const GuideTooltip = ({ isLastStep, primaryProps, skipProps, step, tooltipProps }: TooltipRenderProps) => ( -
-
- {step.title && ( -
- - {step.title} +export interface GuideTooltipProps extends TooltipRenderProps { + setStepIndex: React.Dispatch>; +} + +const GuideTooltip = ({ isLastStep, primaryProps, skipProps, step, tooltipProps, setStepIndex }: GuideTooltipProps) => { + const swipe_handlers = useSwipeable({ + onSwipedUp: () => { + document.querySelector('.trade__chart')?.scrollIntoView(); + setStepIndex((prev: number) => prev + 1); + }, + preventDefaultTouchmoveEvent: true, + trackTouch: true, + trackMouse: true, + }); + + if (step.title === 'scroll-icon') { + return ( +
+ + + + +
+ ); + } + + return ( +
+
+ {step.title && ( +
+ + {step.title} + + } + className='guide-tooltip__close' + size='sm' + color='white-black' + variant='tertiary' + /> +
+ )} + {step.content && ( + + {step.content} - } - className='guide-tooltip__close' - size='sm' - color='white-black' - variant='tertiary' - /> -
- )} - {step.content && ( - - {step.content} - - )} + )} +
+
-
-); + ); +}; export default GuideTooltip; diff --git a/packages/trader/src/AppV2/Components/OnboardingGuide/onboarding-guide.scss b/packages/trader/src/AppV2/Components/OnboardingGuide/onboarding-guide.scss index 53a22a945f88..e18270ded78c 100644 --- a/packages/trader/src/AppV2/Components/OnboardingGuide/onboarding-guide.scss +++ b/packages/trader/src/AppV2/Components/OnboardingGuide/onboarding-guide.scss @@ -9,6 +9,16 @@ align-items: flex-start; min-width: var(--core-size-4300); color: var(--component-textIcon-inverse-prominent); + + &-scroll { + display: flex; + flex-direction: column; + align-items: center; + + &-text { + color: var(--core-color-solid-slate-50); + } + } } &__button { @@ -29,6 +39,23 @@ inset-inline-start: var(--core-spacing-500); inset-block-end: var(--core-spacing-500); } + + @keyframes bounce { + 0%, + 100% { + transform: translateY(0); + } + 50% { + transform: translateY(-10px); + } + } + + &--bounce { + height: var(--core-spacing-3200); + width: var(--core-spacing-2400); + fill: var(--core-color-solid-slate-50); + animation: bounce var(--core-motion-duration-400) ease-in-out var(--core-motion-duration-100) infinite; + } } //TODO: remove after video for position page guide will be ready diff --git a/packages/trader/src/AppV2/Containers/Trade/trade.scss b/packages/trader/src/AppV2/Containers/Trade/trade.scss index 75b54851c697..814031fb2817 100644 --- a/packages/trader/src/AppV2/Containers/Trade/trade.scss +++ b/packages/trader/src/AppV2/Containers/Trade/trade.scss @@ -50,4 +50,7 @@ position: relative; } } + &__parameter { + display: inline; + } } diff --git a/packages/trader/src/AppV2/Containers/Trade/trade.tsx b/packages/trader/src/AppV2/Containers/Trade/trade.tsx index e2afc243cebb..41552829b320 100644 --- a/packages/trader/src/AppV2/Containers/Trade/trade.tsx +++ b/packages/trader/src/AppV2/Containers/Trade/trade.tsx @@ -88,12 +88,14 @@ const Trade = observer(() => { -
- -
+
+
+ +
+
{isAccumulatorContract(contract_type) && }
-
+