diff --git a/src/components/modal/social/container.jsx b/src/components/modal/social/container.jsx
index 3125bf513..767415a7e 100644
--- a/src/components/modal/social/container.jsx
+++ b/src/components/modal/social/container.jsx
@@ -11,6 +11,7 @@ class SocialModal extends React.Component {
this.embedTextarea = {};
this.embedCopyTimeoutId = null;
this.linkCopyTimeoutId = null;
+ this.linkTextarea = {};
this.showCopyResultTimeout = 2000;
this.state = {
showEmbedResult: false,
@@ -21,11 +22,14 @@ class SocialModal extends React.Component {
'handleCopyProjectLink',
'hideEmbedResult',
'hideLinkResult',
- 'setEmbedTextarea'
+ 'linkUrl',
+ 'setEmbedTextarea',
+ 'setLinkTextarea'
]);
}
componentWillUnmount () {
this.clearEmbedCopyResultTimeout();
+ this.clearLinkCopyResultTimeout();
}
handleCopyEmbed () {
if (this.embedTextarea) {
@@ -42,14 +46,17 @@ class SocialModal extends React.Component {
}
}
handleCopyProjectLink () {
- this.props.onCopyProjectLink();
- if (this.state.showLinkResult === false && this.linkCopyTimeoutId === null) {
- this.setState({showLinkResult: true}, () => {
- this.linkCopyTimeoutId = setTimeout(
- this.hideLinkResult,
- this.showCopyResultTimeout
- );
- });
+ if (this.linkTextarea) {
+ this.linkTextarea.select();
+ clipboardCopy(this.linkTextarea.value);
+ if (this.state.showLinkResult === false && this.linkCopyTimeoutId === null) {
+ this.setState({showLinkResult: true}, () => {
+ this.linkCopyTimeoutId = setTimeout(
+ this.hideLinkResult,
+ this.showCopyResultTimeout
+ );
+ });
+ }
}
}
hideEmbedResult () {
@@ -60,16 +67,29 @@ class SocialModal extends React.Component {
this.setState({showLinkResult: false});
this.linkCopyTimeoutId = null;
}
+ linkUrl () {
+ return `${window.location.origin}${window.location.pathname}`;
+ }
setEmbedTextarea (textarea) {
this.embedTextarea = textarea;
return textarea;
}
+ setLinkTextarea (textarea) {
+ this.linkTextarea = textarea;
+ return textarea;
+ }
clearEmbedCopyResultTimeout () {
if (this.embedCopyTimeoutId !== null) {
clearTimeout(this.embedCopyTimeoutId);
this.embedCopyTimeoutId = null;
}
}
+ clearLinkCopyResultTimeout () {
+ if (this.linkCopyTimeoutId !== null) {
+ clearTimeout(this.linkCopyTimeoutId);
+ this.linkCopyTimeoutId = null;
+ }
+ }
render () {
const projectId = this.props.projectId;
return (
@@ -78,7 +98,9 @@ class SocialModal extends React.Component {
fbUrl={social.facebookIntentLink(projectId)}
googleClassroomUrl={social.googleClassroomIntentLink(projectId)}
isOpen={this.props.isOpen}
+ linkUrl={this.linkUrl()}
setEmbedTextarea={this.setEmbedTextarea}
+ setLinkTextarea={this.setLinkTextarea}
showEmbedResult={this.state.showEmbedResult}
showLinkResult={this.state.showLinkResult}
twitterUrl={social.twitterIntentLink(projectId)}
@@ -93,7 +115,6 @@ class SocialModal extends React.Component {
SocialModal.propTypes = {
isOpen: PropTypes.bool,
- onCopyProjectLink: PropTypes.func,
onRequestClose: PropTypes.func,
projectId: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
};
diff --git a/src/components/modal/social/modal.scss b/src/components/modal/social/modal.scss
index bc03a61da..ec1ce57ed 100644
--- a/src/components/modal/social/modal.scss
+++ b/src/components/modal/social/modal.scss
@@ -30,28 +30,39 @@
}
.social-spaced-row {
- width: 100%;
+ // width: 100%;
justify-content: space-between;
- align-items: start;
+ align-items: flex-end;
+}
+
+.social-row-right {
+ margin-left: auto;
}
.social-label-row {
+ width: 100%;
font-weight: bold;
margin-bottom: .5rem;
- justify-content: start;
- align-items: start;
+ justify-content: space-between;
+ align-items: flex-end;
}
-.social-label {
+.social-label-title {
+ font-size: 1rem;
margin-right: 1.5rem;
}
+.social-label-item {
+ margin-left: 1.5rem;
+ margin-right: .25rem;
+}
+
.social-label-result {
color: $type-gray-75percent;
transition: opacity 100ms linear;
}
-.embed-section {
+.embed-section, .link-section {
margin-top: 2rem;
}
@@ -115,7 +126,7 @@
// NOTE: copied from inplace-input.scss. We should refactor to put this style in
// only one place.
-.social-embed-textarea {
+.social-embed-textarea, .social-link-textarea {
transition: all .2s ease;
border: 2px dashed $ui-blue-25percent;
border-radius: 8px;
@@ -128,6 +139,13 @@
resize: none;
overflow: hidden;
+ width: 100%;
+ height: 6rem;
+
+ textarea {
+ min-height: 4rem;
+ }
+
&:focus {
transition: all .2s ease;
outline: none;
@@ -136,15 +154,6 @@
}
}
-.social-embed-textarea {
- width: 100%;
- height: 6rem;
-
- textarea {
- min-height: 4rem;
- }
-}
-
// NOTE: should probably be put in a shared css location
.social-hidden {
opacity: 0.0;
diff --git a/src/components/modal/social/presentation.jsx b/src/components/modal/social/presentation.jsx
index e327fd6b8..1595a1b3d 100644
--- a/src/components/modal/social/presentation.jsx
+++ b/src/components/modal/social/presentation.jsx
@@ -14,18 +14,17 @@ require('./modal.scss');
const SocialModalPresentation = ({
embedHtml,
- fbUrl,
- googleClassroomUrl,
intl,
isOpen,
+ linkUrl,
+ onClickEmbedText,
onCopyEmbed,
onCopyProjectLink,
onRequestClose,
setEmbedTextarea,
+ setLinkTextarea,
showEmbedResult,
- showLinkResult,
- twitterUrl,
- weChatUrl
+ showLinkResult
}) => {
const title = intl.formatMessage({id: 'social.title'});
@@ -44,117 +43,68 @@ const SocialModalPresentation = ({
- {/* top row: social links and copy link button */}
-
-
- {/* social links */}
-
+ {/* top row: link */}
+
+
- {intl.formatMessage({id: 'social.socialMediaLabel'})}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/* copy link button */}
-
-
-
+
{intl.formatMessage({id: 'social.linkLabel'})}
-
- {intl.formatMessage({id: 'social.embedCopiedResultText'})}
-
+
+
+ {intl.formatMessage({id: 'social.embedCopiedResultText'})}
+
+
+
-
-
-
-
-
-
+
{/* bottom row: embed */}
-
+
{intl.formatMessage({id: 'social.embedHtmlLabel'})}
-
+
+
@@ -174,18 +124,17 @@ const SocialModalPresentation = ({
SocialModalPresentation.propTypes = {
embedHtml: PropTypes.string,
- fbUrl: PropTypes.string,
- googleClassroomUrl: PropTypes.string,
intl: intlShape,
isOpen: PropTypes.bool,
+ linkUrl: PropTypes.string,
+ onClickEmbedText: PropTypes.func,
onCopyEmbed: PropTypes.func,
onCopyProjectLink: PropTypes.func,
onRequestClose: PropTypes.func,
setEmbedTextarea: PropTypes.func,
+ setLinkTextarea: PropTypes.func,
showEmbedResult: PropTypes.bool,
- showLinkResult: PropTypes.bool,
- twitterUrl: PropTypes.string,
- weChatUrl: PropTypes.string
+ showLinkResult: PropTypes.bool
};
module.exports = injectIntl(SocialModalPresentation);
diff --git a/src/l10n.json b/src/l10n.json
index 8d085798f..710f984c7 100644
--- a/src/l10n.json
+++ b/src/l10n.json
@@ -258,7 +258,7 @@
"comments.status.deleted": "Deleted",
"comments.status.reported": "Reported",
- "social.title": "Social",
+ "social.title": "Embed",
"social.embedHtmlLabel": "Embed",
"social.copyEmbedLinkText": "Copy embed",
"social.linkLabel": "Link",
diff --git a/src/lib/social.js b/src/lib/social.js
index cb4d4f0f9..a23da86ba 100644
--- a/src/lib/social.js
+++ b/src/lib/social.js
@@ -2,7 +2,7 @@ module.exports = {};
module.exports.embedHtml = projectId => {
if (projectId) {
- return `';
}
diff --git a/src/views/preview/presentation.jsx b/src/views/preview/presentation.jsx
index 20ca303d7..0e764a868 100644
--- a/src/views/preview/presentation.jsx
+++ b/src/views/preview/presentation.jsx
@@ -88,7 +88,6 @@ const PreviewPresentation = ({
onAddToStudioClicked,
onAddToStudioClosed,
onCloseAdminPanel,
- onCopyProjectLink,
onDeleteComment,
onFavoriteClicked,
onGreenFlag,
@@ -375,7 +374,6 @@ const PreviewPresentation = ({
userOwnsProject={userOwnsProject}
onAddToStudioClicked={onAddToStudioClicked}
onAddToStudioClosed={onAddToStudioClosed}
- onCopyProjectLink={onCopyProjectLink}
onReportClicked={onReportClicked}
onReportClose={onReportClose}
onReportSubmit={onReportSubmit}
@@ -524,7 +522,6 @@ const PreviewPresentation = ({
userOwnsProject={userOwnsProject}
onAddToStudioClicked={onAddToStudioClicked}
onAddToStudioClosed={onAddToStudioClosed}
- onCopyProjectLink={onCopyProjectLink}
onReportClicked={onReportClicked}
onReportClose={onReportClose}
onReportSubmit={onReportSubmit}
@@ -702,7 +699,6 @@ PreviewPresentation.propTypes = {
onAddToStudioClicked: PropTypes.func,
onAddToStudioClosed: PropTypes.func,
onCloseAdminPanel: PropTypes.func,
- onCopyProjectLink: PropTypes.func,
onDeleteComment: PropTypes.func,
onFavoriteClicked: PropTypes.func,
onGreenFlag: PropTypes.func,
diff --git a/src/views/preview/project-view.jsx b/src/views/preview/project-view.jsx
index 4cfb2d3ac..5b943d3c6 100644
--- a/src/views/preview/project-view.jsx
+++ b/src/views/preview/project-view.jsx
@@ -8,7 +8,6 @@ const PropTypes = require('prop-types');
const connect = require('react-redux').connect;
const injectIntl = require('react-intl').injectIntl;
const parser = require('scratch-parser');
-const copy = require('clipboard-copy');
const Page = require('../../components/page/www/page.jsx');
const storage = require('../../lib/storage.js').default;
@@ -55,7 +54,6 @@ class Preview extends React.Component {
'fetchCommunityData',
'handleAddComment',
'handleClickLogo',
- 'handleCopyProjectLink',
'handleDeleteComment',
'handleSocialClick',
'handleSocialClose',
@@ -582,11 +580,6 @@ class Preview extends React.Component {
this.props.user.token
);
}
- handleCopyProjectLink () {
- // Use the pathname so we do not have to update this if path changes
- // Also do not include hash or query params
- copy(`${window.location.origin}${window.location.pathname}`);
- }
handleSocialClick () {
this.setState({socialOpen: true});
}
@@ -694,7 +687,6 @@ class Preview extends React.Component {
onAddToStudioClicked={this.handleAddToStudioClick}
onAddToStudioClosed={this.handleAddToStudioClose}
onCloseAdminPanel={this.handleCloseAdminPanel}
- onCopyProjectLink={this.handleCopyProjectLink}
onDeleteComment={this.handleDeleteComment}
onFavoriteClicked={this.handleFavoriteToggle}
onGreenFlag={this.handleGreenFlag}
diff --git a/src/views/preview/subactions.jsx b/src/views/preview/subactions.jsx
index 373f8cef9..f834e5798 100644
--- a/src/views/preview/subactions.jsx
+++ b/src/views/preview/subactions.jsx
@@ -61,7 +61,6 @@ const Subactions = props => (
isOpen
key="social-modal"
projectId={props.projectInfo && props.projectInfo.id}
- onCopyProjectLink={props.onCopyProjectLink}
onRequestClose={props.onSocialClosed}
/>
)}
diff --git a/src/views/preview/subactions.scss b/src/views/preview/subactions.scss
index 8d478c3d8..05837a75c 100644
--- a/src/views/preview/subactions.scss
+++ b/src/views/preview/subactions.scss
@@ -61,7 +61,8 @@
}
&.studio-button,
&.copy-link-button,
- &.report-button {
+ &.report-button,
+ &.social-button {
&:before {
display: inline-block;
margin-right: .25rem;
@@ -89,7 +90,7 @@
&.social-button {
&:before {
- background-image: url("/svgs/project/copy-link-white.svg");
+ background-image: url("/svgs/project/embed-icon.svg");
}
}
diff --git a/static/svgs/project/embed-icon.svg b/static/svgs/project/embed-icon.svg
new file mode 100644
index 000000000..6eeb28a56
--- /dev/null
+++ b/static/svgs/project/embed-icon.svg
@@ -0,0 +1 @@
+
\ No newline at end of file