-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
@@ -0,0 +1,148 @@ | |||
/** | |||
* Copyright 2015 The AMP HTML Authors. All Rights Reserved. |
There was a problem hiding this comment.
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 @@ | |||
/* |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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> |
There was a problem hiding this comment.
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
196c731
to
c0a1c34
Compare
} | ||
if (link === null) { | ||
link = this.getWin().document.createElement(LINK_TAG); | ||
link.innerHTML = this.typeConfig_['text']; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- You can research
white-space
CSS rules and how to modify them for your desired needs. - You can set
a
todisplay: 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 hosta
inside ofspan
. Although, I don't yet understand whatspan
does and why it's needed. - You can use JS character equivalent to
. 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent 4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
ab6577b
to
3901312
Compare
|
||
/** @private @const {number} */ | ||
this.width_ = getLengthNumeral(this.element.getAttribute('width')) | ||
|| DEFAULT_WIDTH; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: indent 4
There was a problem hiding this comment.
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
Looks great. Please squash commits and we can ship this! |
3901312
to
3db8802
Compare
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', |
There was a problem hiding this comment.
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
3db8802
to
519b3e8
Compare
Does anyone know how long this takes to be hosted on the cdn? |
@escobar022 we just released this in our |
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. 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? |
@corysimmons Would you mind opening an issue with this info? |
Done #2628 |
Created the AMP Social Share Extension as per Issue #1201