Skip to content

Commit

Permalink
Remove the branching share page checkbox. (ampproject#24980)
Browse files Browse the repository at this point in the history
* Remove the branching share page checkbox.

* I will run gulp pr-check before pushing. I will run gulp pr-check before pushing. I will run gulp pr-check before pushing. I will run gulp pr-check before pushing. I will run gulp pr-check before pushing.
  • Loading branch information
gmajoulet authored and Micajuine Ho committed Dec 27, 2019
1 parent 52456a1 commit c583dae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 81 deletions.
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

0 comments on commit c583dae

Please sign in to comment.