A full-featured CRM built with React, shadcn/ui, and Supabase.
use a portal in header
Jean-Baptiste Kaisercbc1f8c86532
diff --git a/registry.json b/registry.jsonindex 1009e211..a828eaea 100644--- a/registry.json+++ b/registry.json@@ -396,6 +396,10 @@"path": "src/components/atomic-crm/layout/MobileContent.tsx","type": "registry:component"},+ {+ "path": "src/components/atomic-crm/layout/MobileAppBar.tsx",+ "type": "registry:component"+ },{"path": "src/components/atomic-crm/layout/Layout.tsx","type": "registry:component"diff --git a/src/components/atomic-crm/companies/CompanyList.tsx b/src/components/atomic-crm/companies/CompanyList.tsxindex 7e2a8664..459fc024 100644--- a/src/components/atomic-crm/companies/CompanyList.tsx+++ b/src/components/atomic-crm/companies/CompanyList.tsx@@ -6,9 +6,8 @@ import { SortButton } from "@/components/admin/sort-button";import { InfiniteListBase, useGetIdentity, useListContext } from "ra-core";import { useIsMobile } from "@/hooks/use-mobile";-import { MobileContent } from "../layout/MobileContent";-import MobileHeader from "../layout/MobileHeader";import { TopToolbar } from "../layout/TopToolbar";+import { MobileHeader } from "../layout/MobileHeader";import { InfinitePagination } from "../misc/InfinitePagination";import { CompanyEmpty } from "./CompanyEmpty";import { CompanyListFilter } from "./CompanyListFilter";@@ -45,6 +44,9 @@ const CompanyListMobile = () => {return (<InfiniteListBase perPage={25} sort={{ field: "name", order: "ASC" }}><MobileCompanyListLayout />+ <div className="flex justify-center">+ <InfinitePagination />+ </div></InfiniteListBase>);};@@ -76,17 +78,12 @@ const MobileCompanyListLayout = () => {if (!data?.length && !hasFilters) return <CompanyEmpty />;return (- <div>+ <><MobileHeader><CompanyListFilter /></MobileHeader>- <MobileContent><ImageList />- <div className="flex justify-center">- <InfinitePagination />- </div>- </MobileContent>- </div>+ </>);};diff --git a/src/components/atomic-crm/contacts/ContactList.tsx b/src/components/atomic-crm/contacts/ContactList.tsxindex 445c0969..5e747d5e 100644--- a/src/components/atomic-crm/contacts/ContactList.tsx+++ b/src/components/atomic-crm/contacts/ContactList.tsx@@ -21,8 +21,7 @@ import { ContactListFilter } from "./ContactListFilter";import { TopToolbar } from "../layout/TopToolbar";import { useIsMobile } from "@/hooks/use-mobile";import { InfinitePagination } from "../misc/InfinitePagination";-import MobileHeader from "../layout/MobileHeader";-import { MobileContent } from "../layout/MobileContent";+import { MobileHeader } from "../layout/MobileHeader";export const ContactList = () => {const isMobile = useIsMobile();@@ -59,6 +58,9 @@ const ContactListMobile = () => {exporter={exporter}><MobileContactListLayout />+ <div className="flex justify-center">+ <InfinitePagination />+ </div></InfiniteListBase>);};@@ -95,19 +97,14 @@ const MobileContactListLayout = () => {if (!data?.length && !hasFilters) return <ContactEmpty />;return (- <div>+ <><MobileHeader><ContactListFilter /></MobileHeader>- <MobileContent>- <Card className="py-0">- <ContactListContent />- </Card>- <div className="flex justify-center">- <InfinitePagination />- </div>- </MobileContent>- </div>+ <Card className="py-0">+ <ContactListContent />+ </Card>+ </>);};diff --git a/src/components/atomic-crm/dashboard/MobileDashboard.tsx b/src/components/atomic-crm/dashboard/MobileDashboard.tsxindex aec685cb..141e6d0f 100644--- a/src/components/atomic-crm/dashboard/MobileDashboard.tsx+++ b/src/components/atomic-crm/dashboard/MobileDashboard.tsx@@ -1,16 +1,12 @@import { useGetList } from "ra-core";+import { MobileHeader } from "../layout/MobileHeader";import type { Contact, ContactNote } from "../types";import { DashboardActivityLog } from "./DashboardActivityLog";import { DashboardStepper } from "./DashboardStepper";import { Welcome } from "./Welcome";-import MobileHeader from "../layout/MobileHeader";-import { MobileContent } from "../layout/MobileContent";-import { useConfigurationContext } from "../root/ConfigurationContext";export const MobileDashboard = () => {- const { darkModeLogo, lightModeLogo, title } = useConfigurationContext();-const {data: dataContact,total: totalContact,@@ -31,36 +27,30 @@ export const MobileDashboard = () => {}if (!totalContact) {- return <DashboardStepper step={1} />;+ return (+ <>+ <MobileHeader />+ <DashboardStepper step={1} />+ </>+ );}if (!totalContactNotes) {- return <DashboardStepper step={2} contactId={dataContact?.[0]?.id} />;+ return (+ <>+ <MobileHeader />+ <DashboardStepper step={2} contactId={dataContact?.[0]?.id} />+ </>+ );}return (<>- <MobileHeader>- <div className="flex items-center gap-2 text-secondary-foreground no-underline py-3">- <img- className="[.light_&]:hidden h-6"- src={darkModeLogo}- alt={title}- />- <img- className="[.dark_&]:hidden h-6"- src={lightModeLogo}- alt={title}- />- <h1 className="text-xl font-semibold">{title}</h1>- </div>- </MobileHeader>- <MobileContent>- <div className="grid grid-cols-1 md:grid-cols-12 gap-6 mt-1">- {import.meta.env.VITE_IS_DEMO === "true" ? <Welcome /> : null}- <DashboardActivityLog />- </div>- </MobileContent>+ <MobileHeader />+ <div className="grid grid-cols-1 md:grid-cols-12 gap-6 mt-1">+ {import.meta.env.VITE_IS_DEMO === "true" ? <Welcome /> : null}+ <DashboardActivityLog />+ </div></>);};diff --git a/src/components/atomic-crm/layout/MobileAppBar.tsx b/src/components/atomic-crm/layout/MobileAppBar.tsxnew file mode 100644index 00000000..6a71e2ee--- /dev/null+++ b/src/components/atomic-crm/layout/MobileAppBar.tsx@@ -0,0 +1,12 @@+export const MobileAppBar = () => {+ return (+ <header className="fixed top-0 left-0 right-0 z-10 bg-secondary h-14 px-4 w-full flex justify-between items-center">+ <div+ id="atomic-crm-header"+ className="w-full flex justify-between items-center"+ >+ {/* Portal content will be rendered here */}+ </div>+ </header>+ );+};diff --git a/src/components/atomic-crm/layout/MobileHeader.tsx b/src/components/atomic-crm/layout/MobileHeader.tsxindex e300584f..3b414091 100644--- a/src/components/atomic-crm/layout/MobileHeader.tsx+++ b/src/components/atomic-crm/layout/MobileHeader.tsx@@ -1,9 +1,21 @@-const MobileHeader = ({ children }: { children: React.ReactNode }) => {- return (- <header className="fixed top-0 left-0 right-0 z-10 bg-secondary h-14 px-4 w-full flex justify-between items-center">- {children}- </header>+import { type ReactNode } from "react";+import { createPortal } from "react-dom";+import { useConfigurationContext } from "../root/ConfigurationContext";++export const MobileHeader = ({ children }: { children?: ReactNode }) => {+ const { darkModeLogo, lightModeLogo, title } = useConfigurationContext();++ const portalTarget = document.getElementById("atomic-crm-header");++ if (!portalTarget) return null;++ const content = children || (+ <div className="flex items-center gap-2 text-secondary-foreground no-underline py-3">+ <img className="[.light_&]:hidden h-6" src={darkModeLogo} alt={title} />+ <img className="[.dark_&]:hidden h-6" src={lightModeLogo} alt={title} />+ <h1 className="text-xl font-semibold">{title}</h1>+ </div>);-};-export default MobileHeader;+ return createPortal(content, portalTarget);+};diff --git a/src/components/atomic-crm/layout/MobileLayout.tsx b/src/components/atomic-crm/layout/MobileLayout.tsxindex c03ded36..3f9bb2c9 100644--- a/src/components/atomic-crm/layout/MobileLayout.tsx+++ b/src/components/atomic-crm/layout/MobileLayout.tsx@@ -5,14 +5,19 @@ import { Suspense, type ReactNode } from "react";import { ErrorBoundary } from "react-error-boundary";import { MobileNavigation } from "./MobileNavigation";+import { MobileContent } from "./MobileContent";+import { MobileAppBar } from "./MobileAppBar";export const MobileLayout = ({ children }: { children: ReactNode }) => (<>- <ErrorBoundary FallbackComponent={Error}>- <Suspense fallback={<Skeleton className="h-12 w-12 rounded-full" />}>- {children}- </Suspense>- </ErrorBoundary>+ <MobileAppBar />+ <MobileContent>+ <ErrorBoundary FallbackComponent={Error}>+ <Suspense fallback={<Skeleton className="h-12 w-12 rounded-full" />}>+ {children}+ </Suspense>+ </ErrorBoundary>+ </MobileContent><MobileNavigation /><Notification /></>