Skip to content

Commit aeec589

Browse files
committed
cloud variable notice
1 parent d10fc6c commit aeec589

File tree

2 files changed

+65
-4
lines changed

2 files changed

+65
-4
lines changed

src/components/stage/stage.css

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ stage doesn't "spill" out from under its rounded corners. instead, shift these o
132132
pointer-events: all;
133133
cursor: pointer;
134134
}
135-
136135
.green-flag-overlay {
137136
padding: 1rem;
138137
border-radius: 100%;
@@ -146,6 +145,35 @@ stage doesn't "spill" out from under its rounded corners. instead, shift these o
146145
height: 5rem;
147146
}
148147

148+
.green-flag-overlay-with-warning {
149+
display: flex;
150+
flex-direction: column;
151+
height: 100%;
152+
}
153+
154+
.cloud-warning-content {
155+
display: flex;
156+
flex-direction: column;
157+
gap: 0.5rem;
158+
color: $text-primary-default;
159+
160+
position: absolute;
161+
top: 0px;
162+
padding: 20px;
163+
background-color: $ui-white-default;
164+
margin: 20px;
165+
border-radius: 0.5rem;
166+
}
167+
168+
.cloud-warning-text {
169+
font-size: 0.85rem;
170+
font-weight: normal;
171+
}
172+
.cloud-warning-text .cloud-warning-text-red{
173+
color: $looks-secondary;
174+
font-weight: bold;
175+
}
176+
149177
.green-flag-overlay > img {
150178
width: 100%;
151179
object-fit: contain;

src/containers/green-flag-overlay.jsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import bindAll from 'lodash.bindall';
22
import React from 'react';
33
import PropTypes from 'prop-types';
4+
import classNames from 'classnames';
45

56
import {connect} from 'react-redux';
67
import VM from 'scratch-vm';
78
import Box from '../components/box/box.jsx';
89
import greenFlag from '../components/green-flag/icon--green-flag.svg';
910
import {setStartedState} from '../reducers/vm-status.js';
11+
import {FormattedMessage} from 'react-intl';
12+
13+
import styles from '../components/stage/stage.css';
1014

1115
class GreenFlagOverlay extends React.Component {
1216
constructor (props) {
@@ -27,11 +31,36 @@ class GreenFlagOverlay extends React.Component {
2731
}
2832

2933
render () {
34+
// Check if project has cloud vars and user is generic 'player' or empty string (not logged in)
35+
const isGuest = !this.props.username || this.props.username === 'player';
36+
const showCloudWarning = this.props.hasCloudVariables && isGuest;
37+
3038
return (
3139
<Box
32-
className={this.props.wrapperClass}
40+
className={classNames(
41+
this.props.wrapperClass,
42+
{[styles.greenFlagOverlayWithWarning]: showCloudWarning}
43+
)}
3344
onClick={this.handleClick}
3445
>
46+
{showCloudWarning && (
47+
<div className={styles.cloudWarningContent}>
48+
<div className={styles.cloudWarningText}>
49+
<span className={styles.cloudWarningTextRed}>
50+
<FormattedMessage
51+
defaultMessage="Multiplayer Features: "
52+
id="gui.greenFlagOverlay.cloudTitle"
53+
/>
54+
</span>
55+
<span>
56+
<FormattedMessage
57+
defaultMessage="This project uses cloud variables. To play online or interact with others, you must log in."
58+
id="gui.greenFlagOverlay.cloudWarning"
59+
/>
60+
</span>
61+
</div>
62+
</div>
63+
)}
3564
<div className={this.props.className}>
3665
<img
3766
draggable={false}
@@ -48,11 +77,15 @@ GreenFlagOverlay.propTypes = {
4877
className: PropTypes.string,
4978
vm: PropTypes.instanceOf(VM),
5079
wrapperClass: PropTypes.string,
51-
onStarted: PropTypes.func
80+
onStarted: PropTypes.func,
81+
hasCloudVariables: PropTypes.bool,
82+
username: PropTypes.string
5283
};
5384

5485
const mapStateToProps = state => ({
55-
vm: state.scratchGui.vm
86+
vm: state.scratchGui.vm,
87+
hasCloudVariables: state.scratchGui.tw.hasCloudVariables,
88+
username: state.scratchGui.tw.username
5689
});
5790

5891
const mapDispatchToProps = dispatch => ({

0 commit comments

Comments
 (0)