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 hover behavior for images #4735

Merged
merged 19 commits into from
Jan 22, 2024
Merged

adding hover behavior for images #4735

merged 19 commits into from
Jan 22, 2024

Conversation

mirnawong1
Copy link
Contributor

@mirnawong1 mirnawong1 commented Jan 11, 2024

AI Summary: This pull request primarily involves changes to the image display size in various markdown files. The changes reduce the width of images displayed using the <Lightbox> tag from the original size to a smaller size, typically 90%. This adjustment is likely to improve the layout and readability of the documentation pages.

this pr adds a 'hover over images to expand' behavior. the following changes were made to the original code:

original lightbox src component:

  • original lightbox component handled the display of images with alignment and collapsing features.
  • used props for customization but did not have any interactive behavior like hover effects or handling of scrolling events.

updates to lightbox src component:

  • added state variables : isHovered, expandImage, and isScrolling.
  • isHovered: tracks if the mouse is hovering over image.
  • expandImage: identifies if the image should expand.
  • isScrolling: helps indicate whether page is currently being scrolled. (to avoid pop ups when a user is reading)
  • implemented a hover effect that expands the image (setExpandImage(true) after a delay (300 milliseconds), but only if the page is not being scrolled (!isScrolling).
  • added a handleScroll function to update the isScrolling state when the user scrolls. This function also cancels the image expansion (setExpandImage(false)) and resets isScrolling after a delay.
  • added event listeners for mouse enter (onMouseEnter) and mouse leave (onMouseLeave) to control the hover state (setIsHovered).
  • attached a scroll event listener to the window in a useEffect hook to trigger handleScroll
  • modified the handleMouseEnter to include a delay (matching the scroll delay) before setting isHovered to true. This ensures that hover effects are not activated immediately after scrolling stops.
  • adjusted the component structure and styling to accommodate the new hover and scroll behaviors. this means the image now scales (transform: 'scale(1.2)') with a smooth transition (transition: 'transform 0.5s ease') when hovered, and the zIndex is increased to '9999' during expansion.
  • added a default width to 80% to all images (using lightbox src component) to ensure the scale was consistent across images and improve accessibility. adding widths also helps with page load and SEO.

images

  • also adjusted widths for images that a large width attribute assigned. this is to ensure it scaled correctly without affecting the user UX.

@mirnawong1 mirnawong1 requested review from dataders and a team as code owners January 11, 2024 17:20
Copy link

vercel bot commented Jan 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 22, 2024 10:48am

@github-actions github-actions bot added size: large This change will more than a week to address and might require more than one person Docs team Authored by the Docs team @dbt Labs content Improvements or additions to content developer blog This content fits on the developer blog. guides Knowledge best suited for Guides and removed size: large This change will more than a week to address and might require more than one person Docs team Authored by the Docs team @dbt Labs labels Jan 11, 2024
@github-actions github-actions bot added Docs team Authored by the Docs team @dbt Labs size: large This change will more than a week to address and might require more than one person labels Jan 11, 2024
This reverts commit da40805, reversing
changes made to 39ad19d.
@github-actions github-actions bot added size: x-small This change will take under 3 hours to fix. and removed size: large This change will more than a week to address and might require more than one person labels Jan 11, 2024
@github-actions github-actions bot added size: medium This change will take up to a week to address and removed size: x-small This change will take under 3 hours to fix. labels Jan 11, 2024
@github-actions github-actions bot added size: large This change will more than a week to address and might require more than one person and removed size: medium This change will take up to a week to address labels Jan 11, 2024
@github-actions github-actions bot added size: medium This change will take up to a week to address and removed size: large This change will more than a week to address and might require more than one person labels Jan 15, 2024
@@ -185,7 +185,7 @@ Now that you’ve set up the dbt project, database, and have taken a peek at the

Identifying the business process is done in collaboration with the business user. The business user has context around the business objectives and business processes, and can provide you with that information.

<Lightbox src="/img/blog/2023-04-18-building-a-kimball-dimensional-model-with-dbt/conversation.png" width="65%" title="Conversation between business user and analytics engineer"/>
<Lightbox src="/img/blog/2023-04-18-building-a-kimball-dimensional-model-with-dbt/conversation.png" title="Conversation between business user and analytics engineer"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the original images don't have a width attribute and this undo's a python script i ran, which added a width attribute.

@mirnawong1
Copy link
Contributor Author

also not sure if the scrolling is affecting the hover a little

Copy link
Collaborator

@JKarlavige JKarlavige left a comment

Choose a reason for hiding this comment

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

The scale on hover looks like it works great, awesome work @mirnawong1!

Comment on lines +56 to +58
${alignment === "left" ? styles.leftAlignLightbox : ''}
${alignment === "right" ? styles.rightAlignLightbox : ''}
${isHovered ? styles.hovered : ''}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice work with these conditional checks!

@mirnawong1 mirnawong1 merged commit 9672b61 into current Jan 22, 2024
7 checks passed
@mirnawong1 mirnawong1 deleted the mwong-hover-images branch January 22, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content developer blog This content fits on the developer blog. Docs team Authored by the Docs team @dbt Labs guides Knowledge best suited for Guides January-2024 size: medium This change will take up to a week to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants