Skip to content

Commit

Permalink
Add a welcome tab to the demo page
Browse files Browse the repository at this point in the history
- A short introduction and welcome page for new users.
- Should be opened automatically upon first install.
  • Loading branch information
joelpurra committed Dec 9, 2017
1 parent f654933 commit f8ecde8
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 84 deletions.
48 changes: 44 additions & 4 deletions src/demo/components/main.jsx
Expand Up @@ -38,6 +38,7 @@ import Features from "./sections/features.jsx";
import Support from "./sections/support.jsx";
import Usage from "./sections/usage.jsx";
import VoicesContainer from "../containers/voices-container.jsx";
import Welcome from "./sections/welcome.jsx";

const widthStyles = {
minWidth: "400px",
Expand All @@ -62,9 +63,16 @@ export default class Main extends React.Component {

this.handleLinkClick = this.handleLinkClick.bind(this);
this.handleOpenShortKeysConfigurationClick = this.handleOpenShortKeysConfigurationClick.bind(this);
this.playWelcomeMessage = this.playWelcomeMessage.bind(this);

// TODO: better place to put navigation menu links?
this.links = [
{
tabId: "welcome",
// TODO: translate.
text: "Welcome",
// text: this.props.translate("frontend_welcomeLinkText"),
},
{
tabId: "voices",
text: this.props.translate("frontend_voicesLinkText"),
Expand Down Expand Up @@ -118,6 +126,9 @@ export default class Main extends React.Component {
versionName: null,
systemType: null,
osType: null,
voicesCount: 0,
languagesCount: 0,
languageGroupsCount: 0,
activeTabId: null,
};

Expand All @@ -128,6 +139,9 @@ export default class Main extends React.Component {
versionName: PropTypes.string.isRequired,
systemType: PropTypes.string.isRequired,
osType: PropTypes.string,
voicesCount: PropTypes.number.isRequired,
languagesCount: PropTypes.number.isRequired,
languageGroupsCount: PropTypes.number.isRequired,
activeTabId: PropTypes.string.isRequired,
className: PropTypes.string.isRequired,
translate: PropTypes.func.isRequired,
Expand All @@ -152,10 +166,6 @@ export default class Main extends React.Component {
window.scroll(0, 0);
}

openUrlInNewTab(url) {
this.props.actions.sharedNavigation.openUrlInNewTab(url);
}

handleOpenShortKeysConfigurationClick() {
this.props.actions.sharedNavigation.openShortKeysConfiguration();
}
Expand All @@ -164,6 +174,18 @@ export default class Main extends React.Component {
this.props.actions.sharedNavigation.openUrlInNewTab(url);
}

playWelcomeMessage() {
// TODO: translate.
const text = `Welcome to ${this.props.translate("extensionShortName")}! You are now using one of the best text-to-speech browser extensions in the world!`;
// const text = this.props.translate(...);

const voice = {
lang: this.props.translate("extensionLocale"),
};

this.props.actions.sharedVoices.speak(text, voice);
}

render() {
const {
activeTabId,
Expand All @@ -172,6 +194,9 @@ export default class Main extends React.Component {
versionName,
systemType,
osType,
voicesCount,
languagesCount,
languageGroupsCount,
className,
} = this.props;

Expand All @@ -196,6 +221,21 @@ export default class Main extends React.Component {
<this.styled.main
onClick={this.handleClick}
>
<TabContents
id="welcome"
activeTabId={activeTabId}
onLinkClick={this.handleLinkClick}
>
<Welcome
isPremiumVersion={isPremiumVersion}
systemType={systemType}
osType={osType}
voicesCount={voicesCount}
languagesCount={languagesCount}
languageGroupsCount={languageGroupsCount}
playWelcomeMessage={this.playWelcomeMessage}
/>
</TabContents>

<TabContents
id="voices"
Expand Down
4 changes: 0 additions & 4 deletions src/demo/components/sections/support.jsx
Expand Up @@ -42,10 +42,6 @@ export default class Features extends React.Component {
super(props);

this.styled = {
p: styled({
marginBottom: "0.5em",
})(textBase.p),

summaryH4: styled({
display: "inline-block",
margin: 0,
Expand Down
167 changes: 167 additions & 0 deletions src/demo/components/sections/welcome.jsx
@@ -0,0 +1,167 @@
/*
This file is part of Talkie -- text-to-speech browser extension button.
<https://joelpurra.com/projects/talkie/>
Copyright (c) 2016, 2017 Joel Purra <https://joelpurra.com/>
Talkie is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Talkie is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Talkie. If not, see <https://www.gnu.org/licenses/>.
*/

import React from "react";
import PropTypes from "prop-types";

import configureAttribute from "../../../shared/hocs/configure.jsx";
import translateAttribute from "../../../shared/hocs/translate.jsx";
import styled from "../../../shared/hocs/styled.jsx";

import * as layoutBase from "../../../shared/styled/layout/layout-base.jsx";
import * as textBase from "../../../shared/styled/text/text-base.jsx";
import * as listBase from "../../../shared/styled/list/list-base.jsx";
import * as buttonBase from "../../../shared/styled/button/button-base.jsx";

import Discretional from "../../../shared/components/discretional.jsx";
import VersionSection from "../../../shared/components/section/version-section.jsx";
import FreeSection from "../../../shared/components/section/free-section.jsx";
import PremiumSection from "../../../shared/components/section/premium-section.jsx";
import TalkieVersionIcon from "../../../shared/components/icon/talkie-version-icon.jsx";
import TalkieFreeIcon from "../../../shared/components/icon/talkie-free-icon.jsx";
import TalkiePremiumIcon from "../../../shared/components/icon/talkie-premium-icon.jsx";

@configureAttribute
@translateAttribute
export default class Features extends React.Component {
constructor(props) {
super(props);

this.handlePlayWelcomeMessageButtonClick = this.handlePlayWelcomeMessageButtonClick.bind(this);

this.styled = {
heroDiv: styled({
fontSize: "2em",
lineHeight: "1.5em",
})("div"),
};
}

static defaultProps = {
isPremiumVersion: false,
systemType: false,
osType: false,
voicesCount: 0,
languagesCount: 0,
languageGroupsCount: 0,
playWelcomeMessage: null,
};

static propTypes = {
isPremiumVersion: PropTypes.bool.isRequired,
systemType: PropTypes.string.isRequired,
osType: PropTypes.string.isRequired,
voicesCount: PropTypes.number.isRequired,
languagesCount: PropTypes.number.isRequired,
languageGroupsCount: PropTypes.number.isRequired,
playWelcomeMessage: PropTypes.func.isRequired,
translate: PropTypes.func.isRequired,
configure: PropTypes.func.isRequired,
}

componentDidMount() {
this.props.playWelcomeMessage();
}

handlePlayWelcomeMessageButtonClick(e) {
this.props.playWelcomeMessage();
}

render() {
const {
isPremiumVersion,
systemType,
osType,
voicesCount,
languagesCount,
languageGroupsCount,
translate,
configure,
} = this.props;

// TODO: configuration.
const devModeShowAll = false;

return (
<section>
<VersionSection
isPremiumVersion={isPremiumVersion}
>
<this.styled.heroDiv>
<textBase.p>
{/* TODO: translate */}
Welcome to {translate("extensionShortName")}! You are now using one of the best text-to-speech browser extensions in the world! You can go ahead and test it by selecting this text, and then clicking the
<TalkieVersionIcon
isPremiumVersion={isPremiumVersion}
/>
{translate("extensionShortName")} button in the browser bar.
</textBase.p>
</this.styled.heroDiv>
</VersionSection>

<textBase.h2>
{/* TODO: translate */}
Want to install more voices?
</textBase.h2>

<textBase.p>
{/* TODO: translate */}
Talkie can currently find <strong>{languageGroupsCount} languages</strong> with <strong>{languagesCount} dialects</strong>, and <strong>{voicesCount} voices</strong> installed on your system.
{" "}
<Discretional
enabled={devModeShowAll || osType === "win"}
>
<textBase.span>
{/* TODO: translate */}
You can add more voices from both Microsoft and others; see separate installation instructions. <textBase.a href="https://support.office.com/en-us/article/How-to-download-Text-to-Speech-languages-for-Windows-10-d5a6b612-b3ae-423f-afa5-4f6caf1ec5d3">Windows 10</textBase.a>, <textBase.a href="https://support.office.com/en-us/article/How-to-download-Text-to-Speech-languages-for-Windows-4c83a8d8-7486-42f7-8e46-2b0fdf753130">Windows 8</textBase.a>, <textBase.a href="https://www.microsoft.com/en-us/download/details.aspx?id=27224">Windows 7</textBase.a>, <textBase.a href="http://espeak.sourceforge.net">eSpeak (open source)</textBase.a>.
</textBase.span>
</Discretional>

<Discretional
enabled={devModeShowAll || osType === "cros"}
>
<textBase.span>
{/* TODO: translate */}
Any additions to ChromeOS should be available in the Chrome Web Store. One example is <textBase.a href="https://chrome.google.com/webstore/detail/us-english-female-text-to/pkidpnnapnfgjhfhkpmjpbckkbaodldb">US English Female Text-to-speech (by Google)</textBase.a>.
</textBase.span>
</Discretional>

<Discretional
enabled={devModeShowAll || osType === "mac"}
>
<textBase.span>
{/* TODO: translate */}
Additional voices can be automatically installed from the system preferences for speech; see separate installation instructions. <textBase.a href="https://support.apple.com/kb/PH25378">macOS Sierra (10.12)</textBase.a>.
</textBase.span>
</Discretional>

<Discretional
enabled={devModeShowAll || osType === "linux"}
>
<textBase.span>
{/* TODO: translate */}
Currently not sure, as I have not tried installing voices myself on any distributions. It is also a matter of if and how browers detect any installed voices. See separate installation instructions. Please let me know what your expirences are! <textBase.a href="http://espeak.sourceforge.net">eSpeak (open source)</textBase.a>.
</textBase.span>
</Discretional>
</textBase.p>
</section>
);
}
}
9 changes: 9 additions & 0 deletions src/demo/containers/app.jsx
Expand Up @@ -34,17 +34,20 @@ import Main from "../components/main.jsx";
import actionCreators from "../actions";

import {
getLanguageGroupsFromLanguages,
getLanguagesFromVoices,
} from "../../shared/utils/transform-voices";

const mapStateToProps = (state) => {
const languages = getLanguagesFromVoices(state.shared.voices.voices);
const languageGroups = getLanguageGroupsFromLanguages(languages);

return {
voices: state.shared.voices.voices,
languages: languages,
voicesCount: state.shared.voices.voices.length,
languagesCount: languages.length,
languageGroupsCount: languageGroups.length,
isPremiumVersion: state.shared.metadata.isPremiumVersion,
versionNumber: state.shared.metadata.versionNumber,
versionName: state.shared.metadata.versionName,
Expand All @@ -69,6 +72,9 @@ export default class App extends React.Component {
static defaultProps = {
voices: [],
languages: [],
voicesCount: 0,
languagesCount: 0,
languageGroupsCount: 0,
isPremiumVersion: false,
versionNumber: null,
versionName: null,
Expand All @@ -89,6 +95,7 @@ export default class App extends React.Component {
languages: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
voicesCount: PropTypes.number.isRequired,
languagesCount: PropTypes.number.isRequired,
languageGroupsCount: PropTypes.number.isRequired,
isPremiumVersion: PropTypes.bool.isRequired,
versionNumber: PropTypes.string.isRequired,
versionName: PropTypes.string.isRequired,
Expand All @@ -104,6 +111,7 @@ export default class App extends React.Component {
languages,
voicesCount,
languagesCount,
languageGroupsCount,
isPremiumVersion,
versionNumber,
versionName,
Expand All @@ -119,6 +127,7 @@ export default class App extends React.Component {
languages={languages}
voicesCount={voicesCount}
languagesCount={languagesCount}
languageGroupsCount={languageGroupsCount}
isPremiumVersion={isPremiumVersion}
versionNumber={versionNumber}
versionName={versionName}
Expand Down

0 comments on commit f8ecde8

Please sign in to comment.