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

✨ Adding themes for new outlink CTA #33702

Merged
merged 54 commits into from
Apr 16, 2021
Merged

Conversation

raxsha
Copy link
Contributor

@raxsha raxsha commented Apr 8, 2021

The following themes are now available for the outlink CTA button:

  • default light theme
  • default dark theme
  • custom theme (user specifies an accent color, and whether it's applied to the background or text)

Firebase demo: https://test-project-01-ead4f.web.app/examples/amp-story/attachment.html

themes

Fixes #32716
Fixes #32718

@raxsha raxsha requested a review from mszylkowski April 8, 2021 02:32
@raxsha raxsha marked this pull request as ready for review April 8, 2021 02:43
@amp-owners-bot
Copy link

amp-owners-bot bot commented Apr 8, 2021

Hey @gmajoulet, @newmuis, @Enriqe! These files were changed:

extensions/amp-story/1.0/amp-story-open-page-attachment.css
extensions/amp-story/1.0/amp-story-open-page-attachment.js
extensions/amp-story/1.0/amp-story-page-attachment.js
extensions/amp-story/1.0/test/test-amp-story-page.js
extensions/amp-story/1.0/test/validator-amp-story-page-attachment.html
extensions/amp-story/1.0/test/validator-amp-story-page-attachment.out
extensions/amp-story/validator-amp-story.protoascii

Hey @ampproject/wg-caching! These files were changed:

extensions/amp-story/1.0/test/validator-amp-story-page-attachment.html
extensions/amp-story/1.0/test/validator-amp-story-page-attachment.out
extensions/amp-story/validator-amp-story.protoascii

@raxsha raxsha removed the request for review from mszylkowski April 8, 2021 21:41
@raxsha raxsha requested a review from mszylkowski April 14, 2021 19:26
@raxsha raxsha requested a review from mszylkowski April 16, 2021 02:43
@raxsha
Copy link
Contributor Author

raxsha commented Apr 16, 2021

Transition state for the new outlink UI will be built with: #33812

@mszylkowski
Copy link
Contributor

JS/CSS looks good, left comments on the DD for the API but let's continue that offline (and could be changed later since this is behind an experiment)

@lgtm-com
Copy link

lgtm-com bot commented Apr 16, 2021

This pull request introduces 3 alerts when merging 8f10a84 into 4d9ef0e - view on LGTM.com

new alerts:

  • 3 for Useless assignment to local variable

extensions/amp-story/1.0/amp-story-open-page-attachment.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/amp-story-open-page-attachment.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/amp-story-open-page-attachment.js Outdated Show resolved Hide resolved
} else {
const linkImage = htmlFor(
attachmentEl
)`<svg class="i-amphtml-story-page-open-attachment-link-icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the SVG be living in the CSS instead, and added through a class?

Copy link
Contributor

Choose a reason for hiding this comment

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

The CSS needs to change the color based on the accent color (the same color as the text), and CSS background-image can't access CSS vars or be changed through JS. The simplest workaround is to have the SVG in the HTML allowing the use of the CSS vars, unless you had another way fo doing this (like tinting background-images or other sorcery)

extensions/amp-story/1.0/amp-story-open-page-attachment.js Outdated Show resolved Hide resolved
Comment on lines 161 to 164
let themeAttribute = attachmentEl.getAttribute('theme');
if (themeAttribute) {
themeAttribute = AttachmentTheme[themeAttribute.toUpperCase()];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let themeAttribute = attachmentEl.getAttribute('theme');
if (themeAttribute) {
themeAttribute = AttachmentTheme[themeAttribute.toUpperCase()];
}
let themeAttribute = attachmentEl.getAttribute('theme').toLowerCase();

Simplifying a bit, this should give you the same value

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 doesn't work bc theme isn't always set, so there needs to be a check. I went with:

let themeAttribute = attachmentEl.getAttribute('theme');
  if (themeAttribute) {
    themeAttribute = themeAttribute.toLowerCase();
  }

extensions/amp-story/1.0/amp-story-open-page-attachment.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/amp-story-open-page-attachment.js Outdated Show resolved Hide resolved
Copy link
Member

@twifkak twifkak left a comment

Choose a reason for hiding this comment

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

LGTM for validator

@raxsha raxsha merged commit 3887bad into ampproject:main Apr 16, 2021
Gregable pushed a commit that referenced this pull request Apr 19, 2021
rochapablo pushed a commit to rochapablo/amphtml that referenced this pull request Aug 30, 2021
* outlinke cta

* restoring arrow

* adding default and customizable image

* adding default and customizable image

* adding example pages

* adding example pages - nit

* refactor adding image

* adding instructions

* using flexbox instead of table layouts

* fixes

* removing click target

* lint

* htmlrefs

* conditional fix

* added unit test

* added tests

* CSS classes

* test nits

* createElementWithAttributes

* only one additional class

* removes default image class

* added dark theme and custom theme

* trying to do contrast calculations

* added contrast calculations

* added validator tests

* merge conflicts

* merge conflicts

* merge conflicts

* changed arrow color, added new SVG customization function

* trying to customize SVG

* trying to customize SVG

* added custom SVG method

* custom SVG

* css vars

* cleanup

* adding unit test

* adding border around custom image + nits

* moved rgb logic into open-pg-attachment

* removed border

* removed added element

* css nits

* enum classes

* added setCustomThemeStyles(win, attachmentEl, openAttachmentEl) method

* nits

* theme enum fix

* fix unit test
rochapablo pushed a commit to rochapablo/amphtml that referenced this pull request Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Page attachments] [Outlink] Accent color [Page attachments] [Outlink] Theme attribute
5 participants