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

feat(TDP-12694): add pendo trackers to guided-tour actions #4982

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/green-drinks-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/react-components': minor
---

feat(TDP-12694): add pendo trackers to guided-tour actions
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function AppGuidedTour({
onImportDemoContent,
onRequestClose,
welcomeStepBody = null,
tourId,
...rest
}) {
const { t } = useTranslation(I18N_DOMAIN_COMPONENTS);
Expand Down Expand Up @@ -52,6 +53,7 @@ function AppGuidedTour({

return (
<GuidedTour
tourId={tourId}
isOpen={isOpen}
showButtons={!isNavigationDisabled}
showCloseButton={!isNavigationDisabled}
Expand Down Expand Up @@ -100,6 +102,7 @@ function AppGuidedTour({
setImportDemoContent(event.target.checked);
}}
checked={importDemoContent}
data-feature={tourId && `guidedtour.${tourId}.demo`}
/>
</form>
)}
Expand Down Expand Up @@ -134,6 +137,7 @@ AppGuidedTour.propTypes = {
onRequestOpen: PropTypes.func.isRequired,
onImportDemoContent: PropTypes.func,
onRequestClose: PropTypes.func.isRequired,
tourId: PropTypes.string,
};

export default AppGuidedTour;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function AppGuidedTourContainer({ withDemoContent = false }) {

return (
<AppGuidedTour
tourId="preparation"
isOpen
appName="Data Preparation"
steps={[
Expand Down
34 changes: 28 additions & 6 deletions packages/components/src/GuidedTour/GuidedTour.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import Tour from 'reactour';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { ButtonIcon, ButtonPrimary } from '@talend/design-system';

import Action from '../Actions/Action';
import I18N_DOMAIN_COMPONENTS from '../constants';

import theme from './GuidedTour.module.scss';
Expand Down Expand Up @@ -35,13 +35,16 @@ function GuidedTour({
disableAllInteractions,
steps,
lastStepNextButtonDataFeature,
tourId,
...rest
}) {
const { t } = useTranslation(I18N_DOMAIN_COMPONENTS);
if (!steps.length) {
return null;
}

const dataFeature = action => tourId && `guidedtour.${tourId}.${action}`;

return (
<Tour
className={classNames(
Expand All @@ -56,11 +59,29 @@ function GuidedTour({
disableInteraction
highlightedMaskClassName="tc-guided-tour__highlighted-mask"
lastStepNextButton={
<Action
bsStyle="info"
label={t('GUIDEDTOUR_LAST_STEP', { defaultValue: 'Let me try' })}
data-feature={lastStepNextButtonDataFeature}
/>
<ButtonPrimary data-feature={lastStepNextButtonDataFeature ?? dataFeature('last')}>
{t('GUIDEDTOUR_LAST_STEP', 'Let me try')}
</ButtonPrimary>
}
nextButton={
<ButtonIcon
size="S"
onClick={() => {}}
icon="arrow-right"
data-feature={dataFeature('next')}
>
{t('GUIDEDTOUR_NEXT_STEP', 'Next')}
</ButtonIcon>
}
prevButton={
<ButtonIcon
size="S"
onClick={() => {}}
icon="arrow-left"
data-feature={dataFeature('prev')}
>
{t('GUIDEDTOUR_PREV_STEP', 'Previous')}
</ButtonIcon>
}
maskSpace={10}
rounded={4}
Expand Down Expand Up @@ -98,6 +119,7 @@ GuidedTour.propTypes = {
onRequestClose: PropTypes.func,
disableAllInteractions: PropTypes.bool,
lastStepNextButtonDataFeature: PropTypes.string,
tourId: PropTypes.string,
};

export default GuidedTour;
2 changes: 1 addition & 1 deletion packages/components/src/GuidedTour/GuidedTour.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $tc-guidedtour-tooltip-padding: $padding-large !default;
$tc-guidedtour-mask-opactiy: 0.25 !default;
$tc-guidedtour-close-button-size: $svg-sm-size !default;
$tc-guidedtour-nav-button-size: $svg-md-size !default;
$tc-guidedtour-controls-color: tokens.$coral-color-neutral-text !default;
$tc-guidedtour-controls-color: tokens.$coral-color-accent-text !default;
$tc-guidedtour-width: 40rem !default;

/* stylelint-disable-next-line selector-id-pattern*/
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/GuidedTour/GuidedTour.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class GuidedTourContainer extends Component {
t: this.props.t,
})}
lastStepNextButtonDataFeature="HOHOOO"
tourId="my-tour"
onRequestClose={this.closeTour}
isOpen={isOpen}
showCloseButton={controls}
Expand Down
32 changes: 17 additions & 15 deletions packages/components/src/GuidedTour/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ The guided tour is based on [reactour](https://github.com/elrumordelaluz/reactou

## Props

| Props | Type | Description |
| ----- | ---- | ----------- |
| `className` | string | CSS classes for guided tour component |
| `steps` | array of object or function | Array of steps to construct the guided tour |
| `isOpen` | boolean | If true, guided tour will start |
| `onRequestClose` | function | Callback when user close i.e. to toggle `isOpen` |
| `disableAllInteractions` | boolean | If true, all controls will disappear |
| Props | Type | Description |
| ------------------------------- | --------------------------- | ------------------------------------------------------------------------- |
|  `className` | string | CSS classes for guided tour component |
|  `steps` | array of object or function | Array of steps to construct the guided tour |
|  `isOpen` |  boolean |  If true, guided tour will start |
|  `onRequestClose` | function | Callback when user close i.e. to toggle `isOpen` |
| `disableAllInteractions` |  boolean | If true, all controls will disappear |
| `lastStepNextButtonDataFeature` | string | value to data-feature attribute of last step next button |
| `tourId` | string | tour identifier to be used in data-feature attribute of prev/next buttons |

## Style

Those classes are accessible from outside.

| CSS class | Type | Description |
| --------- | ---- | ----------- |
| `.tc-react-tour` | block | The guided tour |
| `.tc-react-tour__mask` | element | The dark overlay |
| `.tc-react-tour__highlighted-mask` | element | The light overlay to highlight element |
| `.tc-react-tour__header` | element | The header of the tooltip |
| `.tc-react-tour__body` | element | The body of the tooltip |
| `.tc-react-tour--no-interaction` | modifier | The guided tour without any controls |
| CSS class | Type | Description |
| ---------------------------------- | -------- | -------------------------------------- |
| `.tc-react-tour` | block | The guided tour |
| `.tc-react-tour__mask` | element | The dark overlay |
| `.tc-react-tour__highlighted-mask` | element | The light overlay to highlight element |
| `.tc-react-tour__header` | element | The header of the tooltip |
| `.tc-react-tour__body` | element | The body of the tooltip |
| `.tc-react-tour--no-interaction` | modifier | The guided tour without any controls |
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,20 @@ exports[`Guided Tour Container should render 1`] = `
data-tour-elem="controls"
>
<button
class="sc-aXZVg cdorhc sc-eqUAAy cTnNMO"
class="sc-aXZVg cdorhc sc-eqUAAy jLJOIm"
data-tour-elem="left-arrow"
disabled=""
>
<svg
viewBox="0 0 18.4 14.4"
<span
class="sc-gEvEer fZNxWp"
>
<path
d="M1.4 7.2h16M7.6 1L1.4 7.2l6.2 6.2"
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-miterlimit="10"
stroke-width="2"
/>
</svg>
<span
class="CoralButtonIcon"
icon="arrow-left"
>
Previous
</span>
</span>
</button>
<nav
class="sc-kAyceB cIhnUi"
Expand All @@ -209,21 +207,19 @@ exports[`Guided Tour Container should render 1`] = `
/>
</nav>
<button
class="sc-aXZVg dbJwZj sc-eqUAAy eqHGdD"
class="sc-aXZVg dbJwZj sc-eqUAAy gcKufz"
data-tour-elem="right-arrow"
>
<svg
viewBox="0 0 18.4 14.4"
<span
class="sc-gEvEer fZNxWp"
>
<path
d="M17 7.2H1M10.8 1L17 7.2l-6.2 6.2"
fill="none"
stroke="currentColor"
stroke-linecap="round"
stroke-miterlimit="10"
stroke-width="2"
/>
</svg>
<span
class="CoralButtonIcon"
icon="arrow-right"
>
Next
</span>
</span>
</button>
</div>
<button
Expand Down