Mailspring/app/internal_packages/onboarding/lib/page-tutorial.tsx
Ben Gotow 149b389508
Replace Babel with TypeScript compiler, switch entire app to TypeScript 🎉 (#1404)
* Switch to using Typescript instead of Babel

* Switch all es6 / jsx file extensions to ts / tsx

* Convert Utils to a TS module from module.exports style module

* Move everything from module.exports to typescript exports

* Define .d.ts files for mailspring-exports and component kit… Yes it seems this is the best option :(

* Load up on those @types

* Synthesize TS types from PropTypes for standard components

* Add types to Model classes and move constructor constants to instance vars

* 9800 => 7700 TS errors

* 7700 => 5600 TS errors

* 5600 => 5330 TS errors

* 5330 => 4866 TS errors

* 4866 => 4426 TS errors

* 4426 => 2411 TS errors

* 2411 > 1598 TS errors

* 1598 > 769 TS errors

* 769 > 129 TS errors

* 129 > 22 TS errors

* Fix runtime errors

* More runtime error fixes

* Remove support for custom .es6 file extension

* Remove a few odd remaining references to Nylas

* Don’t ship Typescript support in the compiled app for now

* Fix issues in compiled app - module resolution in TS is case sensitive?

* README updates

* Fix a few more TS errors

* Make “No Signature” option clickable + selectable

* Remove flicker when saving file and reloading keymaps

* Fix mail rule item height in preferences

* Fix missing spacing in thread sharing popover

* Fix scrollbar ticks being nested incorrectly

* Add Japanese as a manually reviewed language

* Prevent the thread list from “sticking”

* Re-use Sheet when switching root tabs, prevent sidebar from resetting

* Ensure specs run

* Update package configuration to avoid shpping types

* Turn eslint back on - we will opt-in to the TS rules one by one
2019-03-04 11:03:12 -08:00

161 lines
4.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { localized, React } from 'mailspring-exports';
import * as OnboardingActions from './onboarding-actions';
const Steps = [
{
seen: false,
id: 'people',
title: localized('Compose with context'),
image: 'feature-people@2x.png',
description: localized(
'Mailspring shows you everything about your contacts right inside your inbox. See LinkedIn profiles, Twitter bios, message history, and more.'
),
x: 96.6,
y: 1.3,
xDot: 93.5,
yDot: 5.4,
},
{
seen: false,
id: 'activity',
title: localized('Track opens and clicks'),
image: 'feature-activity@2x.png',
description: localized(
'With activity tracking, youll know as soon as someone reads your message. Sending to a group? Mailspring shows you which recipients opened your email so you can follow up with precision.'
),
x: 12.8,
y: 1,
xDot: 15,
yDot: 5.1,
},
{
seen: false,
id: 'snooze',
title: localized('Send on your own schedule'),
image: 'feature-snooze@2x.png',
description: localized(
'Snooze emails to return at any time that suits you. Schedule messages to send at the ideal time. Mailspring makes it easy to control the fabric of spacetime!'
),
x: 5.5,
y: 23.3,
xDot: 10,
yDot: 25.9,
},
// {
// seen: false,
// id: 'composer',
// title: 'Eliminate hacky extensions',
// image: 'feature-composer@2x.png',
// description: "Embed calendar invitations, propose meeting times, use quick reply templates, send mass emails with mail merge, and more—all directly from Mailsprings powerful composer.",
// x: 60.95,
// y: 66,
// xDot: 60.3,
// yDot: 65.0,
// },
];
export default class TutorialPage extends React.Component<
{},
{ appeared: boolean; seen: any[]; current: any }
> {
static displayName = 'TutorialPage';
_timer: NodeJS.Timeout;
constructor(props) {
super(props);
this.state = {
appeared: false,
seen: [],
current: Steps[0],
};
}
componentDidMount() {
this._timer = setTimeout(() => {
this.setState({ appeared: true });
}, 200);
}
componentWillUnmount() {
clearTimeout(this._timer);
}
_onBack = () => {
const nextItem = this.state.seen.pop();
if (!nextItem) {
OnboardingActions.moveToPreviousPage();
} else {
this.setState({ current: nextItem });
}
};
_onNextUnseen = () => {
const nextSeen = [].concat(this.state.seen, [this.state.current]);
const nextItem = Steps.find(s => !nextSeen.includes(s));
if (nextItem) {
this.setState({ current: nextItem, seen: nextSeen });
} else {
OnboardingActions.moveToPage('authenticate');
}
};
_onMouseOverOverlay = event => {
const item = Steps.find(i => i.id === event.target.id);
if (item) {
if (!this.state.seen.includes(item)) {
this.state.seen.push(item);
}
this.setState({ current: item });
}
};
render() {
const { current, seen, appeared } = this.state;
return (
<div className={`page tutorial appeared-${appeared}`}>
<div className="tutorial-container">
<div className="left">
<div className="screenshot">
{Steps.map(step => (
<div
key={step.id}
id={step.id}
className={`overlay ${seen.includes(step) ? 'seen' : ''} ${
current === step ? 'expanded' : ''
}`}
style={{ left: `${step.xDot}%`, top: `${step.yDot}%` }}
onMouseOver={this._onMouseOverOverlay}
>
<div
className="overlay-content"
style={{ backgroundPosition: `${step.x}% ${step.y}%` }}
/>
</div>
))}
</div>
</div>
<div className="right">
<img
src={`mailspring://onboarding/assets/${current.image}`}
style={{ zoom: 0.5, margin: 'auto' }}
alt=""
/>
<h2>{current.title}</h2>
<p>{current.description}</p>
</div>
</div>
<div className="footer">
<button key="prev" className="btn btn-large btn-prev" onClick={this._onBack}>
{localized('Back')}
</button>
<button key="next" className="btn btn-large btn-next" onClick={this._onNextUnseen}>
{seen.length < Steps.length ? localized('Next') : localized('Get Started')}
</button>
</div>
</div>
);
}
}