Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the branching share page checkbox. #24980

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions extensions/amp-story/1.0/amp-story-share.css
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,3 @@
font-size: 11px !important;
text-align: center !important;
}

.i-amphtml-story-page-share {
display: flex !important;
margin: 0 24px 12px !important;
align-items: center !important;
}

.i-amphtml-story-page-share-input {
height: 18px !important;
width: 18px !important;
margin: 0 !important;
}

.i-amphtml-story-page-share-label {
color: rgba(0, 0, 0, 0.87) !important;
margin-left: 8px !important;
font-family: 'Roboto', regular !important;
font-size: 13px !important;
}
65 changes: 3 additions & 62 deletions extensions/amp-story/1.0/amp-story-share.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
import {LocalizedStringId} from '../../../src/localized-strings';
import {Services} from '../../../src/services';
import {StateProperty, getStoreService} from './amp-story-store-service';
import {Toast} from './toast';
import {
copyTextToClipboard,
Expand All @@ -24,7 +23,6 @@ import {
import {dev, devAssert, user} from '../../../src/log';
import {dict, map} from './../../../src/utils/object';
import {getRequestService} from './amp-story-request-service';
import {isExperimentOn} from '../../../src/experiments';
import {isObject} from '../../../src/types';
import {listen} from '../../../src/event-helper';
import {px, setImportantStyles} from '../../../src/style';
Expand Down Expand Up @@ -93,32 +91,6 @@ const TEMPLATE = {
],
};

/** @private @const {!./simple-template.ElementDef} */
const SHARE_PAGE_TEMPLATE = {
tag: 'div',
attrs: dict({
'class': 'i-amphtml-story-page-share',
}),
children: [
{
tag: 'input',
attrs: dict({
'class': 'i-amphtml-story-page-share-input',
'type': 'checkbox',
'id': 'page-share',
}),
},
{
tag: 'label',
attrs: dict({
'class': 'i-amphtml-story-page-share-label',
'for': 'page-share',
}),
localizedStringId: LocalizedStringId.AMP_STORY_SHARING_PAGE_LABEL,
},
],
};

/** @private @const {!./simple-template.ElementDef} */
const SHARE_ITEM_TEMPLATE = {
tag: 'li',
Expand Down Expand Up @@ -253,9 +225,6 @@ export class ShareWidget {

/** @private @const {!./amp-story-request-service.AmpStoryRequestService} */
this.requestService_ = getRequestService(this.win, storyEl);

/** @private @const {!./amp-story-store-service.AmpStoryStoreService} */
this.storeService_ = getStoreService(this.win);
}

/**
Expand Down Expand Up @@ -284,7 +253,6 @@ export class ShareWidget {
this.loadProviders();
this.maybeAddLinkShareButton_();
this.maybeAddSystemShareButton_();
this.maybeAddPageShareButton_();

return this.root;
}
Expand Down Expand Up @@ -312,42 +280,15 @@ export class ShareWidget {

listen(linkShareButton, 'click', e => {
e.preventDefault();
let shareFromCurrentPage = false;
if (isExperimentOn(this.win, 'amp-story-branching')) {
shareFromCurrentPage = this.root.querySelector('#page-share').checked;
}
this.copyUrlToClipboard_(shareFromCurrentPage);
this.copyUrlToClipboard_();
});
}

/**
* On desktop mode, with branching, users should be able to share a story
* starting from a specific page.
* @private
*/
maybeAddPageShareButton_() {
if (isExperimentOn(this.win, 'amp-story-branching')) {
const list = devAssert(this.root).firstChild;
const sharePageCheck = renderAsElement(
this.win.document,
SHARE_PAGE_TEMPLATE
);
this.root.insertBefore(sharePageCheck, list);
}
}

/**
* @param {boolean} shareFromCurrentPage
* @private
*/
copyUrlToClipboard_(shareFromCurrentPage) {
const currentPageId = this.storeService_.get(StateProperty.CURRENT_PAGE_ID);
const shouldAddFragment =
isExperimentOn(this.win, 'amp-story-branching') && shareFromCurrentPage;

const url =
Services.documentInfoForDoc(this.getAmpDoc_()).canonicalUrl +
(shouldAddFragment ? '#page=' + currentPageId : '');
copyUrlToClipboard_() {
const url = Services.documentInfoForDoc(this.getAmpDoc_()).canonicalUrl;

if (!copyTextToClipboard(this.win, url)) {
this.localizationServicePromise_.then(localizationService => {
Expand Down