-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #203 from assemblee-virtuelle/200-AdaptFirstLayout…
…ToNewArchitecture [Minor] 200 - Move existing layout to create new "leftMenu" layout
- Loading branch information
Showing
24 changed files
with
139 additions
and
54 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
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
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,45 @@ | ||
import React, { createContext, FunctionComponent, PropsWithChildren, ReactNode, useContext } from 'react'; | ||
import { LayoutProps } from 'react-admin'; | ||
import leftMenu, { LayoutOptions as LeftMenuOptions } from './leftMenu'; | ||
|
||
type BaseViewProps = PropsWithChildren<{ | ||
title: string | ReactNode; | ||
actions: JSX.Element; | ||
aside?: JSX.Element; | ||
}>; | ||
|
||
export type LayoutComponents = { | ||
Layout: FunctionComponent<LayoutProps>; | ||
BaseView: FunctionComponent<BaseViewProps>; | ||
Aside: FunctionComponent<PropsWithChildren>; | ||
}; | ||
|
||
export type LeftMenuLayoutType = LayoutComponents & LeftMenuOptions; | ||
|
||
type LayoutOptions = LeftMenuOptions; | ||
type LayoutContextType = LeftMenuLayoutType; | ||
|
||
export const LayoutContext = createContext<LayoutContextType | undefined>(undefined); | ||
|
||
const layoutsComponents = { | ||
leftMenu, | ||
}; | ||
|
||
type LayoutProviderProps = PropsWithChildren<{ | ||
layoutOptions: LayoutOptions; | ||
}>; | ||
|
||
export const LayoutProvider = ({ children, layoutOptions }: LayoutProviderProps) => { | ||
const layoutComponents = layoutsComponents[layoutOptions.name]; | ||
|
||
if (!layoutComponents) { | ||
return null; | ||
} | ||
|
||
return <LayoutContext.Provider value={{ ...layoutOptions, ...layoutComponents }}>{children}</LayoutContext.Provider>; | ||
}; | ||
|
||
export const useLayoutContext = <T extends LayoutOptions = LayoutOptions>() => { | ||
const layout = useContext(LayoutContext); | ||
return layout as T & LayoutComponents; | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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,13 @@ | ||
import { lazy } from 'react'; | ||
import { LayoutComponents } from '../LayoutContext'; | ||
|
||
export type LayoutOptions = { | ||
name: 'leftMenu'; | ||
options: Record<string, never>; | ||
}; | ||
|
||
export default { | ||
Layout: lazy(() => import('./Layout')), | ||
BaseView: lazy(() => import('./BaseView')), | ||
Aside: lazy(() => import('./Aside')), | ||
} as LayoutComponents; |
8 changes: 5 additions & 3 deletions
8
...ent/Activity/Event/EventFilterSidebar.jsx → ...ent/Activity/Event/EventFilterSidebar.tsx
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
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
Oops, something went wrong.