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 43 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 NewsletterGlowContainer as a new component, which contains NewsletterForm (also used on this page in the toast) to the Campaign page
  • 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 customizable glow hover effect for interactive elements
    • Added newsletter subscription functionality with localized support
    • Enhanced container components with advanced styling and referencing capabilities
  • Improvements

    • Expanded localization support for newsletter content across multiple languages
    • Streamlined newsletter form handling with improved validation and user feedback
  • Technical Updates

    • Implemented new React hooks and utility functions for advanced UI interactions
    • Added new components for enhanced user experience

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 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 24, 2025 6:20pm

Copy link

coderabbitai bot commented Jan 13, 2025

📝 Walkthrough

Walkthrough

This pull request introduces a comprehensive set of changes focused on enhancing the UI components, particularly around glow hover effects and newsletter functionality. The changes include new components like NewsletterForm, NewsletterGlowContainer, and a sophisticated glowHoverEffect module. Localization support for newsletter translations has been added across multiple language files, and new container components with advanced styling capabilities have been implemented.

Changes

File Change Summary
ui/src/components/containers/base-container.tsx Added wrapperClassName and wrapperRef props to BaseContainerProps
ui/src/components/use-glow-hover/* Introduced comprehensive glow hover effect module with glowHoverEffect, useGlowHover, and related utilities
website/src/components/newsletter-* New newsletter-related components for form handling and container
shared/locales/*/website-newsletter.json Added campaign information label across multiple language files
ui/src/components/containers/glow-hover-container.tsx New GlowHoverContainer component

Suggested labels

feature, ui-enhancement, newsletter

Suggested reviewers

  • andrashee
  • socialincome-dev
  • ssandino
  • mkue

Possibly related PRs


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!

Copy link
Author

Choose a reason for hiding this comment

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

According to live chat with @ssandino during the coding retreat, it's been decided, that no color customization is needed here.

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 1a1ad0b):

https://si-admin-staging--pr1009-implement-glowing-cu-5itsz7qr.web.app

(expires Fri, 31 Jan 2025 14:52:40 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)

ssandino and others added 8 commits January 14, 2025 21:22
…-effect-wip-fix' into sandino/implement-glowing-cursor-effect-wip-fix

# Conflicts:
#	ui/src/components/use-glow-hover/glow-hover-effect.ts
…-effect-wip-fix' into sandino/implement-glowing-cursor-effect-wip-fix
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: 1

🔭 Outside diff range comments (1)
website/src/components/newsletter-popup/newsletter-popup-client.tsx (1)

Line range hint 31-59: Remove duplicated form logic.

The form schema and API call logic are duplicated from NewsletterForm component:

-const api = useApi();
-const formSchema = z.object({ email: z.string().email() });
-type FormSchema = z.infer<typeof formSchema>;
-const form = useForm<FormSchema>({
-  resolver: zodResolver(formSchema),
-  defaultValues: { email: '' },
-});

-const onSubmit = async (values: FormSchema) => {
-  const body: CreateNewsletterSubscription = {
-    email: values.email,
-    language: lang === 'de' ? 'de' : 'en',
-  };
-  api.post('/api/newsletter/subscription/public', body).then((response) => {
-    if (response.status === 200) {
-      toast.dismiss(t.id);
-      toast.success(translations.toastSuccess);
-    } else {
-      toast.error(translations.toastFailure);
-    }
-  });
-};
♻️ Duplicate comments (1)
website/src/components/newsletter-form/newsletter-form.tsx (1)

20-33: 🛠️ Refactor suggestion

Improve error handling and use async/await consistently.

The API call error handling can be improved:

 const onSubmit = async (values: FormSchema) => {
   const body: CreateNewsletterSubscription = {
     email: values.email,
     language: lang === 'de' ? 'de' : 'en',
   };
-  api.post('/api/newsletter/subscription/public', body).then((response) => {
-    if (response.status === 200) {
+  try {
+    const response = await api.post('/api/newsletter/subscription/public', body);
+    if (response.status === 200) {
       toast.dismiss(t.id);
       toast.success(translations.toastSuccess);
-    } else {
-      toast.error(translations.toastFailure);
-    }
-  });
+    } else {
+      toast.error(translations.toastFailure);
+    }
+  } catch (error) {
+    toast.error(translations.toastFailure);
+  }
 };
🧹 Nitpick comments (3)
website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (1)

10-19: Simplify nested flex containers.

The nested flex containers can be simplified:

-<div className="flex flex-col items-center py-12">
-  <div className="align-center flex flex-col">
+<div className="flex flex-col items-center gap-8 py-12">
    <Typography size="2xl" color="foreground" weight="medium">
      {title}
    </Typography>
-  </div>
-  <div className="mt-8 flex w-full justify-center sm:w-full md:max-w-md">
+  <div className="flex w-full justify-center md:max-w-md">
website/src/components/newsletter-form/newsletter-form.tsx (1)

23-23: Make language fallback logic more explicit.

Consider using a more explicit language fallback:

-language: lang === 'de' ? 'de' : 'en',
+language: ['de'].includes(lang) ? lang : 'en',
website/src/components/newsletter-popup/newsletter-popup-client.tsx (1)

Line range hint 78-78: Extract cookie consent check to a custom hook.

Consider moving the cookie consent logic to a reusable hook:

function useCookieConsent() {
  return localStorage.getItem('cookie_consent') !== null;
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a1ad0b and ff3cb17.

📒 Files selected for processing (5)
  • ui/src/components/card.tsx (1 hunks)
  • website/src/app/[lang]/[region]/(website)/campaign/[campaign]/page.tsx (3 hunks)
  • website/src/components/newsletter-form/newsletter-form.tsx (1 hunks)
  • website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (1 hunks)
  • website/src/components/newsletter-popup/newsletter-popup-client.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/src/components/card.tsx
  • website/src/app/[lang]/[region]/(website)/campaign/[campaign]/page.tsx
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test website
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)


import NewsletterForm from '@/components/newsletter-form/newsletter-form';

const NewsletterGlowContainer = ({ title, lang, formTranslations }) => {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add TypeScript interface for component props.

Define prop types for type safety:

+interface NewsletterGlowContainerProps {
+  title: string;
+  lang: 'en' | 'de';
+  formTranslations: {
+    toastSuccess: string;
+    toastFailure: string;
+    emailPlaceholder: string;
+    buttonAddSubscriber: string;
+  };
+}

-const NewsletterGlowContainer = ({ title, lang, formTranslations }) => {
+const NewsletterGlowContainer = ({ title, lang, formTranslations }: NewsletterGlowContainerProps) => {
📝 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
const NewsletterGlowContainer = ({ title, lang, formTranslations }) => {
interface NewsletterGlowContainerProps {
title: string;
lang: 'en' | 'de';
formTranslations: {
toastSuccess: string;
toastFailure: string;
emailPlaceholder: string;
buttonAddSubscriber: string;
};
}
const NewsletterGlowContainer = ({ title, lang, formTranslations }: NewsletterGlowContainerProps) => {

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: 1

🔭 Outside diff range comments (1)
website/src/components/newsletter-popup/newsletter-popup-client.tsx (1)

Line range hint 31-40: Remove duplicated form logic.

The form schema and submission logic are duplicated between this file and NewsletterForm component.

Consider moving the shared logic to a separate hook:

// hooks/useNewsletterSubscription.ts
export const useNewsletterSubscription = (lang: LanguageCode) => {
  const api = useApi();
  const formSchema = z.object({ email: z.string().email() });
  
  const subscribe = async (email: string) => {
    const body: CreateNewsletterSubscription = {
      email,
      language: lang === 'de' ? 'de' : 'en',
    };
    return api.post('/api/newsletter/subscription/public', body);
  };
  
  return { formSchema, subscribe };
};
♻️ Duplicate comments (1)
website/src/components/newsletter-form/newsletter-form.tsx (1)

32-40: 🛠️ Refactor suggestion

Improve error handling and use async/await consistently.

The current implementation:

  1. Doesn't handle network errors
  2. Mixes Promise chains with async/await
-    api.post('/api/newsletter/subscription/public', body).then((response) => {
-      if (response.status === 200) {
-        toast.dismiss(t.id);
-        toast.success(translations.toastSuccess);
-      } else {
-        toast.error(translations.toastFailure);
-      }
-    });
+    try {
+      const response = await api.post('/api/newsletter/subscription/public', body);
+      if (response.status === 200) {
+        toast.dismiss(t.id);
+        toast.success(translations.toastSuccess);
+      } else {
+        toast.error(translations.toastFailure);
+      }
+    } catch (error) {
+      toast.error(translations.toastFailure);
+    }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ff3cb17 and 53813b8.

📒 Files selected for processing (2)
  • website/src/components/newsletter-form/newsletter-form.tsx (1 hunks)
  • website/src/components/newsletter-popup/newsletter-popup-client.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test website
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (4)
website/src/components/newsletter-form/newsletter-form.tsx (2)

42-66: Well-structured form implementation.

Good implementation with:

  • Proper form validation
  • Responsive layout
  • Accessible form controls

18-18: ⚠️ Potential issue

Add type annotation to component props.

The component should use the defined NewsletterForm type.

-const NewsletterForm = ({ lang, translations }) => {
+const NewsletterForm = ({ lang, translations, t }: NewsletterForm) => {

Likely invalid or redundant comment.

website/src/components/newsletter-popup/newsletter-popup-client.tsx (2)

Line range hint 17-26: Well-defined type exports and definitions.

The type definitions are complete and properly exported.


65-65: Correct integration of NewsletterForm component.

All required props are properly passed to the NewsletterForm component.

Comment on lines 13 to 16
type NewsletterForm = {
lang: LanguageCode;
translations: NewsletterPopupTranslations
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing type definition for toast prop.

The type definition is missing the t: Toast property which is used in the component.

 type NewsletterForm = {
   lang: LanguageCode;
   translations: NewsletterPopupTranslations;
+  t: Toast;
 };
📝 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
type NewsletterForm = {
lang: LanguageCode;
translations: NewsletterPopupTranslations
};
type NewsletterForm = {
lang: LanguageCode;
translations: NewsletterPopupTranslations;
t: Toast;
};

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: 1

♻️ Duplicate comments (3)
website/src/components/newsletter-form/newsletter-form.tsx (3)

13-16: ⚠️ Potential issue

Add missing type definition for toast prop.

The type definition is missing the t prop which is used in line 34.

 type NewsletterForm = {
   lang: LanguageCode;
   translations: NewsletterPopupTranslations;
+  t: Toast;
 };

18-25: ⚠️ Potential issue

Add type safety to component props.

The component props are not properly typed, which could lead to runtime errors.

-const NewsletterForm = ({ lang, translations }) => {
+const NewsletterForm = ({ lang, translations, t }: NewsletterForm) => {

27-40: 🛠️ Refactor suggestion

Improve error handling with async/await.

The current implementation mixes async/await with .then() and lacks proper error handling.

   const onSubmit = async (values: FormSchema) => {
     const body: CreateNewsletterSubscription = {
       email: values.email,
       language: lang === 'de' ? 'de' : 'en',
     };
-    api.post('/api/newsletter/subscription/public', body).then((response) => {
-      if (response.status === 200) {
-        toast.dismiss(t.id);
-        toast.success(translations.toastSuccess);
-      } else {
-        toast.error(translations.toastFailure);
-      }
-    });
+    try {
+      const response = await api.post('/api/newsletter/subscription/public', body);
+      if (response.status === 200) {
+        toast.dismiss(t.id);
+        toast.success(translations.toastSuccess);
+      } else {
+        toast.error(translations.toastFailure);
+      }
+    } catch (error) {
+      toast.error(translations.toastFailure);
+    }
   };
🧹 Nitpick comments (1)
website/src/components/newsletter-form/newsletter-form.tsx (1)

42-65: Add aria-label for better accessibility.

The form lacks proper accessibility attributes.

 <form
   className="flex w-full flex-col items-center justify-center gap-2 sm:flex-row"
   onSubmit={form.handleSubmit(onSubmit)}
+  aria-label="Newsletter subscription form"
 >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 53813b8 and 45958cb.

📒 Files selected for processing (1)
  • website/src/components/newsletter-form/newsletter-form.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test website

Comment on lines +29 to +31
email: values.email,
language: lang === 'de' ? 'de' : 'en',
};
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

The newsletter form should support all five language codes: 'en', 'de', 'it', 'fr', and 'kri'

The current implementation only handles 'de' and defaults everything else to 'en', ignoring three supported languages.

🔗 Analysis chain

Consider supporting all available languages.

The language selection is hardcoded to only support 'de' and 'en', while the LanguageCode type might support more languages.

Let's verify the available language codes:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find all language codes defined in the project
rg -g '*.ts' -g '*.tsx' "type LanguageCode" -A 5

Length of output: 139


Script:

#!/bin/bash
# Find LANGUAGE_CODES constant definition
rg -g '*.ts' -g '*.tsx' "LANGUAGE_CODES.*=" -A 2

Length of output: 460

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: 0

🧹 Nitpick comments (1)
website/src/components/newsletter-form/newsletter-form.tsx (1)

45-68: Enhance form accessibility.

Add aria-label to the form for better screen reader support.

 <form
   className="flex w-full flex-col items-center justify-center gap-2 sm:flex-row"
+  aria-label="Newsletter subscription form"
   onSubmit={form.handleSubmit(onSubmit)}
 >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d79d76c and c115353.

📒 Files selected for processing (2)
  • website/src/components/newsletter-form/newsletter-form.tsx (1 hunks)
  • website/src/components/newsletter-popup/newsletter-popup-client.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (4)
website/src/components/newsletter-popup/newsletter-popup-client.tsx (2)

3-3: LGTM! Good separation of concerns.

The form logic has been cleanly extracted to a dedicated NewsletterForm component.

Also applies to: 37-37


Line range hint 12-17: LGTM! Type export enables reuse.

Making NewsletterPopupTranslations exportable allows proper type sharing across components.

website/src/components/newsletter-form/newsletter-form.tsx (2)

13-17: ⚠️ Potential issue

Add proper type for Toast prop.

The Toast prop is marked optional but used without null checks on line 35.

 type NewsletterForm = {
   lang: LanguageCode;
-  t?: Toast;
+  t: Toast;
   translations: NewsletterPopupTranslations;
 };

Likely invalid or redundant comment.


28-43: 🛠️ Refactor suggestion

Improve error handling and language support.

Three issues need attention:

  1. Language handling is limited to 'de' and 'en'
  2. Mixed usage of async/await with .then()
  3. Missing error catch block
 const onSubmit = async (values: FormSchema) => {
   const body: CreateNewsletterSubscription = {
     email: values.email,
-    language: lang === 'de' ? 'de' : 'en',
+    language: lang,
   };
-  api.post('/api/newsletter/subscription/public', body).then((response) => {
-    if (response.status === 200) {
-      if (t.id) {
-        toast.dismiss(t.id);
-      }
-      toast.success(translations.toastSuccess);
-    } else {
+  try {
+    const response = await api.post('/api/newsletter/subscription/public', body);
+    if (response.status === 200) {
+      toast.dismiss(t.id);
+      toast.success(translations.toastSuccess);
+    } else {
       toast.error(translations.toastFailure);
     }
-  });
+  } catch (error) {
+    toast.error(translations.toastFailure);
+  }
 };

Likely invalid or redundant comment.

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: 0

🧹 Nitpick comments (1)
website/src/components/newsletter-form/newsletter-form.tsx (1)

13-17: Add specific type for translations object.

Define exact shape of required translation strings for better type safety.

+type NewsletterTranslations = {
+  toastSuccess: string;
+  toastFailure: string;
+  emailPlaceholder: string;
+  buttonAddSubscriber: string;
+};

 type NewsletterForm = {
   lang: LanguageCode;
   t?: Toast;
-  translations: NewsletterPopupTranslations;
+  translations: NewsletterTranslations;
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c115353 and 6b777e7.

📒 Files selected for processing (1)
  • website/src/components/newsletter-form/newsletter-form.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
website/src/components/newsletter-form/newsletter-form.tsx

[error] 35-35: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test website
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (4)
website/src/components/newsletter-form/newsletter-form.tsx (4)

19-26: Clean form setup with proper validation.

Good use of zod schema and react-hook-form configuration.


30-32: Support all available language codes.

The language selection only handles 'de' and defaults to 'en', ignoring other supported languages.


33-42: Simplify error handling with async/await and optional chaining.

The promise chain and nested conditionals can be simplified.

-    api.post('/api/newsletter/subscription/public', body).then((response) => {
-      if (response.status === 200) {
-        if (t && t.id) {
-          toast.dismiss(t.id);
-        }
-        toast.success(translations.toastSuccess);
-      } else {
-        toast.error(translations.toastFailure);
-      }
-    });
+    try {
+      const response = await api.post('/api/newsletter/subscription/public', body);
+      t?.id && toast.dismiss(t.id);
+      response.status === 200
+        ? toast.success(translations.toastSuccess)
+        : toast.error(translations.toastFailure);
+    } catch {
+      toast.error(translations.toastFailure);
+    }
🧰 Tools
🪛 Biome (1.9.4)

[error] 35-35: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


45-68: Well-structured form layout with proper responsiveness.

Clean implementation using FormField components and responsive styling.

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: 1

🧹 Nitpick comments (1)
website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (1)

18-27: Consider extracting newsletter form section to a separate component.

The nested structure with multiple divs could be simplified by extracting the newsletter form section into a separate component.

+const NewsletterFormSection = ({ lang, translations }: { lang: LanguageCode; translations: NewsletterPopupTranslations }) => (
+  <div className="mt-8 flex w-full justify-center sm:w-full md:max-w-md">
+    <NewsletterForm lang={lang} translations={translations} />
+  </div>
+);

 const NewsletterGlowContainer = ({ title, lang, formTranslations }: NewsletterGlowContainerProps) => {
   return (
     <GlowHoverContainer>
       <div className="flex flex-col items-center py-12">
         <div className="align-center flex flex-col">
           <Typography size="2xl" color="foreground" weight="medium">
             {title}
           </Typography>
         </div>
-        <div className="mt-8 flex w-full justify-center sm:w-full md:max-w-md">
-          <NewsletterForm lang={lang} translations={formTranslations} />
-        </div>
+        <NewsletterFormSection lang={lang} translations={formTranslations} />
       </div>
     </GlowHoverContainer>
   );
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6b777e7 and 723b102.

📒 Files selected for processing (1)
  • website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
website/src/components/newsletter-glow-container/newsletter-glow-container.tsx

[error] 9-9: Shouldn't redeclare 'NewsletterForm'. Consider to delete it or rename it.

'NewsletterForm' is defined here:

(lint/suspicious/noRedeclare)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test website
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (2)
website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (2)

15-15: ⚠️ Potential issue

Update component props type reference.

Update the component definition to use the renamed type.

-const NewsletterGlowContainer = ({ title, lang, formTranslations }: NewsletterForm) => {
+const NewsletterGlowContainer = ({ title, lang, formTranslations }: NewsletterGlowContainerProps) => {

Likely invalid or redundant comment.


17-28: Verify GlowHoverContainer implementation.

The component uses GlowHoverContainer from @socialincome/ui. Let's verify its implementation and usage across the codebase.

✅ Verification successful

GlowHoverContainer implementation is correct

The component is properly implemented and correctly used in the newsletter container. The component chain (GlowHoverContainer → BaseContainer) and all dependencies are well-structured and type-safe.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify GlowHoverContainer implementation and usage

# Check GlowHoverContainer implementation
echo "Checking GlowHoverContainer implementation..."
ast-grep --pattern 'export const GlowHoverContainer = ({ children }) => {
  $$$
}'

# Check other usages of GlowHoverContainer
echo "Checking GlowHoverContainer usages..."
rg -l "GlowHoverContainer"

Length of output: 430


Script:

#!/bin/bash
# Check the implementation details
echo "=== GlowHoverContainer Implementation ==="
cat ui/src/components/containers/glow-hover-container.tsx

# Check for any prop type definitions
echo -e "\n=== Prop Types ==="
ast-grep --pattern 'interface $_ {
  $$$
}'  ui/src/components/containers/glow-hover-container.tsx

Length of output: 937


Script:

#!/bin/bash
# Check BaseContainer implementation and props
echo "=== BaseContainer Implementation ==="
cat ui/src/components/containers/base-container.tsx

echo -e "\n=== useGlowHover Hook Implementation ==="
cat ui/src/components/use-glow-hover.tsx

Length of output: 1024


Script:

#!/bin/bash
# Search for useGlowHover hook implementation
echo "=== Searching for useGlowHover hook ==="
fd -e ts -e tsx | xargs rg "export.*useGlowHover"

Length of output: 372

Comment on lines 9 to 13
type NewsletterForm = {
title: string;
lang: LanguageCode;
formTranslations: NewsletterPopupTranslations;
};
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Rename type to avoid naming conflict.

The type NewsletterForm conflicts with the imported component of the same name. Rename it to be more specific.

-type NewsletterForm = {
+type NewsletterGlowContainerProps = {
   title: string;
   lang: LanguageCode;
   formTranslations: NewsletterPopupTranslations;
 };
📝 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
type NewsletterForm = {
title: string;
lang: LanguageCode;
formTranslations: NewsletterPopupTranslations;
};
type NewsletterGlowContainerProps = {
title: string;
lang: LanguageCode;
formTranslations: NewsletterPopupTranslations;
};
🧰 Tools
🪛 Biome (1.9.4)

[error] 9-9: Shouldn't redeclare 'NewsletterForm'. Consider to delete it or rename it.

'NewsletterForm' is defined here:

(lint/suspicious/noRedeclare)

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: 0

🧹 Nitpick comments (2)
website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (1)

18-23: Simplify nested div structure.

The nested divs with flex and alignment can be consolidated.

-			<div className="flex flex-col items-center py-12">
-				<div className="align-center flex flex-col">
-					<Typography size="2xl" color="foreground" weight="medium">
-						{title}
-					</Typography>
-				</div>
+			<div className="flex flex-col items-center py-12">
+				<Typography size="2xl" color="foreground" weight="medium" className="text-center">
+					{title}
+				</Typography>
website/src/components/newsletter-form/newsletter-form.tsx (1)

35-37: Use optional chaining.

Replace nested condition with optional chaining operator.

-				if (t && t.id) {
-					toast.dismiss(t.id);
-				}
+				t?.id && toast.dismiss(t.id);
🧰 Tools
🪛 Biome (1.9.4)

[error] 35-35: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 723b102 and 1d68453.

📒 Files selected for processing (2)
  • website/src/components/newsletter-form/newsletter-form.tsx (1 hunks)
  • website/src/components/newsletter-glow-container/newsletter-glow-container.tsx (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
website/src/components/newsletter-form/newsletter-form.tsx

[error] 35-35: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (2)
website/src/components/newsletter-form/newsletter-form.tsx (2)

30-32: ⚠️ Potential issue

Support all available language codes.

The language selection is overly simplified and doesn't support all available languages.

-			language: lang === 'de' ? 'de' : 'en',
+			language: lang,

Likely invalid or redundant comment.


33-43: 🛠️ Refactor suggestion

Improve error handling with async/await.

Convert Promise chain to async/await for better error handling.

-		api.post('/api/newsletter/subscription/public', body).then((response) => {
-			if (response.status === 200) {
-				if (t && t.id) {
-					toast.dismiss(t.id);
-				}
-				toast.success(translations.toastSuccess);
-			} else {
-				toast.error(translations.toastFailure);
-			}
-		});
+		try {
+			const response = await api.post('/api/newsletter/subscription/public', body);
+			if (response.status === 200) {
+				t?.id && toast.dismiss(t.id);
+				toast.success(translations.toastSuccess);
+			} else {
+				toast.error(translations.toastFailure);
+			}
+		} catch (error) {
+			toast.error(translations.toastFailure);
+		}

Likely invalid or redundant comment.

🧰 Tools
🪛 Biome (1.9.4)

[error] 35-35: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

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