feat: Enhance HomePage and SiteList with new UI components and improved loading overlay
This commit is contained in:
@@ -1,28 +1,42 @@
|
||||
'use client'
|
||||
|
||||
import Image from 'next/image'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
|
||||
interface LoadingOverlayProps {
|
||||
logoSrc: string
|
||||
title: string
|
||||
logoSrc?: string
|
||||
title?: string
|
||||
}
|
||||
|
||||
export default function LoadingOverlay({ logoSrc, title }: LoadingOverlayProps) {
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-white/80 dark:bg-neutral-950/80 backdrop-blur-sm">
|
||||
<div className="text-center">
|
||||
<div className="mb-4 flex justify-center">
|
||||
<Image
|
||||
src={logoSrc}
|
||||
alt={title}
|
||||
width={64}
|
||||
height={64}
|
||||
className="animate-pulse"
|
||||
export default function LoadingOverlay({
|
||||
logoSrc = "/ciphera_icon_no_margins.png",
|
||||
title = "Ciphera Analytics"
|
||||
}: LoadingOverlayProps) {
|
||||
const [mounted, setMounted] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true)
|
||||
return () => setMounted(false)
|
||||
}, [])
|
||||
|
||||
if (!mounted) return null
|
||||
|
||||
return createPortal(
|
||||
<div className="fixed inset-0 z-[100] flex items-center justify-center bg-white dark:bg-neutral-950 animate-in fade-in duration-200">
|
||||
<div className="flex flex-col items-center gap-6">
|
||||
<div className="flex items-center gap-3">
|
||||
<img
|
||||
src={logoSrc}
|
||||
alt={title}
|
||||
className="h-12 w-auto object-contain"
|
||||
/>
|
||||
<span className="text-3xl font-bold tracking-tight text-neutral-900 dark:text-white">
|
||||
{title}
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-8 w-8 animate-spin rounded-full border-4 border-neutral-200 border-t-brand-orange mx-auto mb-4"></div>
|
||||
<p className="text-neutral-600 dark:text-neutral-400">Loading...</p>
|
||||
<div className="h-8 w-8 animate-spin rounded-full border-4 border-neutral-200 border-t-brand-orange dark:border-neutral-800 dark:border-t-brand-orange" />
|
||||
</div>
|
||||
</div>
|
||||
</div>,
|
||||
document.body
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import { useRouter } from 'next/navigation'
|
||||
import { listSites, deleteSite, type Site } from '@/lib/api/sites'
|
||||
import { toast } from 'sonner'
|
||||
import LoadingOverlay from '../LoadingOverlay'
|
||||
import { Button } from '@ciphera-net/ui'
|
||||
import { BarChartIcon, TrashIcon, PlusIcon } from '@radix-ui/react-icons'
|
||||
|
||||
export default function SiteList() {
|
||||
const [sites, setSites] = useState<Site[]>([])
|
||||
@@ -50,12 +52,12 @@ export default function SiteList() {
|
||||
return (
|
||||
<div className="text-center py-12">
|
||||
<p className="text-neutral-600 dark:text-neutral-400 mb-4">No sites yet. Create your first site to get started.</p>
|
||||
<button
|
||||
<Button
|
||||
onClick={() => router.push('/sites/new')}
|
||||
className="btn-primary"
|
||||
>
|
||||
<PlusIcon className="w-4 h-4 mr-2" />
|
||||
Create Site
|
||||
</button>
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -74,27 +76,29 @@ export default function SiteList() {
|
||||
{site.domain}
|
||||
</p>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
<Button
|
||||
onClick={() => router.push(`/sites/${site.id}`)}
|
||||
className="btn-primary flex-1 text-sm"
|
||||
className="flex-1 text-sm"
|
||||
>
|
||||
<BarChartIcon className="w-4 h-4 mr-2" />
|
||||
View Dashboard
|
||||
</button>
|
||||
<button
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
onClick={() => handleDelete(site.id)}
|
||||
className="btn-secondary text-sm px-4"
|
||||
className="text-sm px-4"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
<TrashIcon className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
onClick={() => router.push('/sites/new')}
|
||||
className="bg-white dark:bg-neutral-900 border-2 border-dashed border-neutral-300 dark:border-neutral-700 rounded-xl p-6 hover:border-brand-orange transition-colors text-neutral-600 dark:text-neutral-400"
|
||||
className="bg-white dark:bg-neutral-900 border-2 border-dashed border-neutral-300 dark:border-neutral-700 rounded-xl p-6 hover:border-brand-orange transition-colors text-neutral-600 dark:text-neutral-400 w-full h-full min-h-[160px] flex items-center justify-center"
|
||||
>
|
||||
<div className="text-center">
|
||||
<div className="text-2xl mb-2">+</div>
|
||||
<div className="text-2xl mb-2 mx-auto w-8 h-8 rounded-full bg-neutral-100 dark:bg-neutral-800 flex items-center justify-center">+</div>
|
||||
<div>Add New Site</div>
|
||||
</div>
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user