-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathEmptyLayout.tsx
More file actions
executable file
·64 lines (56 loc) · 1.63 KB
/
EmptyLayout.tsx
File metadata and controls
executable file
·64 lines (56 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { useEffect, type ReactNode } from 'react'
import { isNumber } from 'lodash'
import classNames from 'classnames'
import { withPageConfig } from 'Components/Layout'
import type { PageConfig } from 'Components/Layout/types'
interface EmptyLayoutProps {
pageConfig?: PageConfig | null
children: ReactNode
className?: string
}
interface SectionProps {
className?: string
children: ReactNode
center?: boolean
width?: number | string
}
const EmptyLayoutBase = ({ pageConfig, children, className }: EmptyLayoutProps) => {
useEffect(() => {
pageConfig?.setElementsVisibility?.({
navbarHidden: true,
sidebarHidden: true,
footerHidden: true,
})
return () => {
pageConfig?.setElementsVisibility?.({
navbarHidden: false,
sidebarHidden: false,
footerHidden: false,
})
}
}, [pageConfig])
const emptyLayoutClass = classNames('fullscreen', className)
return <div className={emptyLayoutClass}>{children}</div>
}
const Section = ({ className, children, center, width = '420px' }: SectionProps) => {
const sectionClass = classNames(className, 'fullscreen__section', {
'fullscreen__section--center': center,
})
const maxWidth = isNumber(width) ? `${width}px` : width
return (
<div className={sectionClass}>
{center ? (
<div className="fullscrenn__section__child" style={{ maxWidth }}>
{children}
</div>
) : (
children
)}
</div>
)
}
const EmptyLayout = withPageConfig(EmptyLayoutBase) as ReturnType<typeof withPageConfig> & {
Section: typeof Section
}
EmptyLayout.Section = Section
export { EmptyLayout }