Skip to content

Add hover state to site thumbnail - #357

Merged
wojtekn merged 10 commits into
trunkfrom
add/site-thumbnail-link
Jul 16, 2024
Merged

Add hover state to site thumbnail#357
wojtekn merged 10 commits into
trunkfrom
add/site-thumbnail-link

Conversation

@wojtekn

@wojtekn wojtekn commented Jul 12, 2024

Copy link
Copy Markdown
Contributor

Related to #103

Proposed Changes

I propose adding a hover state to the site thumbnail to let the user open the site by clicking it.

Screenshot 2024-07-12 at 16 01 36

Testing Instructions

  1. Start site
  2. Confirm the new thumbnail hover state works as expected
  3. Click the thumbnail and confirm it opens the site
  4. Stop the site
  5. Confirm there is no hover state anymore

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@wojtekn
wojtekn requested a review from a team July 12, 2024 14:02
@wojtekn wojtekn self-assigned this Jul 12, 2024
Comment thread src/components/content-tab-overview.tsx Outdated
{ ! loading && siteRunning && (
<button
aria-label={ __( 'Open WP Admin' ) }
className={ cx( `relative group` ) }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I couldn't make the focus state work and it was yellow all the time. How to do it correctly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you try using something like Button component that we have: https://github.com/Automattic/studio/blob/trunk/src/components/button.tsx ? It would take care of all these styles including focus so you would not need to manually fix them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, and it was even worse. I've just pushed the fix for the outline issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hahaha, it does not surprise me 😅

Ideally I would love for us to use the components we have instead of adding the button manually but I have not explored this solution in detail.

Comment thread src/components/content-tab-overview.tsx Outdated
`opacity-0 group-hover:opacity-90 group-hover:bg-white duration-300 absolute size-full flex justify-center items-center bg-white text-a8c-blueberry`
) }
>
{ __( 'Open Site' ) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ __( 'Open Site' ) }
{ __( 'Open site' ) }

This seems to be the spelling according to the design

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fixed the letter casing, thanks.

Comment thread src/components/content-tab-overview.tsx Outdated
{ ! loading && (
{ ! loading && siteRunning && (
<button
aria-label={ __( 'Open WP Admin' ) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am finding a bit strange that the aria-label is Open WP admin but the text on the actual thumbnail is Open site. Should we consolidate the two to be consistent there? Perhaps the text on the thumbnail should be Open WP admin if that is what the action of clicking on the thumbnail does?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I fixed it already when I changed the link to open site frontend instead of WP Admin.

<div
className={ cx(
'w-full min-h-40 max-h-60 overflow-hidden rounded-sm border border-a8c-gray-5 bg-a8c-gray-0 mb-2 flex items-center justify-center',
'w-full min-h-40 max-h-64 rounded-sm border border-a8c-gray-5 bg-a8c-gray-0 mb-2 flex justify-center',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to fix the missing top and bottom thumbnail outline on focus.

@wojtekn
wojtekn requested a review from katinthehatsite July 15, 2024 06:37

@fluiddot fluiddot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGMT 🎊 ! I've added some comments but none should be considered a blocker for this PR.

Comment thread src/components/content-tab-overview.tsx Outdated
Comment thread src/components/content-tab-overview.tsx Outdated
Comment thread src/components/content-tab-overview.tsx Outdated
Comment thread src/components/content-tab-overview.tsx Outdated

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Carlos' suggestions make sense.

I tested the Pr and it looks good. I have two questions:

  1. I think the hover effect should be present even if the server is stopped. In that case we should start the server before opening the browser.
  2. The focus effect should be the same as the hover effect, displaying the open site effect, as shown here #103 (comment)
Screenshot 2024-07-15 at 16 17 18

Screencast:

U9djHa.mp4
@wojtekn

wojtekn commented Jul 16, 2024

Copy link
Copy Markdown
Contributor Author

Thanks for testing it!

I think the hover effect should be present even if the server is stopped. In that case, we should start the server before opening the browser.

It may make some sense. However, it would introduce a difference between the 'WP Admin' and 'Open site' buttons and the thumbnail. The buttons in the site header are disabled when the site is not running, and they don't allow the site to start automatically. For those reasons, I would prefer to keep those aligned. What if we displayed the disabled cursor over the thumbnail on a stopped site?

The focus effect should be the same as the hover effect, displaying the open site effect, as shown here #103 (comment)

Thanks, fixed: 8242879

@fluiddot fluiddot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Re-tested using the latest changes. It worked as expected 🎊.

@wojtekn
wojtekn merged commit 4fe49bd into trunk Jul 16, 2024
@wojtekn
wojtekn deleted the add/site-thumbnail-link branch July 16, 2024 13:19

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing the group-focus 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants