Skip to content

Conversation

bramanudom
Copy link
Contributor

@bramanudom bramanudom commented Feb 11, 2019

#20083

In branching, users should also have the ability to share the story from the page they are currently seeing, if they so choose.

Until a better UX solution is found for sharing natively, the ability to share a specific page should exist via the web landscape UI only. When stories support landscape and branching is turned on, users will now have the option to click Share this page which will generate a url with a page URL fragment parameter (#20238).

screen shot 2019-02-11 at 4 41 57 pm

screen shot 2019-02-11 at 4 51 00 pm

{
tag: 'input',
attrs: dict(
{'class': 'i-amphtml-page-share-check',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: { on previous line for consistency

* starting from a specific page.
* @private */
maybeAddPageShareButton_() {
if (isExperimentOn(this.win, 'amp-story-branching') && this.isDesktopUi_) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of keeping track of this.isDesktopUi_, would it make sense to just directly call this.storeService_.get(StateProperty.UI_STATE) === UIType.DESKTOP_FULLBLEED here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, definitely. Made the change, and did the same with the currentPageId

.i-amphtml-page-share-check {
width: 12px !important;
height: 12px !important;
vertical-align: middle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!important?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const sharePageCheck =
renderAsElement(this.win.document, SHARE_PAGE_TEMPLATE);
sharePageCheck.querySelector(
'#page-share-span').innerHTML = 'Share this page';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be rendered with the simple templates stuff? We'll also want to localize it, so you can follow the instructions here, and pass your LocalizedStringId to the simple templates def, like we do here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@cvializ cvializ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!


const sharePageCheck =
renderAsElement(this.win.document, SHARE_PAGE_TEMPLATE);
// sharePageCheck.querySelector(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can this leftover commented code be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh oops. Removed.

}

/**
* @param {boolean} opt_sharePage
Copy link
Contributor

@cvializ cvializ Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: optional params are specified with an = suffix, e.g. {boolean=}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
copyUrlToClipboard_(opt_sharePage) {
const currentPageId = this.storeService_.get(StateProperty.CURRENT_PAGE_ID);
const url =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some duplication here. The difference is what's appended, so you can have that be the ternary value

const shouldAddFragment = 
    (isExperimentOn(this.win, 'amp-story-branching') && opt_sharePage)
const url = Services.documentInfoForDoc(this.getAmpDoc_()).canonicalUrl + 
    (shouldAddFragment ? '#page=' + currentPageId : '')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense and is much more readable. Thanks, Carlos!

@gmajoulet
Copy link
Contributor

One thing I'm a bit worried about with this feature is the UX we're offering. The sharing and the wording assumes that users know so much about what it's going to do and how our stories work:

  • Do users know the difference between sharing a specific page vs sharing the whole story? Surely they'll figure it out, but we don't know if it's something they already thought about, and if not it might create some confusion
  • Do users know what a "page" is? We know because we've been using that in our codebase from the beginning, but other stories platforms call that a "story"

That being said, the feature will be very useful for some use cases, especially stories using branching.
Should we ask for publishers to opt-in to enable it?

@newmuis
Copy link
Contributor

newmuis commented Feb 13, 2019

/cc @hongwei1990 for @gmajoulet's UX comments above

@hongcatlover
Copy link

I think the message here is wrong. What we are doing here is not just share this current page, we are saying your story will share start from this page. The UI is a bit misleading here too. I will take a look.

@hongcatlover
Copy link

Please see my UX mocks below
state1
state2
redline

@bramanudom
Copy link
Contributor Author

I think this is ready for review! @gmajoulet @newmuis @cvializ

Copy link
Contributor

@newmuis newmuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, save for the comment on isDesktopUi

uiState === UIType.DESKTOP_FULLBLEED ||
uiState === UIType.DESKTOP_PANELS;

if (isExperimentOn(this.win, 'amp-story-branching') && isDesktopUi) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can show this even if it's not the desktop UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I was in understanding that when on mobile we would be triggering the native sharing UI, of which the design in still pending. Please correct me if I'm wrong!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some mobile browsers trigger native sharing, but not all. For those that don't, they'll get this UI!

@Enriqe Enriqe merged commit 2092e3c into ampproject:master Mar 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants