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

Theme: remove nested anchor in theme sheet #34695

Merged
merged 3 commits into from
Jul 22, 2019
Merged

Conversation

donpark
Copy link
Contributor

@donpark donpark commented Jul 16, 2019

Changes proposed in this Pull Request

Removes unnecessary 'Open Live Demo' anchor nested inside preview anchor in theme sheet page at /theme/{theme_slug} path.

Nested anchor was not visible and is no longer necessary because 'Open Live Demo' button is already displayed in the Nav Bar.

screenshot_790

Testing instructions

  1. Using Chrome, navigate to /theme/photo-blog or /theme/photo-blog/{site_slug}.
  2. Open DevTools > Console and verify that following warnings are no longer emitted.

screenshot_789

Fixes #34609

@donpark donpark added [Feature Group] Appearance & Themes Features related to the appearance of sites. [Type] Janitorial labels Jul 16, 2019
@donpark donpark requested a review from jsnajdr July 16, 2019 23:54
@donpark donpark self-assigned this Jul 16, 2019
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

matticbot commented Jul 17, 2019

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~6 bytes removed 📉 [gzipped])

name   parsed_size           gzip_size
theme        -76 B  (-0.0%)       -6 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

</span>
</a>
);
}
Copy link
Member

Choose a reason for hiding this comment

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

This "Open Live Demo" button seems to be a part of intentional UI design that looks differently on wide two-column layout and narrow, mobile one-column layout

  • two-column layout shows an "Open Live Demo" item in a SectionNav in the left column
  • that item is hidden in one-column view, and the "Open Live Demo" button (the element being removed in this PR) is displayed under the screenshot

@folletto may provide some advice about how to remove the invalid HTML while keeping the design working. He originally worked on it and submitted PRs like #13598.

Also, removing the button breaks the theme-sheet-welcome-tour guided tour that looks for the data-tip-target="theme-sheet-preview" element and attaches a bubble to it. That tour is likely already broken on non-mobile views (?!)

Copy link
Member

Choose a reason for hiding this comment

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

To see this code in action, open a theme page like https://wordpress.com/theme/modern-business and resize the window to switch between one- and two-column views.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, so that's why it was there. We should include a comment in the fix so it's more apparent.

@folletto
Copy link
Contributor

because 'Open Live Demo' button is already displayed in the Nav Bar

Maybe I'm missing something, but... where? Can you post a screenshot?

@jsnajdr
Copy link
Member

jsnajdr commented Jul 17, 2019

Two column layout shows "Open Live Demo" in the SectionNav. The right column contains the theme screenshot and nothing else. The "Open Live Button" is not displayed there:

Screenshot 2019-07-17 at 17 12 46

Single column layout hides "Open Live Demo" from the SectionNav and shows it as button in an overlay over the screenshot. (The responsive view shows the second column on top, and the first column under it)
Screenshot 2019-07-17 at 17 13 18

@folletto
Copy link
Contributor

folletto commented Jul 17, 2019

Yes sorry, I didn't mean the difference between desktop and mobile.

I thought that quote in the original post meant "the action already exists elsewhere on the page" but it seems that if it gets removed, then there's no explicit action for it anymore: "no longer necessary".

Ah! I think I connected the pieces of the puzzle of why you pointed that out. Sorry, and thanks :D

Yes. The page uses some tricky pieces of code in order to make the two button appear at different breakpoints (mobile/desktop) so it's not hidden, it's just hidden at that breakpoint. It's not elegant, and frankly I don't recall the reasons from the depth of 2017, just it was the way we found to avoid other issues. I think it's because popping in and out a button from the bar at the top and move it below the screenshot, wasn't really trivial to do.

@donpark
Copy link
Contributor Author

donpark commented Jul 17, 2019

I'm not sure if current implementation of NavSection supports inlined right-alined button but I think we can improve current design of the theme sheet page by turning "Open Live Demo" into a button that remains in-place even in mobile view. As to why, it's not really a NavItem but a button and it could use more emphasis.

This is what I had in mind. "Open Live Demo" should look more like a button than just a rectangle but this is best I can manage in short time. What do you think?

screenshot_795

@folletto
Copy link
Contributor

I'm ok if you want to switch placement of it. The above however seems going a bit more outside the UI patterns we have right now, no? Is there another example of such layout that I'm missing?

@jsnajdr
Copy link
Member

jsnajdr commented Jul 18, 2019

@folletto we use a similar layout on the "Plugins" screen:

Screenshot 2019-07-18 at 11 50 11

But the buttons are not part of the SectionNav, and they currently don't align very well when the screen is resized to a narrow width.

@donpark If we want to just fix the non-valid HTML markup (nested a's), then we can just convert the "Open Live Demo" button to a passive div, can't we? It's already part of the screenshot's clickable area, so it doesn't need to be an active element with hrefs or event handlers.

@folletto
Copy link
Contributor

we use a similar layout on the "Plugins" screen

That's a bit different from the above. I'm ok with going for something like Plugins if y'all prefer to go for that layout :)

I agree right now is probably better to just fix the nesting.

@donpark
Copy link
Contributor Author

donpark commented Jul 18, 2019

If we want to just fix the non-valid HTML markup (nested a's), then we can just convert the "Open Live Demo" button to a passive div, can't we? It's already part of the screenshot's clickable area, so it doesn't need to be an active element with hrefs or event handlers.

Yeah, I agree that just fixing the nesting makes more sense. I'll update this PR. Thx.

@donpark
Copy link
Contributor Author

donpark commented Jul 18, 2019

Anchor has been replaced with <div>. Pseudo-button is still visible and clickable as before in mobile view:

screenshot_797

@donpark donpark added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 18, 2019
@folletto
Copy link
Contributor

I just noticed a thing on the mobile screenshot: the gradient is wrong. :D

It's not super noticeable on that theme given the image cut, but on another:

Screenshot 2019-07-18 at 23 52 48

This is fixed:

Screenshot 2019-07-18 at 23 54 33

It might have been when the color variables were introduced, this slipped through.

linear-gradient(180deg,rgba(var(--color-neutral-0-rgb),1) 0,rgba(var(--color-neutral-0-rgb),.5) 40%,var(--color-neutral-0) 93%)

This should fix it (but I haven't checked if it has consequences elsewhere):

linear-gradient(180deg,transparent 0,rgba(var(--color-neutral-0-rgb),.5) 40%,var(--color-neutral-0) 93%)

@donpark
Copy link
Contributor Author

donpark commented Jul 18, 2019

This should fix it (but I haven't checked if it has consequences elsewhere):

linear-gradient(180deg,transparent 0,rgba(var(--color-neutral-0-rgb),.5) 40%,var(--color-neutral-0) 93%)

Done. Button border looked more vulnerable as result but darkening it didn't help much so I let it alone.

Copy link
Member

@jsnajdr jsnajdr left a comment

Choose a reason for hiding this comment

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

This works great now, both the button and the gradient. Thanks for working on this! 👍

@donpark donpark merged commit 2e92590 into master Jul 22, 2019
@donpark donpark deleted the fix/themesheet-nested-anchor branch July 22, 2019 12:07
@matticbot matticbot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature Group] Appearance & Themes Features related to the appearance of sites. [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theme: nested anchor tags in ThemeSheet.renderScreenshot
4 participants