added congratulations on sharing message for new scratchers

This commit is contained in:
Ben Wheeler 2018-11-23 01:04:11 -05:00
parent f6d54e25b9
commit 8d74726080
5 changed files with 27 additions and 1 deletions

View file

@ -10,6 +10,7 @@ $ui-orange-25percent: hsla(35, 90, 55, .25);
$ui-red: hsla(20, 100%, 55%, 1); /* #FF661A */ $ui-red: hsla(20, 100%, 55%, 1); /* #FF661A */
$ui-red-25percent: hsla(20, 100%, 55%, .25); $ui-red-25percent: hsla(20, 100%, 55%, .25);
$ui-green-35percent: rgba(126, 225, 195, 0.35);
$ui-light-gray: hsla(0, 0, 98, 1); //#FAFAFA $ui-light-gray: hsla(0, 0, 98, 1); //#FAFAFA
$ui-gray: hsla(0, 0, 95, 1); //#F2F2F2 $ui-gray: hsla(0, 0, 95, 1); //#F2F2F2

View file

@ -3,11 +3,15 @@
$navigation-height: 50px; $navigation-height: 50px;
.banner-outer { .banner-outer {
display: flex;
background-color: $ui-orange-25percent; background-color: $ui-orange-25percent;
width: 100%; width: 100%;
min-height: 3.75rem;
overflow: hidden; overflow: hidden;
color: $ui-orange; color: $ui-orange;
font-weight: bold; font-weight: bold;
font-size: .875rem;
align-self: center;
} }
.banner-outer.banner-danger { .banner-outer.banner-danger {
@ -15,8 +19,12 @@ $navigation-height: 50px;
color: $ui-red; color: $ui-red;
} }
.banner-outer.banner-success {
background-color: $ui-green-35percent;
color: $ui-mint-green;
}
.banner-inner { .banner-inner {
min-height: 60px;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
flex-wrap: nowrap; flex-wrap: nowrap;

View file

@ -13,6 +13,7 @@
"project.comments.turnOff": "Turn off commenting", "project.comments.turnOff": "Turn off commenting",
"project.comments.turnedOff": "Sorry, comment posting has been turned off for this project.", "project.comments.turnedOff": "Sorry, comment posting has been turned off for this project.",
"project.share.notShared": "This project is not shared — so only you can see it. Click share to let everyone see it!", "project.share.notShared": "This project is not shared — so only you can see it. Click share to let everyone see it!",
"project.share.shared": "Congratulations on sharing your project! Other people can now try it out, give comments, and remix it.",
"project.share.shareButton": "Share", "project.share.shareButton": "Share",
"project.seeInsideButton": "See inside", "project.seeInsideButton": "See inside",
"project.remixButton": "Remix", "project.remixButton": "Remix",

View file

@ -64,6 +64,7 @@ const PreviewPresentation = ({
intl, intl,
isFullScreen, isFullScreen,
isLoggedIn, isLoggedIn,
isNewScratcher,
isShared, isShared,
loveCount, loveCount,
loved, loved,
@ -139,6 +140,11 @@ const PreviewPresentation = ({
message={<FormattedMessage id="project.share.notShared" />} message={<FormattedMessage id="project.share.notShared" />}
onAction={onShare} onAction={onShare}
/>); />);
} else if (isShared && isNewScratcher) {
banner = (<Banner
className="banner-success"
message={<FormattedMessage id="project.share.shared" />}
/>);
} }
return ( return (
@ -531,6 +537,7 @@ PreviewPresentation.propTypes = {
intl: intlShape, intl: intlShape,
isFullScreen: PropTypes.bool, isFullScreen: PropTypes.bool,
isLoggedIn: PropTypes.bool, isLoggedIn: PropTypes.bool,
isNewScratcher: PropTypes.bool,
isShared: PropTypes.bool, isShared: PropTypes.bool,
loveCount: PropTypes.number, loveCount: PropTypes.number,
loved: PropTypes.bool, loved: PropTypes.bool,

View file

@ -81,6 +81,7 @@ class Preview extends React.Component {
addToStudioOpen: false, addToStudioOpen: false,
extensions: [], extensions: [],
favoriteCount: 0, favoriteCount: 0,
justShared: false,
loveCount: 0, loveCount: 0,
modInfo: { modInfo: {
scripts: 0, scripts: 0,
@ -101,9 +102,11 @@ class Preview extends React.Component {
(this.state.projectId !== prevState.projectId))) { (this.state.projectId !== prevState.projectId))) {
this.fetchCommunityData(); this.fetchCommunityData();
this.getProjectData(this.state.projectId); this.getProjectData(this.state.projectId);
this.setState({justShared: false}); // eslint-disable-line react/no-did-update-set-state
} }
if (this.state.projectId === '0' && this.state.projectId !== prevState.projectId) { if (this.state.projectId === '0' && this.state.projectId !== prevState.projectId) {
this.props.resetProject(); this.props.resetProject();
this.setState({justShared: false}); // eslint-disable-line react/no-did-update-set-state
} }
if (this.props.projectInfo.id !== prevProps.projectInfo.id) { if (this.props.projectInfo.id !== prevProps.projectInfo.id) {
if (typeof this.props.projectInfo.id === 'undefined') { if (typeof this.props.projectInfo.id === 'undefined') {
@ -357,12 +360,14 @@ class Preview extends React.Component {
} }
handleSeeInside () { handleSeeInside () {
this.props.setPlayer(false); this.props.setPlayer(false);
this.setState({justShared: false});
} }
handleShare () { handleShare () {
this.props.shareProject( this.props.shareProject(
this.props.projectInfo.id, this.props.projectInfo.id,
this.props.user.token this.props.user.token
); );
this.setState({justShared: true});
} }
handleUpdate (jsonData) { handleUpdate (jsonData) {
this.props.updateProject( this.props.updateProject(
@ -471,7 +476,9 @@ class Preview extends React.Component {
favoriteCount={this.state.favoriteCount} favoriteCount={this.state.favoriteCount}
isFullScreen={this.state.isFullScreen} isFullScreen={this.state.isFullScreen}
isLoggedIn={this.props.isLoggedIn} isLoggedIn={this.props.isLoggedIn}
isNewScratcher={this.props.isNewScratcher}
isShared={this.props.isShared} isShared={this.props.isShared}
justShared={this.state.justShared}
loveCount={this.state.loveCount} loveCount={this.state.loveCount}
loved={this.props.loved} loved={this.props.loved}
modInfo={this.state.modInfo} modInfo={this.state.modInfo}
@ -596,6 +603,7 @@ Preview.propTypes = {
isAdmin: PropTypes.bool, isAdmin: PropTypes.bool,
isEditable: PropTypes.bool, isEditable: PropTypes.bool,
isLoggedIn: PropTypes.bool, isLoggedIn: PropTypes.bool,
isNewScratcher: PropTypes.bool,
isShared: PropTypes.bool, isShared: PropTypes.bool,
loved: PropTypes.bool, loved: PropTypes.bool,
moreCommentsToLoad: PropTypes.bool, moreCommentsToLoad: PropTypes.bool,
@ -689,6 +697,7 @@ const mapStateToProps = state => {
state.permissions.admin === true), state.permissions.admin === true),
isLoggedIn: isLoggedIn, isLoggedIn: isLoggedIn,
isAdmin: isAdmin, isAdmin: isAdmin,
isNewScratcher: isLoggedIn && state.permissions.new_scratcher,
// if we don't have projectInfo, assume it's shared until we know otherwise // if we don't have projectInfo, assume it's shared until we know otherwise
isShared: !projectInfoPresent || state.preview.projectInfo.is_published, isShared: !projectInfoPresent || state.preview.projectInfo.is_published,
loved: state.preview.loved, loved: state.preview.loved,