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

AMP Social Share Extension #1856

Merged
merged 1 commit into from
Mar 10, 2016

Conversation

paul-matthews
Copy link
Contributor

Created the AMP Social Share Extension as per Issue #1201

  • One extension that represents one social share button
  • Supports:
    • twitter
    • facebook
    • pinterest
    • linkedin
    • gplus
    • email
  • Included Tests
  • Includes changes to the gulp build process to include postcss-import
  • Includes 3p licensed content from http://codepen.io/ruandre/pen/howFi

@@ -0,0 +1,148 @@
/**
* Copyright 2015 The AMP HTML Authors. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

2016 here and any other new file

@@ -0,0 +1,50 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

did we make any changes to this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I couldn't reference the contents of the file without making changes.

I extracted the svgs, and wrapped them with css classes.

Copy link
Member

Choose a reason for hiding this comment

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

we're going to probably need to add a LICENSE file in this folder as well as a README.amp that contains any modification. see https://github.com/ampproject/amphtml/blob/master/third_party/mustache/README.amp.

you might want to commit the original code (through its own standalone PR) and then through a another PR (or the same PR but different commit) do the modification, so we can see a clear delta of what has changed.

/cc @cramforce

@erwinmombay
Copy link
Member

just did quick initial pass, will look into it some more tomorrow since i haven't had a chance to read the original issue yet (qoals/constraints etc).

background-color: blue;
}
</style>
<style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
Copy link
Member

Choose a reason for hiding this comment

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

lets switch this to the new boilerplate. see https://github.com/ampproject/amphtml/blob/master/docs/create_page.md sample

}
if (link === null) {
link = this.getWin().document.createElement(LINK_TAG);
link.innerHTML = this.typeConfig_['text'];
Copy link
Member

Choose a reason for hiding this comment

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

if its only text, lets use textContent 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.

I tried switching to textContext but it results in a collapsed anchor for the cases where no text is necessary. In other words, if i use a   it'll display it as text, if I input a space it'll collapse the anchor. The most common use for this text is set it blank.

The only other option I have is to not make the content extensible. However this means that all social share providers (read: Twitter, Facebook etc) could only use images.

I'm happy to share gists of what I've tried if you think there might be another option.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this should definitely be textContent here. Few options:

  1. You can research white-space CSS rules and how to modify them for your desired needs.
  2. You can set a to display: block and provide it with width/height to fill the available space. In general this is a good idea since what you do is a block. However, that'd mean that you can't then host a inside of span. Although, I don't yet understand what span does and why it's needed.
  3. You can use JS character equivalent to &nbsp;. I want to say it's \u00A0, but not 100%.

I'd like to understand the markup and its intent a little better before advising the best approach. But I do lean toward display:block on a and possible no span at all.

if ('maxlength' in paramConf) {
const maxlength = paramConf['maxlength'];
AMP.assert(!paramValue || paramValue.length < maxlength,
param + ' cannot exceed ' + maxlength + '. %s', this.element);
Copy link
Member

Choose a reason for hiding this comment

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

nit: indent 4

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.

@paul-matthews paul-matthews force-pushed the amp-social-share branch 2 times, most recently from ab6577b to 3901312 Compare March 10, 2016 01:03

/** @private @const {number} */
this.width_ = getLengthNumeral(this.element.getAttribute('width'))
|| DEFAULT_WIDTH;
Copy link
Member

Choose a reason for hiding this comment

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

nit: indent 4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressing, but there should be a lint for this stuff :-p

@cramforce
Copy link
Member

Looks great. Please squash commits and we can ship this!

@cramforce
Copy link
Member

LGTM

let paramValue = this.config_[param] || this.getDefaultValue_(
param, this.config_);
AMP.assert(!paramConf['required'] || paramValue !== null,
param + ' is a required attribute for ' + this.type_ + '. %s',
Copy link
Member

Choose a reason for hiding this comment

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

nit: 4 space indent

* Adding postcss-import to the project
* Adding amp-social-share extension
cramforce added a commit that referenced this pull request Mar 10, 2016
@cramforce cramforce merged commit b80230b into ampproject:master Mar 10, 2016
@escobar022
Copy link

Does anyone know how long this takes to be hosted on the cdn?

@erwinmombay
Copy link
Member

@escobar022 we just released this in our opt-in canary (turned on through cdn.ampproject.org/experiments.html dev-channel) https://github.com/ampproject/amphtml/releases/tag/1457636119213 , we will turn it on for 1% of pages come monday if we didnt see any problems. Then this extension should be fully live by end of day next thursday if we've deemed the version to be stable.

@corysimmons
Copy link

https://amp-partners.appspot.com/social demo looks good but the Twitter logo isn't retina friendly (it isn't svg whereas the others are), and it doesn't look like Facebook is displaying properly at all.

image

Also is there a reason these have border-radius? It's not built in is it? Perhaps we shouldn't encourage additional styles (to disable pre-existing styles) where possible?

@dvoytenko
Copy link
Contributor

@corysimmons Would you mind opening an issue with this info?

@corysimmons
Copy link

Done #2628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants