Skip to content

Commit

Permalink
feat: add page-constructor page
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored and 3y3 committed Mar 25, 2024
1 parent 83166aa commit 66cbce1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"devDependencies": {
"@diplodoc/babel-preset": "^1.0.2",
"@diplodoc/components": "^3.9.1",
"@diplodoc/components": "^4.0.0",
"@diplodoc/eslint-config": "^2.0.0",
"@diplodoc/openapi-extension": "^2.1.0",
"@diplodoc/prettier-config": "^2.0.0",
Expand Down
19 changes: 13 additions & 6 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ import {
} from '@gravity-ui/page-constructor';
import {ThemeProvider} from '@gravity-ui/uikit';
import {
DocLeadingPage,
ConstructorPageData,
DocLeadingPageData,
DocPage,
DocPageData,
DocumentType,
Lang,
Router,
Theme,
getPageByType,
getPageType
} from '@diplodoc/components';

import {HeaderControls} from '../HeaderControls';
import {getDirection, updateRootClassName} from '../../utils';
import {Layout} from '../Layout';
Expand All @@ -35,9 +38,10 @@ import './App.scss';
export interface AppProps {
lang: Lang;
router: Router;
type: DocumentType;
}

export type DocInnerProps<Data = DocLeadingPageData | DocPageData> = {
export type DocInnerProps<Data = DocLeadingPageData | DocPageData | ConstructorPageData> = {
data: Data;
} & AppProps;

Expand Down Expand Up @@ -65,9 +69,9 @@ function Runtime(props: RuntimeProps) {
);
}

function Page(props: DocInnerProps) {
export function Page(props: DocInnerProps) {
const {data, ...pageProps} = props;
const Page = data.leading ? DocLeadingPage : DocPage;
const Page = getPageByType(props?.type);

return (
<Layout>
Expand Down Expand Up @@ -111,6 +115,8 @@ export function App(props: DocInnerProps): ReactElement {
const {theme, textSize, wideFormat, fullScreen, showMiniToc, onChangeFullScreen} = settings;
const fullHeader = !fullScreen && Boolean(navigation);
const headerHeight = fullHeader ? 64 : 0;
const type = getPageType(data);

const pageProps = {
headerHeight,
data,
Expand All @@ -122,6 +128,7 @@ export function App(props: DocInnerProps): ReactElement {
textSize,
fullScreen,
onChangeFullScreen,
type,
};
const direction = getDirection(lang);

Expand Down Expand Up @@ -169,7 +176,7 @@ export function App(props: DocInnerProps): ReactElement {
),
},
}}
content={{
content={type === DocumentType.ConstructorPage && 'data' in data && 'fullScreen' in data.data && data.data.fullScreen ? data.data : {
blocks: [
{
type: 'page',
Expand Down
7 changes: 7 additions & 0 deletions src/styles/overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
margin-top: var(--pc-first-block-indent, 96px);
}

.pc-Grid .pc-Grid {
.container-fluid .pc-header-block__container-fluid {
padding-right: 40px;
padding-left: 40px;
}
}

.pc-block-base {
padding: 0 !important;
}
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"target": "es2020",
"moduleResolution": "node",
"resolveJsonModule": true,
"lib": ["DOM"],
"declaration": true,
"outDir": "build",
Expand Down

0 comments on commit 66cbce1

Please sign in to comment.