docbrown/app/javascript/onboarding/Onboarding.jsx
Jacob Herrington afc9351399 Onboarding a11y fixes (#4728) [deploy]
* Fix some eslint complaints

* Fix some basic a11y issues in onboarding

- Missing a main element
- TODO to enable zooming
- Rename a duplicate ID attribute

I may need some context on the zooming thing, why did we decided to
disable that in the first place? It is a pretty bad a11y issue, we will
need to fix whatever that is a workaround for instead of making it
difficult for some people to use our onboarding.

* Update screenshots
2019-11-06 12:51:13 -05:00

100 lines
2.9 KiB
JavaScript

import 'preact/devtools';
import { h, Component } from 'preact';
import IntroSlide from './components/IntroSlide';
import PersonalInfoForm from './components/PersonalInfoForm';
import EmailListTermsConditionsForm from './components/EmailListTermsConditionsForm';
import ClosingSlide from './components/ClosingSlide';
import FollowTags from './components/FollowTags';
import FollowUsers from './components/FollowUsers';
import BioForm from './components/BioForm';
// Current Onboarding Variants
// 0) Original intro slide: three explainer paragraphs, left adjusted.
// 1) Modified intro slide: Cat gif, let's get started.
// 2) Modified intro slide: Cat gif, We have a few quick questions to fill out your profile
// 3) Modified intro slide: Skull gif, The more you get involved in community, the better developer you will be.
// 4) Modified intro slide: Skull gif, You just made a great choice for your dev career
// 5) No intro slide.
// 6) Last slide challenge: Leave three constructive comments today
// 7) Last slide: Only display cue for welcome thread
// 8) Last slide: Only display cue for welcome thread, and also the leave three constructive comments challenge
// 9) Last slide: Only display cue for welcome thread, display challenge right in link body
export default class Onboarding extends Component {
constructor(props) {
super(props);
const url = new URL(window.location);
const previousLocation = url.searchParams.get('referrer');
let variant = '0';
if (url.searchParams.get('variant') || window.currentUser) {
variant =
url.searchParams.get('variant') ||
window.currentUser.onboarding_variant_version ||
'0';
}
this.nextSlide = this.nextSlide.bind(this);
this.prevSlide = this.prevSlide.bind(this);
let slides = [
IntroSlide,
EmailListTermsConditionsForm,
BioForm,
PersonalInfoForm,
FollowTags,
FollowUsers,
ClosingSlide,
];
if (variant === '5') {
slides = [
EmailListTermsConditionsForm,
BioForm,
PersonalInfoForm,
FollowTags,
FollowUsers,
ClosingSlide,
];
}
this.slides = slides.map(SlideComponent => (
<SlideComponent
next={this.nextSlide}
prev={this.prevSlide}
previousLocation={previousLocation}
variant={variant}
/>
));
this.state = {
currentSlide: 0,
};
}
nextSlide() {
const { currentSlide } = this.state;
const nextSlide = currentSlide + 1;
if (nextSlide < this.slides.length) {
this.setState({
currentSlide: nextSlide,
});
}
}
prevSlide() {
const { currentSlide } = this.state;
const prevSlide = currentSlide - 1;
if (prevSlide >= 0) {
this.setState({
currentSlide: prevSlide,
});
}
}
render() {
const { currentSlide } = this.state;
return <main className="onboarding-body">{this.slides[currentSlide]}</main>;
}
}