Skip to content

Commit e35dad3

Browse files
authored
Merge pull request #241 from smalruby/merge/scratch-gui
Merge/scratch gui
2 parents 7fd1a2d + 12ae159 commit e35dad3

22 files changed

+3846
-1303
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*.svg binary
1313

1414
# Prefer LF for most file types
15+
*.css text eol=lf
1516
*.frag text eol=lf
1617
*.htm text eol=lf
1718
*.html text eol=lf

package-lock.json

Lines changed: 1617 additions & 1165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@
114114
"redux-throttle": "0.1.1",
115115
"rimraf": "^2.6.1",
116116
"scratch-audio": "0.1.0-prerelease.20190925183642",
117-
"scratch-blocks": "0.1.0-prerelease.1583243431",
118-
"scratch-l10n": "3.7.20200303213115",
119-
"scratch-paint": "0.2.0-prerelease.20200213174123",
120-
"scratch-render": "0.1.0-prerelease.20200228152431",
121-
"scratch-storage": "1.3.2",
122-
"scratch-svg-renderer": "0.2.0-prerelease.20200205003400",
117+
"scratch-blocks": "0.1.0-prerelease.20200520151625",
118+
"scratch-l10n": "3.9.20200519213537",
119+
"scratch-paint": "0.2.0-prerelease.20200519194740",
120+
"scratch-render": "0.1.0-prerelease.20200512203149",
121+
"scratch-storage": "1.3.3",
122+
"scratch-svg-renderer": "0.2.0-prerelease.20200507183648",
123123
"selenium-webdriver": "3.6.0",
124124
"shelljs": "^0.8.3",
125125
"startaudiocontext": "1.2.1",
@@ -146,7 +146,8 @@
146146
],
147147
"moduleNameMapper": {
148148
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/__mocks__/fileMock.js",
149-
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js"
149+
"\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js",
150+
"editor-msgs(\\.js)?$": "<rootDir>/test/__mocks__/editor-msgs-mock.js"
150151
}
151152
},
152153
"dependencies": {

src/components/gui/gui.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const GUIComponent = props => {
9191
loading,
9292
logo,
9393
renderLogin,
94+
onClickAbout,
9495
onClickAccountNav,
9596
onCloseAccountNav,
9697
onLogOut,
@@ -108,6 +109,7 @@ const GUIComponent = props => {
108109
onRequestCloseTelemetryModal,
109110
onSeeCommunity,
110111
onShare,
112+
onShowPrivacyPolicy,
111113
onTelemetryModalCancel,
112114
onTelemetryModalOptIn,
113115
onTelemetryModalOptOut,
@@ -166,6 +168,7 @@ const GUIComponent = props => {
166168
onOptIn={onTelemetryModalOptIn}
167169
onOptOut={onTelemetryModalOptOut}
168170
onRequestClose={onRequestCloseTelemetryModal}
171+
onShowPrivacyPolicy={onShowPrivacyPolicy}
169172
/>
170173
) : null}
171174
{loading ? (
@@ -222,6 +225,7 @@ const GUIComponent = props => {
222225
logo={logo}
223226
renderLogin={renderLogin}
224227
showComingSoon={showComingSoon}
228+
onClickAbout={onClickAbout}
225229
onClickAccountNav={onClickAccountNav}
226230
onClickLogo={onClickLogo}
227231
onCloseAccountNav={onCloseAccountNav}
@@ -413,6 +417,7 @@ GUIComponent.propTypes = {
413417
onActivateRubyTab: PropTypes.func,
414418
onActivateSoundsTab: PropTypes.func,
415419
onActivateTab: PropTypes.func,
420+
onClickAbout: PropTypes.func,
416421
onClickAccountNav: PropTypes.func,
417422
onClickLogo: PropTypes.func,
418423
onCloseAccountNav: PropTypes.func,
@@ -424,6 +429,7 @@ GUIComponent.propTypes = {
424429
onRequestCloseTelemetryModal: PropTypes.func,
425430
onSeeCommunity: PropTypes.func,
426431
onShare: PropTypes.func,
432+
onShowPrivacyPolicy: PropTypes.func,
427433
onTabSelect: PropTypes.func,
428434
onTelemetryModalCancel: PropTypes.func,
429435
onTelemetryModalOptIn: PropTypes.func,
Lines changed: 1 addition & 0 deletions
Loading

src/components/menu-bar/menu-bar.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,9 @@
218218
.mystuff > a {
219219
background-image: url("/images/mystuff.png");
220220
}
221+
222+
.about-icon {
223+
height: 1.25rem;
224+
margin: 0.5rem;
225+
vertical-align: middle;
226+
}

src/components/menu-bar/menu-bar.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import profileIcon from './profile-hatti.png';
6969
import remixIcon from './icon--remix.svg';
7070
import dropdownCaret from './dropdown-caret.svg';
7171
import languageIcon from '../language-selector/language-icon.svg';
72+
import aboutIcon from './icon--about.svg';
7273

7374
import smalrubyLogo from './hatti.svg';
7475

@@ -143,6 +144,19 @@ MenuItemTooltip.propTypes = {
143144
isRtl: PropTypes.bool
144145
};
145146

147+
const AboutButton = props => (
148+
<Button
149+
className={classNames(styles.menuBarItem, styles.hoverable)}
150+
iconClassName={styles.aboutIcon}
151+
iconSrc={aboutIcon}
152+
onClick={props.onClick}
153+
/>
154+
);
155+
156+
AboutButton.propTypes = {
157+
onClick: PropTypes.func.isRequired
158+
};
159+
146160
class MenuBar extends React.Component {
147161
constructor (props) {
148162
super(props);
@@ -335,6 +349,8 @@ class MenuBar extends React.Component {
335349
{remixMessage}
336350
</Button>
337351
);
352+
// Show the About button only if we have a handler for it (like in the desktop app)
353+
const aboutButton = this.props.onClickAbout ? <AboutButton onClick={this.props.onClickAbout} /> : null;
338354
return (
339355
<Box
340356
className={classNames(
@@ -721,6 +737,8 @@ class MenuBar extends React.Component {
721737
</React.Fragment>
722738
)}
723739
</div>
740+
741+
{aboutButton}
724742
</Box>
725743
);
726744
}
@@ -754,6 +772,7 @@ MenuBar.propTypes = {
754772
locale: PropTypes.string.isRequired,
755773
loginMenuOpen: PropTypes.bool,
756774
logo: PropTypes.string,
775+
onClickAbout: PropTypes.func,
757776
onClickAccount: PropTypes.func,
758777
onClickEdit: PropTypes.func,
759778
onClickFile: PropTypes.func,

src/components/stage/stage.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666

6767
overflow: hidden;
6868
display: flex;
69-
align-items: center;
7069
justify-content: center;
7170
}
7271

src/components/telemetry-modal/telemetry-modal.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ class TelemetryModal extends React.PureComponent {
9191
<p><FormattedMessage {...messages.bodyText1} /></p>
9292
<p><FormattedMessage
9393
{...messages.bodyText2}
94+
values={{
95+
privacyPolicyLink: (<a
96+
className={styles.privacyPolicyLink}
97+
href="https://scratch.mit.edu/privacy_policy/"
98+
onClick={this.props.onShowPrivacyPolicy}
99+
target="_blank"
100+
rel="noopener noreferrer"
101+
>
102+
<FormattedMessage {...messages.privacyPolicyLink} />
103+
</a>)
104+
}}
94105
/></p>
95106
<Box className={styles.buttonRow}>
96107
<button
@@ -120,7 +131,8 @@ TelemetryModal.propTypes = {
120131
onCancel: PropTypes.func,
121132
onOptIn: PropTypes.func.isRequired,
122133
onOptOut: PropTypes.func.isRequired,
123-
onRequestClose: PropTypes.func
134+
onRequestClose: PropTypes.func,
135+
onShowPrivacyPolicy: PropTypes.func
124136
};
125137

126138
export default injectIntl(TelemetryModal);

src/lib/download-blob.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,23 @@ export default (filename, blob) => {
88
return;
99
}
1010

11-
const url = window.URL.createObjectURL(blob);
12-
downloadLink.href = url;
13-
downloadLink.download = filename;
14-
downloadLink.type = blob.type;
15-
downloadLink.click();
16-
window.URL.revokeObjectURL(url);
17-
document.body.removeChild(downloadLink);
11+
if ('download' in HTMLAnchorElement.prototype) {
12+
const url = window.URL.createObjectURL(blob);
13+
downloadLink.href = url;
14+
downloadLink.download = filename;
15+
downloadLink.type = blob.type;
16+
downloadLink.click();
17+
document.body.removeChild(downloadLink);
18+
window.URL.revokeObjectURL(url);
19+
} else {
20+
// iOS Safari, open a new page and set href to data-uri
21+
let popup = window.open('', '_blank');
22+
const reader = new FileReader();
23+
reader.onloadend = function () {
24+
popup.location.href = reader.result;
25+
popup = null;
26+
};
27+
reader.readAsDataURL(blob);
28+
}
29+
1830
};

0 commit comments

Comments
 (0)