Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
IPogorelova authored and actions-user committed Jan 24, 2025
1 parent 30208ea commit 1a1ad0b
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 92 deletions.
7 changes: 2 additions & 5 deletions ui/src/components/card.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import * as React from 'react';

import { cn } from '../lib/utils';
import {useGlowHover} from "./use-glow-hover";

const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => {
/* const refButton = useGlowHover({
/* const refButton = useGlowHover({
preset: 'bright-red',
lightSize: 60,
enableBurst: true
});*/

return (
<div ref={ref} className={cn('bg-card text-card-foreground rounded-lg border-2', className)} {...props} />
)
return <div ref={ref} className={cn('bg-card text-card-foreground rounded-lg border-2', className)} {...props} />;
});
Card.displayName = 'Card';

Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/containers/base-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { twMerge } from 'tailwind-merge';
export type BaseContainerProps = {
wrapperClassName?: string;
wrapperRef?: React.Ref<HTMLDivElement>;
baseClassNames?: string;
baseClassNames?: string;
} & React.HTMLAttributes<HTMLDivElement>;

export const BaseContainer = React.forwardRef<HTMLDivElement, BaseContainerProps>(
Expand Down
32 changes: 16 additions & 16 deletions ui/src/components/containers/glow-hover-container.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'use client';

import React from "react";
import {useGlowHover} from "../use-glow-hover";
import {twMerge} from "tailwind-merge";
import {BaseContainer} from "./base-container";
import React from 'react';
import { twMerge } from 'tailwind-merge';
import { useGlowHover } from '../use-glow-hover';
import { BaseContainer } from './base-container';

import { BaseContainerProps } from './base-container';

export const GlowHoverContainer = React.forwardRef<HTMLDivElement, Omit<BaseContainerProps, 'wrapperRef'>>(
({ className, ...props }, ref) => {
const refCard = useGlowHover({ lightColor: '#CEFF00' });
({ className, ...props }, ref) => {
const refCard = useGlowHover({ lightColor: '#CEFF00' });

return (
<BaseContainer
wrapperClassName={twMerge('theme-blue', className)}
ref={ref}
{...props}
wrapperRef={refCard as React.Ref<HTMLDivElement>}
/>
);
},
);
return (
<BaseContainer
wrapperClassName={twMerge('theme-blue', className)}
ref={ref}
{...props}
wrapperRef={refCard as React.Ref<HTMLDivElement>}
/>
);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export async function Approach({ lang }: DefaultParams) {
</Typography>
<div className="mx-auto flex w-full max-w-7xl flex-wrap gap-2">
{cards.map((card) => (
<Card hasGlowHover key={card.title} className="theme-blue mx-auto min-w-80 max-w-md flex-1 rounded-none border-none">
<Card
hasGlowHover
key={card.title}
className="theme-blue mx-auto min-w-80 max-w-md flex-1 rounded-none border-none"
>
<CardHeader className="mb-1">
<Typography size="md" className="opacity-40">
{card.category}
Expand Down
99 changes: 52 additions & 47 deletions website/src/components/newsletter-form/newsletter-form.tsx
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
'use client'
'use client';

import {useApi} from '@/hooks/useApi';
import * as z from 'zod';
import {useForm} from 'react-hook-form';
import {zodResolver} from '@hookform/resolvers/zod';
import {CreateNewsletterSubscription} from '@/app/api/newsletter/subscription/public/route';
import { CreateNewsletterSubscription } from '@/app/api/newsletter/subscription/public/route';
import { useApi } from '@/hooks/useApi';
import { zodResolver } from '@hookform/resolvers/zod';
import { Button, Form, FormControl, FormField, FormItem, FormMessage, Input } from '@socialincome/ui';
import { useForm } from 'react-hook-form';
import toast from 'react-hot-toast';
import {Button, Form, FormControl, FormField, FormItem, FormMessage, Input} from '@socialincome/ui';
import * as z from 'zod';

const NewsletterForm = ({ lang, t, translations }) => {
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 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);
}
});
};
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);
}
});
};

return (
<Form {...form}>
<form className="flex gap-2 flex-col sm:flex-row justify-center w-full items-center" onSubmit={form.handleSubmit(onSubmit)}>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem className="flex-1 max-w-full sm:max-w-96 w-full">
<FormControl>
<Input type="email" placeholder={translations.emailPlaceholder} {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit" className="w-full sm:w-full sm:max-w-[10rem]">{translations.buttonAddSubscriber}</Button>
</form>
</Form>
);
return (
<Form {...form}>
<form
className="flex w-full flex-col items-center justify-center gap-2 sm:flex-row"
onSubmit={form.handleSubmit(onSubmit)}
>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem className="w-full max-w-full flex-1 sm:max-w-96">
<FormControl>
<Input type="email" placeholder={translations.emailPlaceholder} {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit" className="w-full sm:w-full sm:max-w-[10rem]">
{translations.buttonAddSubscriber}
</Button>
</form>
</Form>
);
};

export default NewsletterForm;
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
'use client'
'use client';

import {
GlowHoverContainer,
Typography
} from "@socialincome/ui";
import { GlowHoverContainer, Typography } from '@socialincome/ui';

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

const NewsletterGlowContainer = ({ title, formTranslations }) => {

return (
<GlowHoverContainer>
<div className="flex flex-col items-center py-12">
<div className="flex flex-col align-center">
<Typography size="2xl" color="foreground" weight="medium">
{title}
</Typography>
</div>
<div className="flex sm:w-full md:max-w-md w-full justify-center mt-8">
<NewsletterForm translations={formTranslations} />
</div>
</div>
</GlowHoverContainer>
);
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 translations={formTranslations} />
</div>
</div>
</GlowHoverContainer>
);
};

export default NewsletterGlowContainer;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { CreateNewsletterSubscription } from '@/app/api/newsletter/subscription/public/route';
import NewsletterForm from '@/components/newsletter-form/newsletter-form';
import { NewsletterPopupProps } from '@/components/newsletter-popup/newsletter-popup';
import { useApi } from '@/hooks/useApi';
import { XMarkIcon } from '@heroicons/react/24/solid';
Expand All @@ -12,7 +13,6 @@ import { useEffect } from 'react';
import { useForm } from 'react-hook-form';
import toast, { Toast } from 'react-hot-toast';
import * as z from 'zod';
import NewsletterForm from '@/components/newsletter-form/newsletter-form';

type NewsletterPopupTranslations = {
informationLabel: string;
Expand Down

0 comments on commit 1a1ad0b

Please sign in to comment.