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
@@ -1,10 +1,10 @@
import { useState, useEffect } from 'react';
import PropTypes from 'prop-types';

Check warning on line 2 in packages/components/src/AppGuidedTour/AppGuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/AppGuidedTour/AppGuidedTour.component.js#L2

[prettier/prettier] Replace `PropTypes·from·'prop-types` with `{·useTranslation·}·from·'react-i18next`
import useLocalStorage from 'react-use/lib/useLocalStorage';
import { useTranslation } from 'react-i18next';

Check warning on line 4 in packages/components/src/AppGuidedTour/AppGuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/AppGuidedTour/AppGuidedTour.component.js#L4

[prettier/prettier] Replace `import·{·useTranslation·}·from·'react-i18next';` with `⏎import·PropTypes·from·'prop-types';⏎`
import GuidedTour from '../GuidedTour';
import Toggle from '../Toggle';

Check warning on line 6 in packages/components/src/AppGuidedTour/AppGuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/AppGuidedTour/AppGuidedTour.component.js#L6

[prettier/prettier] Replace `Toggle·from·'../Toggle` with `Stepper·from·'../Stepper`
import Stepper from '../Stepper';

Check warning on line 7 in packages/components/src/AppGuidedTour/AppGuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/AppGuidedTour/AppGuidedTour.component.js#L7

[prettier/prettier] Replace `Stepper·from·'../Stepper` with `Toggle·from·'../Toggle`
import I18N_DOMAIN_COMPONENTS from '../constants';
import DemoContentStep from './DemoContentStep.component';

Expand All @@ -21,6 +21,7 @@
onImportDemoContent,
onRequestClose,
welcomeStepBody = null,
tourId,
...rest
}) {
const { t } = useTranslation(I18N_DOMAIN_COMPONENTS);
Expand Down Expand Up @@ -52,6 +53,7 @@

return (
<GuidedTour
tourId={tourId}
isOpen={isOpen}
showButtons={!isNavigationDisabled}
showCloseButton={!isNavigationDisabled}
Expand Down Expand Up @@ -100,6 +102,7 @@
setImportDemoContent(event.target.checked);
}}
checked={importDemoContent}
data-feature={tourId && `guidedtour.${tourId}.demo`}
/>
</form>
)}
Expand Down Expand Up @@ -134,6 +137,7 @@
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
@@ -1,6 +1,6 @@
import { useState } from 'react';
import AppGuidedTour from './AppGuidedTour.component';
import Stepper from '../Stepper';

Check warning on line 3 in packages/components/src/AppGuidedTour/AppGuidedTour.stories.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/AppGuidedTour/AppGuidedTour.stories.js#L2-L3

[prettier/prettier] Replace `import·AppGuidedTour·from·'./AppGuidedTour.component';⏎import·Stepper·from·'../Stepper` with `⏎import·Stepper·from·'../Stepper';⏎import·AppGuidedTour·from·'./AppGuidedTour.component`

// eslint-disable-next-line react/prop-types
function AppGuidedTourContainer({ withDemoContent = false }) {
Expand All @@ -22,6 +22,7 @@

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
@@ -1,10 +1,10 @@
import { Fragment } from 'react';
import Tour from 'reactour';

Check warning on line 2 in packages/components/src/GuidedTour/GuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.component.js#L2

[prettier/prettier] Replace `Tour·from·'reactour` with `{·useTranslation·}·from·'react-i18next`
import PropTypes from 'prop-types';

Check warning on line 3 in packages/components/src/GuidedTour/GuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.component.js#L3

[prettier/prettier] Replace `PropTypes·from·'prop-types';` with `Tour·from·'reactour';⏎`
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';

Check warning on line 5 in packages/components/src/GuidedTour/GuidedTour.component.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.component.js#L5

[prettier/prettier] Replace `{·useTranslation·}·from·'react-i18next';` with `PropTypes·from·'prop-types';⏎`
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 @@
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 @@
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 @@
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
@@ -1,11 +1,11 @@
/* eslint-disable react/prop-types */
import { Component, Fragment } from 'react';
import { action } from '@storybook/addon-actions';

Check warning on line 3 in packages/components/src/GuidedTour/GuidedTour.stories.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.stories.js#L3

[prettier/prettier] Insert `withTranslation·}·from·'react-i18next';⏎⏎import·{·`
import tokens from '@talend/design-tokens';

Check warning on line 4 in packages/components/src/GuidedTour/GuidedTour.stories.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.stories.js#L4

[prettier/prettier] Insert `⏎`
import { withTranslation } from 'react-i18next';

Check warning on line 6 in packages/components/src/GuidedTour/GuidedTour.stories.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.stories.js#L5-L6

[prettier/prettier] Replace `import·{·withTranslation·}·from·'react-i18next';⏎` with `⏎import·I18N_DOMAIN_COMPONENTS·from·'../constants';`
import GuidedTour from './GuidedTour.component';
import I18N_DOMAIN_COMPONENTS from '../constants';

Check warning on line 8 in packages/components/src/GuidedTour/GuidedTour.stories.js

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/components/src/GuidedTour/GuidedTour.stories.js#L7-L8

[prettier/prettier] Delete `';⏎import·I18N_DOMAIN_COMPONENTS·from·'../constants`

class ImportDemo extends Component {
state = {
Expand Down Expand Up @@ -76,6 +76,7 @@
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
Loading