@@ -63,24 +63,9 @@ type LabelMode =
6363type CursorType = "default" | "crosshair" | "drag" | "grabbing" ;
6464
6565const ACTIVITY_DATA = [
66- {
67- label : "New signup" ,
68- time : "2m ago" ,
69- component : "SignupRow" ,
70- comment : "new user joined" ,
71- } ,
72- {
73- label : "Order placed" ,
74- time : "5m ago" ,
75- component : "OrderRow" ,
76- comment : "check order #847" ,
77- } ,
78- {
79- label : "Payment received" ,
80- time : "12m ago" ,
81- component : "PaymentRow" ,
82- comment : "" ,
83- } ,
66+ { label : "New signup" , time : "2m ago" , component : "SignupRow" } ,
67+ { label : "Order placed" , time : "5m ago" , component : "OrderRow" } ,
68+ { label : "Payment received" , time : "12m ago" , component : "PaymentRow" } ,
8469] ;
8570
8671const createSelectionBox = ( position : Position , padding : number ) : BoxState => ( {
@@ -442,6 +427,37 @@ export const MobileDemoAnimation = (): ReactElement => {
442427 setCursorType ( "crosshair" ) ;
443428 } ;
444429
430+ const simulateComment = async (
431+ position : Position ,
432+ comment : string ,
433+ ) : Promise < void > => {
434+ await wait ( 300 ) ;
435+ if ( isCancelled ) return ;
436+
437+ setLabelMode ( "commenting" ) ;
438+ setCommentText ( "" ) ;
439+ await wait ( 200 ) ;
440+ if ( isCancelled ) return ;
441+
442+ for ( let j = 0 ; j <= comment . length ; j ++ ) {
443+ if ( isCancelled ) return ;
444+ setCommentText ( comment . slice ( 0 , j ) ) ;
445+ await wait ( 50 ) ;
446+ }
447+ await wait ( 300 ) ;
448+ if ( isCancelled ) return ;
449+
450+ setLabelMode ( "submitted" ) ;
451+ setSuccessFlash ( createSelectionBox ( position , SELECTION_PADDING_PX ) ) ;
452+ await wait ( 500 ) ;
453+ if ( isCancelled ) return ;
454+
455+ setSuccessFlash ( HIDDEN_BOX ) ;
456+ setSelectionBox ( HIDDEN_BOX ) ;
457+ await fadeOutSelectionLabel ( "Sent" ) ;
458+ setCommentText ( "" ) ;
459+ } ;
460+
445461 const animateDragSelection = async (
446462 startX : number ,
447463 startY : number ,
@@ -479,10 +495,11 @@ export const MobileDemoAnimation = (): ReactElement => {
479495 await wait ( 300 ) ;
480496 if ( isCancelled ) return ;
481497
498+ // 1. Export button - comment
482499 const buttonPos = exportButtonPosition . current ;
483500 const buttonCenter = getElementCenter ( buttonPos ) ;
484501 setCursorPos ( buttonCenter ) ;
485- await wait ( 450 ) ;
502+ await wait ( 400 ) ;
486503 if ( isCancelled ) return ;
487504
488505 setSelectionBox ( createSelectionBox ( buttonPos , SELECTION_PADDING_PX ) ) ;
@@ -492,65 +509,31 @@ export const MobileDemoAnimation = (): ReactElement => {
492509 "ExportBtn" ,
493510 "button" ,
494511 ) ;
495- await wait ( 600 ) ;
496- if ( isCancelled ) return ;
497-
498- await simulateClickAndCopy ( buttonPos ) ;
499- await wait ( 300 ) ;
512+ await simulateComment ( buttonPos , "add CSV option" ) ;
500513 if ( isCancelled ) return ;
501514
515+ // 2. MetricCard - comment
502516 const cardPos = metricCardPosition . current ;
503- const dragStartX = cardPos . x - DRAG_PADDING_PX ;
504- const dragStartY = cardPos . y - DRAG_PADDING_PX ;
505- const dragEndX = cardPos . x + cardPos . width + DRAG_PADDING_PX ;
506- const dragEndY = cardPos . y + cardPos . height + DRAG_PADDING_PX ;
507-
508- setCursorPos ( { x : dragStartX , y : dragStartY } ) ;
509- await wait ( 500 ) ;
510- if ( isCancelled ) return ;
511-
512- setIsDragging ( true ) ;
513- setCursorType ( "drag" ) ;
514- setDragBox ( {
515- visible : true ,
516- x : dragStartX ,
517- y : dragStartY ,
518- width : 0 ,
519- height : 0 ,
520- } ) ;
521- await animateDragSelection ( dragStartX , dragStartY , dragEndX , dragEndY ) ;
522- if ( isCancelled ) return ;
523- await wait ( 200 ) ;
517+ const cardCenter = getElementCenter ( cardPos ) ;
518+ setCursorPos ( cardCenter ) ;
519+ await wait ( 400 ) ;
524520 if ( isCancelled ) return ;
525521
526- setIsDragging ( false ) ;
527- setDragBox ( HIDDEN_BOX ) ;
528- setCursorType ( "grabbing" ) ;
529- setSuccessFlash ( createSelectionBox ( cardPos , SELECTION_PADDING_PX ) ) ;
522+ setSelectionBox ( createSelectionBox ( cardPos , SELECTION_PADDING_PX ) ) ;
530523 displaySelectionLabel (
531524 cardPos . x + cardPos . width / 2 ,
532525 cardPos . y - 10 ,
533526 "MetricCard" ,
534527 "div" ,
535528 ) ;
536- setLabelMode ( "grabbing" ) ;
537- await wait ( 500 ) ;
538- if ( isCancelled ) return ;
539-
540- setLabelMode ( "copied" ) ;
541- await wait ( 500 ) ;
542- if ( isCancelled ) return ;
543-
544- setSuccessFlash ( HIDDEN_BOX ) ;
545- await fadeOutSelectionLabel ( "Copied" ) ;
546- setCursorType ( "crosshair" ) ;
547- await wait ( 300 ) ;
529+ await simulateComment ( cardPos , "show graph" ) ;
548530 if ( isCancelled ) return ;
549531
532+ // 3. StatValue - comment
550533 const valuePos = metricValuePosition . current ;
551534 const valueCenter = getElementCenter ( valuePos ) ;
552535 setCursorPos ( valueCenter ) ;
553- await wait ( 500 ) ;
536+ await wait ( 400 ) ;
554537 if ( isCancelled ) return ;
555538
556539 setSelectionBox ( createSelectionBox ( valuePos , SELECTION_PADDING_PX ) ) ;
@@ -560,61 +543,47 @@ export const MobileDemoAnimation = (): ReactElement => {
560543 "StatValue" ,
561544 "span" ,
562545 ) ;
563- await wait ( 600 ) ;
546+ await simulateComment ( valuePos , "format as USD" ) ;
564547 if ( isCancelled ) return ;
565548
566- await simulateClickAndCopy ( valuePos ) ;
567- if ( isCancelled ) return ;
568-
569- for ( let i = 0 ; i < ACTIVITY_DATA . length - 1 ; i ++ ) {
570- if ( isCancelled ) return ;
571- const rowPos = activityRowPositions . current [ i ] ;
572- if ( ! rowPos ) continue ;
573- const activity = ACTIVITY_DATA [ i ] ;
574-
575- const rowCenter = getElementCenter ( rowPos ) ;
576- setCursorPos ( rowCenter ) ;
577- await wait ( 350 ) ;
549+ // 4. SignupRow - comment
550+ const signupRowPos = activityRowPositions . current [ 0 ] ;
551+ if ( signupRowPos ) {
552+ const signupCenter = getElementCenter ( signupRowPos ) ;
553+ setCursorPos ( signupCenter ) ;
554+ await wait ( 400 ) ;
578555 if ( isCancelled ) return ;
579556
580- setSelectionBox ( createSelectionBox ( rowPos , SELECTION_PADDING_PX ) ) ;
557+ setSelectionBox ( createSelectionBox ( signupRowPos , SELECTION_PADDING_PX ) ) ;
581558 displaySelectionLabel (
582- rowPos . x + 60 ,
583- rowPos . y + rowPos . height + 8 ,
584- activity . component ,
559+ signupRowPos . x + 60 ,
560+ signupRowPos . y + signupRowPos . height + 8 ,
561+ "SignupRow" ,
585562 "div" ,
586- false ,
587563 ) ;
588- await wait ( 300 ) ;
589- if ( isCancelled ) return ;
590-
591- // Switch to comment input mode
592- setLabelMode ( "commenting" ) ;
593- setCommentText ( "" ) ;
594- await wait ( 200 ) ;
564+ await simulateComment ( signupRowPos , "add avatar" ) ;
595565 if ( isCancelled ) return ;
566+ }
596567
597- // Type the comment character by character
598- const comment = activity . comment ;
599- for ( let j = 0 ; j <= comment . length ; j ++ ) {
600- if ( isCancelled ) return ;
601- setCommentText ( comment . slice ( 0 , j ) ) ;
602- await wait ( 50 ) ;
603- }
604- await wait ( 300 ) ;
568+ // 5. OrderRow - grab/copy (last one)
569+ const orderRowPos = activityRowPositions . current [ 1 ] ;
570+ if ( orderRowPos ) {
571+ const orderCenter = getElementCenter ( orderRowPos ) ;
572+ setCursorPos ( orderCenter ) ;
573+ await wait ( 400 ) ;
605574 if ( isCancelled ) return ;
606575
607- // Submit
608- setLabelMode ( "submitted" ) ;
609- setSuccessFlash ( createSelectionBox ( rowPos , SELECTION_PADDING_PX ) ) ;
610- await wait ( 500 ) ;
576+ setSelectionBox ( createSelectionBox ( orderRowPos , SELECTION_PADDING_PX ) ) ;
577+ displaySelectionLabel (
578+ orderRowPos . x + 60 ,
579+ orderRowPos . y + orderRowPos . height + 8 ,
580+ "OrderRow" ,
581+ "div" ,
582+ ) ;
583+ await wait ( 400 ) ;
611584 if ( isCancelled ) return ;
612585
613- // Fade out
614- setSuccessFlash ( HIDDEN_BOX ) ;
615- setSelectionBox ( HIDDEN_BOX ) ;
616- await fadeOutSelectionLabel ( "Sent" ) ;
617- setCommentText ( "" ) ;
586+ await simulateClickAndCopy ( orderRowPos ) ;
618587 if ( isCancelled ) return ;
619588 }
620589
0 commit comments