scratch-www/src/views/download/download.jsx

330 lines
16 KiB
React
Raw Normal View History

const FormattedMessage = require('react-intl').FormattedMessage;
const injectIntl = require('react-intl').injectIntl;
const intlShape = require('react-intl').intlShape;
const React = require('react');
2017-03-31 19:35:33 -04:00
const FlexRow = require('../../components/flex-row/flex-row.jsx');
2018-12-10 17:33:22 -05:00
const bindAll = require('lodash.bindall');
2017-03-31 19:35:33 -04:00
const Page = require('../../components/page/www/page.jsx');
const render = require('../../lib/render.jsx');
const detectOS = require('../../lib/detect-os.js').default;
const OS_ENUM = require('../../lib/os-enum.js');
const {CHROME_APP_RELEASED} = require('../../lib/feature-flags.js');
2018-12-10 17:33:22 -05:00
const OSChooser = require('../../components/os-chooser/os-chooser.jsx');
const InstallScratch = require('../../components/install-scratch/install-scratch.jsx');
const {isDownloaded, isFromGooglePlay} = require('../../components/install-scratch/install-util.js');
2017-04-06 10:40:46 -04:00
require('./download.scss');
2017-05-03 16:19:56 -04:00
require('../../components/forms/button.scss');
2017-04-01 10:55:47 -04:00
class Download extends React.Component {
constructor (props) {
super(props);
2018-12-10 17:33:22 -05:00
bindAll(this, [
'onSetOS'
]);
2018-12-10 17:33:22 -05:00
this.state = {
OS: detectOS()
};
}
2018-12-10 17:33:22 -05:00
onSetOS (os) {
this.setState({
OS: os
});
}
2018-12-10 17:33:22 -05:00
render () {
2017-04-01 10:55:47 -04:00
return (
<div className="download">
2018-12-10 17:33:22 -05:00
<div className="download-header">
<FlexRow className="inner">
<FlexRow className="column download-info">
<FlexRow className="column download-copy">
<h1 className="download-title">
<img
2018-12-11 11:55:42 -05:00
alt={this.props.intl.formatMessage({id: 'download.iconAltText'})}
2018-12-13 10:14:24 -05:00
className="icon"
height="40"
2018-12-13 14:57:21 -05:00
src="/images/download/icon.png"
width="40"
/>
<FormattedMessage
id={CHROME_APP_RELEASED ? 'download.appTitle' :
'download.title'}
/>
2018-12-10 17:33:22 -05:00
</h1>
<span className="download-description">
<FormattedMessage
id={CHROME_APP_RELEASED ? 'download.appIntro' :
'download.intro'}
/>
</span>
2018-12-10 17:33:22 -05:00
</FlexRow>
<FlexRow className="column download-requirements-container">
<span className="requirements-header">
<FormattedMessage id="download.requirements" />
</span>
<FlexRow className="download-requirements">
<span>
<img
alt=""
src="/svgs/extensions/windows.svg"
/>
Windows 10+
</span>
<span>
<img
alt=""
src="svgs/extensions/mac.svg"
/>
macOS 10.13+
</span>
{CHROME_APP_RELEASED && (
<React.Fragment>
<span>
<img
alt=""
src="svgs/extensions/chromeos.svg"
/>
ChromeOS
</span>
<span>
<img
alt=""
src="svgs/extensions/android.svg"
/>
2019-10-02 18:57:06 -04:00
Android 6.0+
</span>
</React.Fragment>
)}
2018-12-10 17:33:22 -05:00
</FlexRow>
</FlexRow>
2018-12-10 17:33:22 -05:00
</FlexRow>
<div className="download-image">
<img
alt={this.props.intl.formatMessage({id: 'download.imgAltDownloadIllustration'})}
src="/images/download/download.png"
/>
</div>
2018-12-10 17:33:22 -05:00
</FlexRow>
</div>
<OSChooser
currentOS={this.state.OS}
handleSetOS={this.onSetOS}
/>
<InstallScratch currentOS={this.state.OS} />
{isDownloaded(this.state.OS) && (
<div className="download-section">
<FlexRow className="inner column">
<h2 className="title">
<FormattedMessage id="download.olderVersionsTitle" />
</h2>
<p>
<FormattedMessage id="download.olderVersions" />
</p>
<FlexRow>
<div className="older-version">
<a href="/download/scratch2">
<img
alt=""
className="screenshot"
height="106"
src="/images/download/scratch2.png"
width="150"
/>
</a>
<p>
2018-12-10 17:33:22 -05:00
<a
className="legacy-link"
href="/download/scratch2"
2018-12-10 17:33:22 -05:00
>
<FormattedMessage id="download.scratch2Desktop" />
<img
className="little-arrow"
src="/svgs/download/r-arrow.svg"
/>
2018-12-10 17:33:22 -05:00
</a>
</p>
2018-12-10 17:33:22 -05:00
</div>
<div className="older-version">
<a href="/scratch_1.4">
<img
alt=""
className="screenshot"
height="106"
src="/images/download/scratch1-4.png"
width="150"
/>
</a>
<p>
<a
className="legacy-link"
href="/scratch_1.4"
>
<FormattedMessage id="download.scratch1-4Desktop" />
<img
className="little-arrow"
src="/svgs/download/r-arrow.svg"
/>
</a>
</p>
</div>
</FlexRow>
</FlexRow>
</div>
)}
2018-12-10 17:33:22 -05:00
<div className="download-section faq">
<FlexRow className="inner column">
<h2 className="title">
<FormattedMessage id="download.troubleshootingTitle" />
</h2>
<h3 className="faq-question">
<FormattedMessage id="download.doIHaveToDownload" />
</h3>
<p>
<FormattedMessage id="download.doIHaveToDownloadAnswer" />
</p>
<h3 className="faq-question">
<FormattedMessage id="download.howConnectHardwareDevices" />
</h3>
{isDownloaded(this.state.OS) && (
<p>
<FormattedMessage
id="download.howConnectHardwareDevicesAnswerLink"
values={{operatingsystem: this.state.OS}}
/>
</p>
)}
{isFromGooglePlay(this.state.OS) && (
<p>
<FormattedMessage
id="download.howConnectHardwareDevicesAnswerApp"
values={{operatingsystem: this.state.OS}}
/>
</p>
)}
<h3 className="faq-question">
<FormattedMessage
id="download.canIShareApp"
values={{operatingsystem: this.state.OS}}
/>
</h3>
{isDownloaded(this.state.OS) && (
<p>
<FormattedMessage
id="download.canIShareAnswerDownloaded"
values={{operatingsystem: this.state.OS}}
/>
</p>
2019-10-02 18:57:06 -04:00
)}
{isFromGooglePlay(this.state.OS) && (
<p>
<FormattedMessage id="download.canIShareAnswerPlayStore" />
</p>
)}
2019-10-02 18:57:06 -04:00
<h3 className="faq-question">
<FormattedMessage id="download.appAndBrowser" />
2019-10-02 18:57:06 -04:00
</h3>
<p>
<FormattedMessage id="download.yesAnswer" />
</p>
<h3 className="faq-question">
<FormattedMessage id="download.onPhone" />
</h3>
<p>
<FormattedMessage id="download.onPhoneAnswer" />
</p>
<h3 className="faq-question">
<FormattedMessage id="download.howUpdateApp" />
</h3>
{isDownloaded(this.state.OS) && (
<p>
<FormattedMessage
id="download.howUpdateAppAnswerDownload"
values={{operatingsystem: this.state.OS}}
/>
</p>
)}
{isFromGooglePlay(this.state.OS) && (
<p>
<FormattedMessage
id="download.howUpdateAppAnswerApp"
/>
</p>
)}
<h3 className="faq-question">
<FormattedMessage id="download.whenSupportLinuxApp" />
</h3>
<p>
<FormattedMessage id="download.whenSupportLinuxAppAnswer" />
</p>
{isFromGooglePlay(this.state.OS) && (
<React.Fragment>
<h3 className="faq-question">
<FormattedMessage id="download.whyNoDevicesVisible" />
</h3>
<p>
<FormattedMessage
id="download.whyNoDevicesVisibleAnswer"
values={{
devicePosessive: (
this.state.OS === OS_ENUM.ANDROID ?
<FormattedMessage id="download.androidPossessive" /> :
<FormattedMessage id="download.chromebookPossessive" />
),
whyNoDevicesContactUsLink: (
<a href="//scratch.mit.edu/contact-us/">
<FormattedMessage id="download.whyNoDevicesContactUsLink" />
</a>
)
}}
/>
</p>
</React.Fragment>
)}
{isFromGooglePlay(this.state.OS) && (
<React.Fragment>
<h3 className="faq-question">
<FormattedMessage
id="download.whyAskForLocation"
values={{operatingsystem: this.state.OS}}
/>
</h3>
<p>
<FormattedMessage id="download.whyAskForLocationAnswer" />
</p>
</React.Fragment>
)}
{isFromGooglePlay(this.state.OS) && (
<React.Fragment>
<h3 className="faq-question">
<FormattedMessage
id="download.whereProjectStored"
values={{operatingsystem: this.state.OS}}
/>
</h3>
<p>
<FormattedMessage id="download.whereProjectStoredAnswer" />
</p>
</React.Fragment>
)}
2018-12-10 17:33:22 -05:00
</FlexRow>
2017-04-01 10:55:47 -04:00
</div>
2017-04-01 10:55:47 -04:00
</div>
);
2018-12-10 17:33:22 -05:00
2017-04-01 10:55:47 -04:00
}
}
Download.propTypes = {
intl: intlShape
2018-12-10 17:33:22 -05:00
};
const WrappedDownload = injectIntl(Download);
2017-04-01 10:55:47 -04:00
render(<Page><WrappedDownload /></Page>, document.getElementById('app'));