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

Website: Implement glowing cursor effect #1009

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

IPogorelova
Copy link

@IPogorelova IPogorelova commented Jan 13, 2025

This PR introduces a new component, GlowHoverContainer, which extends BaseContainer with a glowing cursor effect.
Issue: #987

Changes:

  • GlowHoverContainer: a new component that wraps BaseContainer and adds the glowing cursor effect.
  • BaseContainer: minor adjustments to enable the glowing cursor functionality:
    • Removed duplicated usage of the backgroundColor property, which was previously used on both the parent and child <div>s within the component. This change appears to have no impact on existing functionality, as I've found only 1 usage of backgroundColor property in the project (on the /arts page) and it works fine after component's change.
  • Usage example: added an example of GlowHoverContainer usage on the main page below the Hero section. (TODO: Remove this example before merging)
  • Storybook: as Storybook integration to the project is still in progress, I'd suggest to leave the implementation of the component's Story for later.

Note:
npm run format-code produced unexpected changes across all repo files, primarily related to line breaks. To avoid unintended consequences, I did not commit these changes.
I understand that consistent code formatting is important. However, I'm encountering difficulties with the current formatting command locally. If you have any suggestions or have ever encountered the same issue, I'd really appreciate any advice.

Hope this helps!

Summary by CodeRabbit

  • New Features

    • Introduced a new glow hover effect for interactive containers.
    • Added a new GLowHoverContainer component for enhanced visual interaction.
    • Implemented a custom hook for dynamic hover interactions.
  • Improvements

    • Enhanced component referencing and styling capabilities with new props.
    • Added more granular control over container visual effects.
  • Technical Enhancements

    • Created utility functions for color parsing and linear animations.
    • Developed a modular approach to hover effect management.

Copy link

vercel bot commented Jan 13, 2025

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

Name Status Preview Comments Updated (UTC)
public ❌ Failed (Inspect) Jan 14, 2025 8:12pm

Copy link

coderabbitai bot commented Jan 13, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a glow hover effect system for UI components. It adds a new wrapperRef prop to the BaseContainer, allowing for external references, and introduces the GLowHoverContainer component for enhanced hover effects. A new module for the glow hover effect is created, including customizable options and a linear animation utility. Additionally, a custom React hook, useGlowHover, is implemented to manage the hover effects, and the public API is updated to include these new functionalities.

Changes

File Change Summary
ui/src/components/containers/base-container.tsx Added wrapperRef prop, updated BaseContainer, introduced GLowHoverContainer
ui/src/components/use-glow-hover/glow-hover-effect.ts New module with glowHoverEffect function, GlowHoverOptions type, and color parsing utility
ui/src/components/use-glow-hover/index.ts Added exports for glowHoverEffect and GlowHoverOptions
ui/src/components/use-glow-hover/linear-animation.ts New linear animation utility with LinearAnimationParams interface
ui/src/components/use-glow-hover/use-glow-hover.ts New useGlowHover React hook with GlowHoverHookOptions type
ui/src/index.ts Added export for use-glow-hover module
website/src/app/[lang]/[region]/(website)/(home)/(sections)/overview.tsx Integrated GLowHoverContainer in Overview component

Sequence Diagram

sequenceDiagram
    participant User
    participant Component
    participant GlowHoverHook
    participant GlowHoverEffect

    User->>Component: Hover/Interact
    Component->>GlowHoverHook: Apply Hover Effect
    GlowHoverHook->>GlowHoverEffect: Initialize Effect
    GlowHoverEffect-->>Component: Update Visual Styling
    GlowHoverEffect->>GlowHoverEffect: Animate Glow
Loading

Possibly related issues

  • [github#987] Implement glowing cursor section
    • The new glow hover effect system directly addresses the requirement for creating interactive, glowing UI elements.
    • Provides a flexible implementation that can be used across different sections and pages.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d618b55 and b3b8e29.

📒 Files selected for processing (1)
  • ui/src/components/containers/base-container.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Test functions
  • GitHub Check: Test shared code
  • GitHub Check: Test website
  • GitHub Check: Test admin
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (2)
ui/src/components/containers/base-container.tsx (2)

6-11: LGTM! Type definitions are now complete.

The BaseContainerProps type correctly includes the new wrapper-related props.


15-26: LGTM! BaseContainer implementation is solid.

The component correctly handles the new wrapper props and className merging.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@IPogorelova IPogorelova linked an issue Jan 13, 2025 that may be closed by this pull request
1 task
@IPogorelova IPogorelova added the website Issues concerning Website label Jan 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
ui/src/components/use-glow-hover/glow-hover-effect.ts (1)

124-124: Avoid assignments within arrow function expressions

Using assignments within arrow function expressions without braces can be confusing and reduce code readability.

Apply the following diff to improve clarity:

-onIdUpdate: (newId) => (lightSizeEnterAnimationId = newId),
+onIdUpdate: (newId) => {
+  lightSizeEnterAnimationId = newId;
+},

Repeat this change for lines 158, 177, and 196.

Also applies to: 158-158, 177-177, 196-196

🧰 Tools
🪛 Biome (1.9.4)

[error] 124-124: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

ui/src/components/use-glow-hover/use-glow-hover.ts (1)

13-13: Optimize useEffect dependencies to prevent unnecessary re-renders

Using Object.values(options) in the dependency array may cause the effect to run on every render if options is not memoized, leading to performance issues.

Consider memoizing the options object or explicitly listing each option in the dependency array.

ui/src/components/use-glow-hover/linear-animation.ts (1)

14-15: Clamp initialProgress to the range [0, 1]

Currently, initialProgress can be outside the range [0, 1], which may cause unexpected behavior in the animation.

Apply this diff to ensure initialProgress is within the valid range:

 }: LinearAnimationParams) => {
+  initialProgress = Math.min(Math.max(initialProgress, 0), 1);
   if (time === 0) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d28b07 and d618b55.

📒 Files selected for processing (7)
  • ui/src/components/containers/base-container.tsx (1 hunks)
  • ui/src/components/use-glow-hover/glow-hover-effect.ts (1 hunks)
  • ui/src/components/use-glow-hover/index.ts (1 hunks)
  • ui/src/components/use-glow-hover/linear-animation.ts (1 hunks)
  • ui/src/components/use-glow-hover/use-glow-hover.ts (1 hunks)
  • ui/src/index.ts (1 hunks)
  • website/src/app/[lang]/[region]/(website)/(home)/(sections)/overview.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • ui/src/components/use-glow-hover/index.ts
🧰 Additional context used
🪛 GitHub Actions: Website
ui/src/components/containers/base-container.tsx

[error] 14-14: Property 'wrapperClassName' does not exist on type '{ backgroundColor?: BackgroundColor | undefined; wrapperRef?: Ref | undefined; } & HTMLAttributes'

🪛 Biome (1.9.4)
ui/src/components/use-glow-hover/glow-hover-effect.ts

[error] 124-124: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 158-158: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 177-177: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 196-196: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (2)
ui/src/index.ts (1)

30-30: LGTM!

The new export follows the existing pattern and maintains alphabetical order.

website/src/app/[lang]/[region]/(website)/(home)/(sections)/overview.tsx (1)

14-26: Remove temporary example code.

The TODO comment indicates this code should be removed before merge. Please remove this example usage of GLowHoverContainer.

ui/src/components/containers/base-container.tsx Outdated Show resolved Hide resolved
Comment on lines +26 to +38
export const GLowHoverContainer = React.forwardRef<HTMLDivElement, Omit<BaseContainerProps, 'wrapperRef'>>(
({ className, ...props }, ref) => {
const refCard = useGlowHover({ lightColor: '#CEFF00' });

return (
<BaseContainer
wrapperClassName={twMerge('theme-blue', className)}
ref={ref}
{...props}
wrapperRef={refCard as React.Ref<HTMLDivElement>}
/>
);
},
Copy link

@coderabbitai coderabbitai bot Jan 13, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve type safety and configuration of GLowHoverContainer.

Two suggestions for improvement:

  1. Avoid type casting of refCard
  2. Make the light color configurable
-export const GLowHoverContainer = React.forwardRef<HTMLDivElement, Omit<BaseContainerProps, 'wrapperRef'>>(
+type GlowHoverContainerProps = Omit<BaseContainerProps, 'wrapperRef'> & {
+  lightColor?: string;
+};
+
+export const GLowHoverContainer = React.forwardRef<HTMLDivElement, GlowHoverContainerProps>(
-	({ className, ...props }, ref) => {
+	({ className, lightColor = '#CEFF00', ...props }, ref) => {
-		const refCard = useGlowHover({ lightColor: '#CEFF00' });
+		const refCard = useGlowHover({ lightColor });

 		return (
 			<BaseContainer
 				wrapperClassName={twMerge('theme-blue', className)}
 				ref={ref}
 				{...props}
-				wrapperRef={refCard as React.Ref<HTMLDivElement>}
+				wrapperRef={refCard}
 			/>
 		);
 	},
 );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const GLowHoverContainer = React.forwardRef<HTMLDivElement, Omit<BaseContainerProps, 'wrapperRef'>>(
({ className, ...props }, ref) => {
const refCard = useGlowHover({ lightColor: '#CEFF00' });
return (
<BaseContainer
wrapperClassName={twMerge('theme-blue', className)}
ref={ref}
{...props}
wrapperRef={refCard as React.Ref<HTMLDivElement>}
/>
);
},
type GlowHoverContainerProps = Omit<BaseContainerProps, 'wrapperRef'> & {
lightColor?: string;
};
export const GLowHoverContainer = React.forwardRef<HTMLDivElement, GlowHoverContainerProps>(
({ className, lightColor = '#CEFF00', ...props }, ref) => {
const refCard = useGlowHover({ lightColor });
return (
<BaseContainer
wrapperClassName={twMerge('theme-blue', className)}
ref={ref}
{...props}
wrapperRef={refCard}
/>
);
},

Copy link
Author

Choose a reason for hiding this comment

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

@ssandino hi!
Could you please tell if you need the glowing color to be configurable?
As I can see now, the blue color mostly used throughout the site to make banners and accent sections and yellow cursor glow fits perfectly here. However, there's no problem adding prop for a custom color.

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment on lines +15 to +58
<GLowHoverContainer className="mb-16 mt-8 flex flex-col items-center justify-center md:mb-48 md:mt-16">
<Typography size="3xl" weight="medium" className="my-10 text-center">
{translator.t('section-2.title-1')}
</Typography>
<div className="mb-8 text-center">
{translator.t<{ text: string; color?: FontColor }[]>('section-2.title-2').map((title, index) => (
<Typography as="span" size="3xl" weight="medium" color={title.color} key={index}>
{title.text}{' '}
</Typography>
))}
</div>
</GLowHoverContainer>

<BaseContainer className="mx-auto mb-16 mt-8 flex w-4/5 flex-col items-center justify-center md:mb-48 md:mt-16 lg:w-3/5">
<Typography size="3xl" weight="medium" className="my-10 text-center">
{translator.t('section-2.title-1')}
</Typography>
<div className="mb-8 text-center">
{translator.t<{ text: string; color?: FontColor }[]>('section-2.title-2').map((title, index) => (
<Typography as="span" size="3xl" weight="medium" color={title.color} key={index}>
{title.text}{' '}
</Typography>
))}
</div>
<Typography size="3xl" weight="medium" className="mb-5 mt-12 text-center">
{translator.t('section-2.title-3')}
</Typography>
<ol className="mb-8 list-decimal">
<li>
<Typography as="span">{translator.t('section-2.text-3.1')}</Typography>
</li>
<li>
<Typography as="span">{translator.t('section-2.text-3.2')}</Typography>
</li>
</ol>
<Typography size="3xl" weight="medium" className="mb-5 mt-12 text-center">
{translator.t('section-2.title-4')}
</Typography>
<Typography className="mb-8">{translator.t('section-2.text-4')}</Typography>
<Typography size="3xl" weight="medium" className="mb-5 mt-12 text-center">
{translator.t('section-2.title-5')}
</Typography>
<Typography className="w-full">{translator.t('section-2.text-5')}</Typography>
</BaseContainer>
Copy link

@coderabbitai coderabbitai bot Jan 13, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid content duplication.

The same content is duplicated between GLowHoverContainer and BaseContainer. Choose one container based on the intended design.

Copy link
Author

Choose a reason for hiding this comment

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

JFI: this part of duplicated content will be removed before merge

Copy link

Choose a reason for hiding this comment

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

@IPogorelova Thanks for clarifying! I see the TODO comment now, and understand this is just a temporary example.


If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!

@ssandino
Copy link
Member

Locally the effect works very nicely:
glow2

Copy link

github-actions bot commented Jan 13, 2025

Visit the preview URL for this PR (updated for commit b3b8e29):

https://si-admin-staging--pr1009-implement-glowing-cu-0qtybgf8.web.app

(expires Tue, 21 Jan 2025 18:13:21 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b7b0969384059dce6ea8fad1ee1d1737e54e6676

@ssandino
Copy link
Member

The deployment on Vercel preview throws following error:

Failed to compile.
../ui/src/components/containers/base-container.tsx:14:43
Type error: Property 'wrapperClassName' does not exist on type '{ backgroundColor?: BackgroundColor | undefined; wrapperRef?: Ref | undefined; } & HTMLAttributes'.
12 |
13 | export const BaseContainer = React.forwardRef<HTMLDivElement, BaseContainerProps>(
14 | ({ children, className, backgroundColor, wrapperClassName, wrapperRef, ...props }, ref) => {
| ^
15 | return (
16 | <div className={twMerge(wrapperClassName, backgroundColor)} ref={wrapperRef}>
17 |


Static worker exited with code: 1 and signal: null
npm error Lifecycle script build failed with error:
npm error code 1
npm error path /vercel/path0/website
npm error workspace @socialincome/[email protected]
npm error location /vercel/path0/website
npm error command failed
npm error command sh -c next build
Error: Command "npm run website:build" exited with 1

And the co-pilot bug report says:
The wrapperClassName property needs to be added to the BaseContainerProps type definition to resolve the deployment error. (so the same as the Coderabbit comment above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
website Issues concerning Website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Web]: Implement glowing cursor section
2 participants