-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a3cbc5
commit 9d428ea
Showing
19 changed files
with
275 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import type {PropsWithChildren, ReactNode} from 'react'; | ||
import {Spinner, cn} from '@elwood/ui'; | ||
|
||
export interface ContentLayoutProps { | ||
headerLeft?: ReactNode; | ||
headerRight?: ReactNode; | ||
mainProps?: React.HTMLProps<HTMLDivElement>; | ||
mainClassName?: string; | ||
rail?: ReactNode; | ||
loading?: boolean; | ||
largeTitle?: ReactNode; | ||
} | ||
|
||
export function ContentLayout( | ||
props: PropsWithChildren<ContentLayoutProps>, | ||
): JSX.Element { | ||
const showHeader = props.headerLeft ?? props.headerRight ?? props.largeTitle; | ||
const headerLeft = props.largeTitle ? ( | ||
<h1 className="text-3xl font-extrabold">{props.largeTitle}</h1> | ||
) : ( | ||
props.headerLeft | ||
); | ||
|
||
const bodyClass = cn( | ||
'flex-grow flex-nowrap overflow-y-auto overflow-x-hidden min-h-0 pb-4', | ||
props.mainClassName, | ||
); | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col min-h-0 h-full w-full"> | ||
{showHeader ? ( | ||
<header className="flex items-center justify-between px-8 pt-4"> | ||
<div>{headerLeft}</div> | ||
<div>{props.headerRight}</div> | ||
</header> | ||
) : null} | ||
<div className="flex-grow flex flex-row flex-nowrap min-h-0 px-8 pt-4"> | ||
<div {...props.mainProps} className={bodyClass}> | ||
{props.children} | ||
{props.loading ? ( | ||
<div className="w-full h-full flex items-center justify-center"> | ||
<Spinner /> | ||
</div> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{props.rail ? ( | ||
<div className="ml-0 w-1/4 min-w-[300px] flex flex-col border rounded m-4"> | ||
{props.rail} | ||
</div> | ||
) : null} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,24 @@ | ||
import type {PropsWithChildren, ReactNode} from 'react'; | ||
import {Spinner, cn} from '@elwood/ui'; | ||
|
||
export interface PageLayoutProps { | ||
headerLeft?: ReactNode; | ||
headerRight?: ReactNode; | ||
mainProps?: React.HTMLProps<HTMLDivElement>; | ||
mainClassName?: string; | ||
rail?: ReactNode; | ||
loading?: boolean; | ||
largeTitle?: ReactNode; | ||
sidebar?: ReactNode; | ||
sidebarFooter?: ReactNode; | ||
} | ||
|
||
export function PageLayout( | ||
props: PropsWithChildren<PageLayoutProps>, | ||
): JSX.Element { | ||
const showHeader = props.headerLeft ?? props.headerRight ?? props.largeTitle; | ||
const headerLeft = props.largeTitle ? ( | ||
<h1 className="text-3xl font-extrabold">{props.largeTitle}</h1> | ||
) : ( | ||
props.headerLeft | ||
); | ||
|
||
const bodyClass = cn( | ||
'flex-grow flex-nowrap overflow-y-auto overflow-x-hidden min-h-0 pb-4', | ||
props.mainClassName, | ||
); | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col min-h-0 h-full w-full"> | ||
{showHeader ? ( | ||
<header className="flex items-center justify-between px-8 pt-4"> | ||
<div>{headerLeft}</div> | ||
<div>{props.headerRight}</div> | ||
</header> | ||
) : null} | ||
<div className="flex-grow flex flex-row flex-nowrap min-h-0 px-8 pt-4"> | ||
<div {...props.mainProps} className={bodyClass}> | ||
{props.children} | ||
{props.loading ? ( | ||
<div className="w-full h-full flex items-center justify-center"> | ||
<Spinner /> | ||
</div> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{props.rail ? ( | ||
<div className="ml-0 w-1/4 min-w-[300px] flex flex-col border rounded m-4"> | ||
{props.rail} | ||
{props.sidebar && ( | ||
<div className="bg-sidebar border-r w-[300px] flex-shrink-0 flex flex-col justify-between"> | ||
<div className="flex-grow overflow-auto px-6">{props.sidebar}</div> | ||
{props.sidebarFooter ? ( | ||
<footer className="flex flex-col">{props.sidebarFooter}</footer> | ||
) : null} | ||
</div> | ||
) : null} | ||
)} | ||
{props.children} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.