Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interactivity to course steps #7535

Merged
merged 35 commits into from Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8d0dbd7
Add tour kit step component for each view event
Imran92 Mar 11, 2024
83d322e
Transpile tour kit lib
Imran92 Mar 11, 2024
936cdf4
Add action in type for step
Imran92 Mar 11, 2024
9f6efd0
Add helper for common interactivity functions
Imran92 Mar 11, 2024
649443b
Add style for highlighting
Imran92 Mar 11, 2024
b0e1a3f
Add class to easily detect lesson save button
Imran92 Mar 11, 2024
3ba9e73
Add interaction for each step
Imran92 Mar 11, 2024
17c6d98
Separate step component
Imran92 Mar 11, 2024
e9acc25
Update sensei tour kit tests
Imran92 Mar 11, 2024
be176c3
Add tests for step component
Imran92 Mar 11, 2024
17c88bc
Handle saving lesson before editing step
Imran92 Mar 11, 2024
e39d22e
Fix tests
Imran92 Mar 11, 2024
d535ac3
Move wait for element to helper function
Imran92 Mar 12, 2024
aa76f2e
Add test for perform step action
Imran92 Mar 12, 2024
557d588
Test that highlighter is working properly
Imran92 Mar 12, 2024
200b522
Additional test case for highligher
Imran92 Mar 12, 2024
ecc88f7
Add tests for remove highlight classe
Imran92 Mar 12, 2024
4fddacd
Add tests for step function
Imran92 Mar 12, 2024
5fb7e34
Add test for waitForElement
Imran92 Mar 12, 2024
0d2671d
Use different function to focus on Course outline block
Imran92 Mar 12, 2024
f312ccb
Merge branch 'trunk' into add/interaction-on-course-step
Imran92 Mar 12, 2024
7338584
Fix function name case
Imran92 Mar 12, 2024
a3e23c0
Fix lint issue, use wpcomtourkit directly
Imran92 Mar 12, 2024
0cf12d6
Merge branch 'add/interaction-on-course-step' of https://github.com/A…
Imran92 Mar 12, 2024
93a3615
Reduce the shadow width
Imran92 Mar 12, 2024
3656fa6
Change default color of shadow
Imran92 Mar 13, 2024
721d705
Use outline instead of border
Imran92 Mar 13, 2024
edfc53a
Reduce box shadow width
Imran92 Mar 13, 2024
72a2f11
Change string passing style to tour kit
Imran92 Mar 13, 2024
78a9a06
Fix import position
Imran92 Mar 13, 2024
7033590
Remove unnecessary focus call
Imran92 Mar 13, 2024
d7a2440
Add jsdoc for performStepAction function
Imran92 Mar 13, 2024
be0505b
Use primary color instead of foreground
Imran92 Mar 13, 2024
5fbdb72
Remove extra class
Imran92 Mar 15, 2024
bf81ebd
Merge branch 'trunk' into add/interaction-on-course-step
Imran92 Mar 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 33 additions & 7 deletions assets/admin/tour/components/sensei-tour-kit/index.js
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { WpcomTourKit } from '@automattic/tour-kit';
import _ from 'lodash';

/**
Expand All @@ -15,6 +14,8 @@
*/
import { SENSEI_TOUR_STORE } from '../../data/store';
import { TourStep } from '../../types';
import { performStepAction, removeHighlightClasses } from '../../helper';
import { WpcomTourKit } from '@automattic/tour-kit';

/**
* Renders a tour kit component for Sensei.
Expand Down Expand Up @@ -69,11 +70,31 @@
},
},
callbacks: {
onNextStep: () => {},
onPreviousStep: () => {},
onGoToStep: () => {},
onMaximize: () => {},
onStepViewOnce: trackTourStepView,
onNextStep: ( index ) => {
performStepAction( index + 1, steps );

Check warning on line 74 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L74

Added line #L74 was not covered by tests
},
onPreviousStep: ( index ) => {
performStepAction( index - 1, steps );

Check warning on line 77 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L77

Added line #L77 was not covered by tests
},
onGoToStep: ( index ) => {
if ( index === steps.length - 1 ) {
performStepAction( 0, steps );

Check warning on line 81 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L81

Added line #L81 was not covered by tests
} else {
removeHighlightClasses();

Check warning on line 83 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L83

Added line #L83 was not covered by tests
}
},
onMaximize: ( index ) => {
performStepAction( index, steps );

Check warning on line 87 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L87

Added line #L87 was not covered by tests
},
onMinimize: () => {
removeHighlightClasses();

Check warning on line 90 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L90

Added line #L90 was not covered by tests
},
onStepViewOnce: ( index ) => {
if ( index === 0 ) {
performStepAction( index, steps );

Check warning on line 94 in assets/admin/tour/components/sensei-tour-kit/index.js

View check run for this annotation

Codecov / codecov/patch

assets/admin/tour/components/sensei-tour-kit/index.js#L94

Added line #L94 was not covered by tests
}
trackTourStepView( index );
},
},
},
placement: 'bottom-start',
Expand All @@ -83,7 +104,12 @@
return null;
}

return <WpcomTourKit config={ _.merge( config, extraConfig ) } />;
return (
<WpcomTourKit
__temp__className={ 'wpcom-tour-kit' }
renatho marked this conversation as resolved.
Show resolved Hide resolved
config={ _.merge( config, extraConfig ) }
/>
);
}

export default SenseiTourKit;
2 changes: 1 addition & 1 deletion assets/admin/tour/components/sensei-tour-kit/index.test.js
Expand Up @@ -3,13 +3,13 @@
*/
import SenseiTourKit from './index';
import getTourSteps from '../../course-tour/steps';
import { when } from 'jest-when';
renatho marked this conversation as resolved.
Show resolved Hide resolved
/**
* External dependencies
*/
import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import { WpcomTourKit } from '@automattic/tour-kit';
import { when } from 'jest-when';
/**
* WordPress dependencies
*/
Expand Down