-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add page-constructor page type
- Loading branch information
1 parent
e080602
commit d3f18e8
Showing
6 changed files
with
156 additions
and
5 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,102 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
BackgroundMedia, | ||
Col, | ||
ConstructorBlocks, | ||
Grid, | ||
Row, | ||
getThemedValue, | ||
} from '@gravity-ui/page-constructor'; | ||
import block from 'bem-cn-lite'; | ||
|
||
import {DEFAULT_SETTINGS} from '../../constants'; | ||
import {DocumentType, PageConstructorData, Router, Theme} from '../../models'; | ||
import {DocLayout} from '../DocLayout'; | ||
|
||
const b = block('dc-doc-page'); | ||
|
||
const bPC = block('pc-page-constructor'); | ||
const bPCRow = block('pc-constructor-row'); | ||
|
||
const {wideFormat: defaultWideFormat} = DEFAULT_SETTINGS; | ||
|
||
export interface PageConstructorProps extends PageConstructorData { | ||
router: Router; | ||
headerHeight?: number; | ||
wideFormat?: boolean; | ||
hideTocHeader?: boolean; | ||
hideToc?: boolean; | ||
tocTitleIcon?: React.ReactNode; | ||
theme: Theme; | ||
type: DocumentType; | ||
} | ||
|
||
export type WithChildren<T = {}> = T & {children?: React.ReactNode}; | ||
|
||
export const ConstructorRow = ({children}: WithChildren<{}>) => | ||
children ? ( | ||
<Row className={bPCRow()}> | ||
<Col>{children}</Col> | ||
</Row> | ||
) : null; | ||
|
||
export const PageConstructor: React.FC<PageConstructorProps> = ({ | ||
data, | ||
toc, | ||
router, | ||
headerHeight, | ||
wideFormat = defaultWideFormat, | ||
hideTocHeader, | ||
hideToc, | ||
tocTitleIcon, | ||
footer, | ||
theme, | ||
type, | ||
}) => { | ||
const modes = { | ||
'regular-page-width': !wideFormat, | ||
}; | ||
|
||
const themedBackground = getThemedValue(data?.background, theme); | ||
|
||
return ( | ||
<DocLayout | ||
toc={toc} | ||
router={router} | ||
headerHeight={headerHeight} | ||
className={b(modes)} | ||
hideTocHeader={hideTocHeader} | ||
hideToc={hideToc || data?.fullScreen} | ||
fullScreen={data?.fullScreen} | ||
tocTitleIcon={tocTitleIcon} | ||
footer={footer} | ||
hideRight={true} | ||
wideFormat={wideFormat} | ||
> | ||
<DocLayout.Center> | ||
<div className={b('main')}> | ||
<main className={b('content')}> | ||
{type === DocumentType.PageConstructor && ( | ||
<div className={b('')}> | ||
<div className={bPC('wrapper')}> | ||
{data?.blocks && themedBackground && ( | ||
<BackgroundMedia | ||
{...themedBackground} | ||
className={bPC('background')} | ||
/> | ||
)} | ||
<Grid> | ||
<ConstructorRow> | ||
<ConstructorBlocks items={data?.blocks} /> | ||
</ConstructorRow> | ||
</Grid> | ||
</div> | ||
</div> | ||
)} | ||
</main> | ||
</div> | ||
</DocLayout.Center> | ||
</DocLayout> | ||
); | ||
}; |
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 @@ | ||
export * from './PageConstructor'; |
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