-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
develop - changeset - added layout context, prime react, interfaces a…
…nd appbar and footer - v4
- Loading branch information
Umer Farooq
committed
Jul 30, 2024
1 parent
86f4ce3
commit 7505dd6
Showing
23 changed files
with
626 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Button } from 'primereact/button'; | ||
import { Card } from 'primereact/card'; | ||
|
||
export default function Dashboard() { | ||
return ( | ||
<div className="card flex justify-content-center"> | ||
<Button>Add</Button> | ||
|
||
<Card> | ||
<p>Some text</p> | ||
</Card> | ||
</div> | ||
); | ||
} |
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,10 @@ | ||
// Styles | ||
import MainLayout from '@/lib/ui/layouts/main'; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
}>) { | ||
return <MainLayout>{children}</MainLayout>; | ||
} |
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 was deleted.
Oops, something went wrong.
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,78 @@ | ||
'use client'; | ||
import { ILayoutProvider } from '@/lib/utils/interfaces'; | ||
import { | ||
LayoutConfig, | ||
LayoutContextProps, | ||
LayoutState, | ||
} from '@/lib/utils/types'; | ||
import { createContext, useState } from 'react'; | ||
export const LayoutContext = createContext({} as LayoutContextProps); | ||
|
||
export const LayoutProvider = ({ children }: ILayoutProvider) => { | ||
const [layoutConfig, setLayoutConfig] = useState<LayoutConfig>({ | ||
ripple: false, | ||
inputStyle: 'outlined', | ||
menuMode: 'static', | ||
colorScheme: 'light', | ||
theme: 'lara-light-indigo', | ||
scale: 14, | ||
}); | ||
|
||
const [layoutState, setLayoutState] = useState<LayoutState>({ | ||
staticMenuDesktopInactive: false, | ||
overlayMenuActive: false, | ||
profileSidebarVisible: false, | ||
configSidebarVisible: false, | ||
staticMenuMobileActive: false, | ||
menuHoverActive: false, | ||
}); | ||
|
||
const onMenuToggle = () => { | ||
if (isOverlay()) { | ||
setLayoutState((prevLayoutState) => ({ | ||
...prevLayoutState, | ||
overlayMenuActive: !prevLayoutState.overlayMenuActive, | ||
})); | ||
} | ||
|
||
if (isDesktop()) { | ||
setLayoutState((prevLayoutState) => ({ | ||
...prevLayoutState, | ||
staticMenuDesktopInactive: !prevLayoutState.staticMenuDesktopInactive, | ||
})); | ||
} else { | ||
setLayoutState((prevLayoutState) => ({ | ||
...prevLayoutState, | ||
staticMenuMobileActive: !prevLayoutState.staticMenuMobileActive, | ||
})); | ||
} | ||
}; | ||
|
||
const showProfileSidebar = () => { | ||
setLayoutState((prevLayoutState) => ({ | ||
...prevLayoutState, | ||
profileSidebarVisible: !prevLayoutState.profileSidebarVisible, | ||
})); | ||
}; | ||
|
||
const isOverlay = () => { | ||
return layoutConfig.menuMode === 'overlay'; | ||
}; | ||
|
||
const isDesktop = () => { | ||
return window.innerWidth > 991; | ||
}; | ||
|
||
const value: LayoutContextProps = { | ||
layoutConfig, | ||
setLayoutConfig, | ||
layoutState, | ||
setLayoutState, | ||
onMenuToggle, | ||
showProfileSidebar, | ||
}; | ||
|
||
return ( | ||
<LayoutContext.Provider value={value}>{children}</LayoutContext.Provider> | ||
); | ||
}; |
File renamed without changes.
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,79 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
|
||
import { LayoutContext } from '@/lib/context/layout-context'; | ||
import { AppTopbarRef } from '@/lib/utils/types'; | ||
import Link from 'next/link'; | ||
import { classNames } from 'primereact/utils'; | ||
import { forwardRef, useContext, useImperativeHandle, useRef } from 'react'; | ||
|
||
const AppTopbar = forwardRef<AppTopbarRef>((props, ref) => { | ||
const { layoutConfig, layoutState, onMenuToggle, showProfileSidebar } = | ||
useContext(LayoutContext); | ||
const menubuttonRef = useRef(null); | ||
const topbarmenuRef = useRef(null); | ||
const topbarmenubuttonRef = useRef(null); | ||
|
||
useImperativeHandle(ref, () => ({ | ||
menubutton: menubuttonRef.current, | ||
topbarmenu: topbarmenuRef.current, | ||
topbarmenubutton: topbarmenubuttonRef.current, | ||
})); | ||
|
||
return ( | ||
<div className="layout-topbar"> | ||
<Link href="/" className="layout-topbar-logo"> | ||
<img | ||
src={`/layout/images/logo-${layoutConfig.colorScheme !== 'light' ? 'white' : 'dark'}.svg`} | ||
width="47.22px" | ||
height={'35px'} | ||
alt="logo" | ||
/> | ||
<span>SAKAI</span> | ||
</Link> | ||
|
||
<button | ||
ref={menubuttonRef} | ||
type="button" | ||
className="p-link layout-menu-button layout-topbar-button" | ||
onClick={onMenuToggle} | ||
> | ||
<i className="pi pi-bars" /> | ||
</button> | ||
|
||
<button | ||
ref={topbarmenubuttonRef} | ||
type="button" | ||
className="p-link layout-topbar-menu-button layout-topbar-button" | ||
onClick={showProfileSidebar} | ||
> | ||
<i className="pi pi-ellipsis-v" /> | ||
</button> | ||
|
||
<div | ||
ref={topbarmenuRef} | ||
className={classNames('layout-topbar-menu', { | ||
'layout-topbar-menu-mobile-active': layoutState.profileSidebarVisible, | ||
})} | ||
> | ||
<button type="button" className="p-link layout-topbar-button"> | ||
<i className="pi pi-calendar"></i> | ||
<span>Calendar</span> | ||
</button> | ||
<button type="button" className="p-link layout-topbar-button"> | ||
<i className="pi pi-user"></i> | ||
<span>Profile</span> | ||
</button> | ||
<Link href="/documentation"> | ||
<button type="button" className="p-link layout-topbar-button"> | ||
<i className="pi pi-cog"></i> | ||
<span>Settings</span> | ||
</button> | ||
</Link> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
AppTopbar.displayName = 'AppTopbar'; | ||
|
||
export default AppTopbar; |
Empty file.
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,10 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
'use client'; | ||
|
||
const AppFooter = () => { | ||
return <div>Footer</div>; | ||
}; | ||
|
||
AppFooter.displayName = 'AppFooter'; | ||
|
||
export default AppFooter; |
Oops, something went wrong.