Skip to content

Commit

Permalink
fix(layout): resolve duplicated layout issue and remove redundant wra…
Browse files Browse the repository at this point in the history
…pper
  • Loading branch information
Favvie authored and Luluameh committed Jan 29, 2025
1 parent c40aff3 commit dde0087
Show file tree
Hide file tree
Showing 16 changed files with 420 additions and 259 deletions.
5 changes: 2 additions & 3 deletions apps/web/app/(routes)/project/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use client'

import type React from 'react'
import TabNavigation from '~/components/base/tab-navigation'
import ProjectOverview from '~/components/sections/project/project-overview'
import ProjectShowcaseSection from '~/components/sections/project/project-showcase'
import ProjectUpdatesSection from '~/components/sections/project/project-updates'
import YourImpactSection from '~/components/sections/project/your-impact'
import TabNavigation from '~/components/base/tab-navigation';
import { projectTabsData } from '~/lib/constants/mock-data/mock-projects'

const TAB_COMPONENTS = {
Expand All @@ -18,8 +18,7 @@ const TAB_COMPONENTS = {
const ProjectDetailsPage = () => {
const tabs = projectTabsData.map((tab) => {
const Component = TAB_COMPONENTS[tab.id as keyof typeof TAB_COMPONENTS]
const contentComponent = Component ? <Component /> : null

const contentComponent = Component ? <Component key={tab.id} /> : null
return {
...tab,
content: contentComponent,
Expand Down
30 changes: 23 additions & 7 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { ThemeProvider } from 'next-themes'
import { GoogleAnalytics } from '~/components/shared/google-analytics'
import RootLayoutWrapper from '~/components/shared/layout/layout-helpers/root-layout-wrapper'
import { Providers } from '~/components/shared/layout/providers'
import { AuthProvider } from '~/hooks/use-auth'
import './css/globals.css'
import Footer from '~/components/shared/layout/footer/footer'
import { Header } from '~/components/shared/layout/header/header'

const defaultUrl = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
Expand All @@ -14,6 +16,14 @@ export const metadata = {
'The first Web3 platform connecting supporters to impactful causes while driving blockchain adoption for social and environmental change',
}

const ProviderWrapper = ({ children }: { children: React.ReactNode }) => {
return (
<AuthProvider>
<ThemeProvider>{children}</ThemeProvider>
</AuthProvider>
)
}

export default function RootLayout({
children,
}: {
Expand All @@ -22,11 +32,17 @@ export default function RootLayout({
return (
<html lang="en" suppressHydrationWarning>
<head />
<body>
<Providers>
<RootLayoutWrapper>{children}</RootLayoutWrapper>
</Providers>
<GoogleAnalytics GA_MEASUREMENT_ID="G-52DWMZ7R1H" />
<body suppressHydrationWarning>
<ProviderWrapper>
<div className="relative min-h-screen flex flex-col">
<Header />
<main className="flex-1">{children}</main>
<Footer />
</div>
</ProviderWrapper>
<GoogleAnalytics
GA_MEASUREMENT_ID={process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID || ''}
/>{' '}
</body>
</html>
)
Expand Down
230 changes: 115 additions & 115 deletions apps/web/components/base/alert-dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,147 +1,147 @@
"use client";
'use client'

import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import * as React from "react";
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
import * as React from 'react'

import { buttonVariants } from "~/components/base/button";
import { cn } from "~/lib/utils";
import { buttonVariants } from '~/components/base/button'
import { cn } from '~/lib/utils'

const AlertDialog = AlertDialogPrimitive.Root;
const AlertDialog = AlertDialogPrimitive.Root

const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
const AlertDialogTrigger = AlertDialogPrimitive.Trigger

const AlertDialogPortal = AlertDialogPrimitive.Portal;
const AlertDialogPortal = AlertDialogPrimitive.Portal

const AlertDialogOverlay = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Overlay
className={cn(
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
className
)}
{...props}
ref={ref}
/>
));
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
<AlertDialogPrimitive.Overlay
className={cn(
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className,
)}
{...props}
ref={ref}
/>
))
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName

const AlertDialogContent = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
React.ElementRef<typeof AlertDialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
>(({ className, ...props }, ref) => (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
aria-live="assertive"
aria-atomic="true"
role="alertdialog"
aria-modal="true"
aria-describedby={props["aria-describedby"] || "alert-dialog-desc"}
className={cn(
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
className
)}
{...props}
/>
</AlertDialogPortal>
));
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Content
ref={ref}
aria-live="assertive"
aria-atomic="true"
role="alertdialog"
aria-modal="true"
aria-describedby={props['aria-describedby'] || 'alert-dialog-desc'}
className={cn(
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
className,
)}
{...props}
/>
</AlertDialogPortal>
))
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName

const AlertDialogHeader = ({
className,
...props
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col space-y-2 text-center sm:text-left",
className
)}
{...props}
/>
);
AlertDialogHeader.displayName = "AlertDialogHeader";
<div
className={cn(
'flex flex-col space-y-2 text-center sm:text-left',
className,
)}
{...props}
/>
)
AlertDialogHeader.displayName = 'AlertDialogHeader'

const AlertDialogFooter = ({
className,
...props
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
className
)}
{...props}
/>
);
AlertDialogFooter.displayName = "AlertDialogFooter";
<div
className={cn(
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
className,
)}
{...props}
/>
)
AlertDialogFooter.displayName = 'AlertDialogFooter'

const AlertDialogTitle = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
React.ElementRef<typeof AlertDialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Title
ref={ref}
className={cn("text-lg font-semibold", className)}
{...props}
/>
));
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
<AlertDialogPrimitive.Title
ref={ref}
className={cn('text-lg font-semibold', className)}
{...props}
/>
))
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName

const AlertDialogDescription = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
React.ElementRef<typeof AlertDialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Description
ref={ref}
id={props.id || "alert-dialog-desc"}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
<AlertDialogPrimitive.Description
ref={ref}
id={props.id || 'alert-dialog-desc'}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
))
AlertDialogDescription.displayName =
AlertDialogPrimitive.Description.displayName;
AlertDialogPrimitive.Description.displayName

const AlertDialogAction = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
React.ElementRef<typeof AlertDialogPrimitive.Action>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Action
ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>
));
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
<AlertDialogPrimitive.Action
ref={ref}
className={cn(buttonVariants(), className)}
{...props}
/>
))
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName

const AlertDialogCancel = React.forwardRef<
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
>(({ className, ...props }, ref) => (
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(
buttonVariants({ variant: "outline" }),
"mt-2 sm:mt-0",
className
)}
{...props}
/>
));
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
<AlertDialogPrimitive.Cancel
ref={ref}
className={cn(
buttonVariants({ variant: 'outline' }),
'mt-2 sm:mt-0',
className,
)}
{...props}
/>
))
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName

export {
AlertDialog,
AlertDialogPortal,
AlertDialogOverlay,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
};
AlertDialog,
AlertDialogPortal,
AlertDialogOverlay,
AlertDialogTrigger,
AlertDialogContent,
AlertDialogHeader,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogAction,
AlertDialogCancel,
}
3 changes: 2 additions & 1 deletion apps/web/components/base/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const Image: FC<ImageProps> = ({ src, alt, className, ...props }) => {
>
<img
src={src}
alt={alt}
alt={alt || ''}
aria-hidden={!alt ? 'true' : 'false'}
className="w-full h-full object-cover block m-0 p-0"
loading="lazy"
{...props}
Expand Down
Loading

0 comments on commit dde0087

Please sign in to comment.