🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Refactor site layout and sidebar components
Bill Yangd0418d8ff7e4
diff --git a/client/src/app/[site]/components/Sidebar/Sidebar.tsx b/client/src/app/[site]/components/Sidebar/Sidebar.tsxindex 1355a3faa..5c05590f7 100644--- a/client/src/app/[site]/components/Sidebar/Sidebar.tsx+++ b/client/src/app/[site]/components/Sidebar/Sidebar.tsx@@ -43,11 +43,9 @@ export function Sidebar() {return (<div className="w-56 bg-neutral-900 border-r border-neutral-800 h-full flex-col">- {site && (- <div className="p-3 border-b border-neutral-800 flex flex-col gap-2">- <SiteSelector />- </div>- )}+ <div className="p-3 border-b border-neutral-800 flex flex-col gap-2">+ <SiteSelector />+ </div><div className="flex flex-col space-y-1 p-3 "><LiveUserCount /><SidebarLinkdiff --git a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx b/client/src/app/[site]/components/Sidebar/SiteSelector.tsxindex 1af0c5bf8..e286a797a 100644--- a/client/src/app/[site]/components/Sidebar/SiteSelector.tsx+++ b/client/src/app/[site]/components/Sidebar/SiteSelector.tsx@@ -23,29 +23,42 @@ function SiteSelectorContent() {return (<DropdownMenuContent align="start">- {sites?.sites?.map((site) => {- const isSelected = site.siteId === currentSiteId;- return (- <DropdownMenuItem- key={site.siteId}- onClick={() => {- if (isSelected) return;- resetStore();- router.push(`/${site.siteId}`);- }}- className={cn(- "flex items-center justify-between",- isSelected && "bg-neutral-800"- )}- >- <div className="flex items-center gap-2">- <Favicon domain={site.domain} className="w-4 h-4" />- <span>{site.domain}</span>- </div>- {isSelected && <Check size={16} />}- </DropdownMenuItem>- );- })}+ {sites?.sites+ ? sites.sites.map((site) => {+ const isSelected = site.siteId === currentSiteId;+ return (+ <DropdownMenuItem+ key={site.siteId}+ onClick={() => {+ if (isSelected) return;+ resetStore();+ router.push(`/${site.siteId}`);+ }}+ className={cn(+ "flex items-center justify-between",+ isSelected && "bg-neutral-800"+ )}+ >+ <div className="flex items-center gap-2">+ <Favicon domain={site.domain} className="w-4 h-4" />+ <span>{site.domain}</span>+ </div>+ {isSelected && <Check size={16} />}+ </DropdownMenuItem>+ );+ })+ : Array.from({ length: 3 }).map((_, index) => (+ <DropdownMenuItem+ key={`skeleton-${index}`}+ className="flex items-center justify-between animate-pulse cursor-default"+ onClick={(e) => e.preventDefault()}+ >+ <div className="flex items-center gap-2">+ <div className="w-4 h-4 bg-neutral-700 rounded"></div>+ <div className="h-4 bg-neutral-700 rounded w-32"></div>+ </div>+ </DropdownMenuItem>+ ))}</DropdownMenuContent>);}@@ -60,11 +73,16 @@ export function SiteSelector() {return (<DropdownMenu><DropdownMenuTrigger unstyled>- {site && (+ {site ? (<div className="flex gap-2 border border-neutral-800 rounded-lg py-1.5 px-3 justify-start cursor-pointer hover:bg-neutral-800/50 transition-colors h-[36px]"><Favicon domain={site.domain} className="w-5 h-5" /><div className="text-white truncate text-sm">{site.domain}</div></div>+ ) : (+ <div className="flex gap-2 border border-neutral-800 rounded-lg py-1.5 px-3 justify-start items-center h-[36px] animate-pulse">+ <div className="w-5 h-5 bg-neutral-800 rounded"></div>+ <div className="h-4 bg-neutral-800 rounded w-24"></div>+ </div>)}</DropdownMenuTrigger>{user && <SiteSelectorContent />}diff --git a/client/src/app/[site]/layout.tsx b/client/src/app/[site]/layout.tsxindex edb6ec773..5ba0621b4 100644--- a/client/src/app/[site]/layout.tsx+++ b/client/src/app/[site]/layout.tsx@@ -17,10 +17,6 @@ export default function SiteLayout({}) {const pathname = usePathname();const { setSite, site } = useStore();- const { isLoading } = useSiteHasData(site);-- const { data: siteMetadata, isLoading: isLoadingSiteMetadata } =- useGetSite(site);// Sync store state with URL parametersuseSyncStateWithUrl();@@ -33,14 +29,6 @@ export default function SiteLayout({const { width } = useWindowSize();- if (!site) {- return null;- }-- if (isLoadingSiteMetadata || isLoading || !siteMetadata) {- return null;- }-if (width && width < 768) {return (<div>diff --git a/client/src/app/[site]/main/page.tsx b/client/src/app/[site]/main/page.tsxindex ae119b786..224d0e9b9 100644--- a/client/src/app/[site]/main/page.tsx+++ b/client/src/app/[site]/main/page.tsx@@ -22,14 +22,8 @@ export default function MainPage() {}function MainPageContent() {- const { data: siteMetadata, isLoading: isLoadingSiteMetadata } = useGetSite();-useSetPageTitle("Rybbit · Main");- if (isLoadingSiteMetadata || !siteMetadata) {- return null;- }-return (<div className="p-2 md:p-4 max-w-[1100px] mx-auto space-y-3 "><SubHeader />diff --git a/memory-bank/progress.md b/memory-bank/progress.mdindex 15d79dba8..050e9cc35 100644--- a/memory-bank/progress.md+++ b/memory-bank/progress.md@@ -22,3 +22,15 @@ This file tracks the project's progress using a task list format.- Analyze existing codebase for potential improvements- Document architectural patterns and decisions- Support ongoing development and feature implementation++2025-06-01 11:40:32 - Added skeleton loading state to SiteSelector component++- Implemented conditional rendering for loading state when site data is falsy+- Created skeleton with matching dimensions and styling+- Added pulse animation for better UX during data fetching++2025-06-01 11:42:55 - Added skeleton loading state to SiteSelectorContent dropdown items++- Implemented conditional rendering for loading state when sites data is falsy+- Created 3 skeleton dropdown items with matching structure and styling+- Added pulse animation and prevented interactions during loading state