Skip to content

Commit

Permalink
fix: pop-up definition overlaps header (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeikZim authored and Ruslan Bagautdinov committed Sep 24, 2024
1 parent 0b36d30 commit 6f7113f
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"mini-css-extract-plugin": "^2.7.6",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-svg-loader": "^3.0.3",
"react-svg-loader": "^3.0.0",
"rtlcss": "^4.1.1",
"sass": "^1.69.5",
"sass-loader": "^13.3.2",
Expand Down
1 change: 1 addition & 0 deletions src/components/App/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

.dc-root_full-header & {
--dc-header-height: 64px;
--dc-subnavigation-height: 52px;
}
}

Expand Down
38 changes: 29 additions & 9 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
} from '@gravity-ui/page-constructor';
import {ThemeProvider} from '@gravity-ui/uikit';
import {
ControlSizes,
CustomNavigation,
DocContentPageData,
DocLeadingPageData,
DocPageData,
Expand All @@ -20,6 +22,10 @@ import {
getPageByType,
getPageType,
} from '@diplodoc/components';
import {MermaidRuntime} from '@diplodoc/mermaid-extension/react';
import {LatexRuntime} from '@diplodoc/latex-extension/react';
import {Runtime as OpenapiSandbox} from '@diplodoc/openapi-extension/runtime';
import '@diplodoc/transform/dist/js/yfm';

import {HeaderControls} from '../HeaderControls';
import {getDirection, updateRootClassName} from '../../utils';
Expand All @@ -28,14 +34,11 @@ import {useSettings} from '../../hooks/useSettings';
import {useMobile} from '../../hooks/useMobile';

import '../../interceptors/leading-page-links';

import '@diplodoc/transform/dist/js/yfm';
import {MermaidRuntime} from '@diplodoc/mermaid-extension/react';
import {LatexRuntime} from '@diplodoc/latex-extension/react';
import {Runtime as OpenapiSandbox} from '@diplodoc/openapi-extension/runtime';
import {ConstructorPage} from '../ConstructorPage';

import './App.scss';
import {ConstructorPage} from '../ConstructorPage';

const HEADER_HEIGHT = 64;

export interface AppProps {
lang: Lang;
Expand Down Expand Up @@ -198,6 +201,13 @@ export function App(props: DocInnerProps): ReactElement {
const {leftItems = [], rightItems = []} = header as NavigationData['header'];
const headerWithControls = rightItems.some((item: {type: string}) => item.type === 'controls');

const controlSize: ControlSizes = ControlSizes.L;
const userSettings = settings;
const toc = data.toc;

const navigationTocData = {toc, router, headerHeight: HEADER_HEIGHT};
const mobileControlsData = {controlSize, lang, userSettings};

return (
<div className={appClassName}>
<ThemeProvider theme={theme} direction={direction}>
Expand Down Expand Up @@ -247,10 +257,20 @@ export function App(props: DocInnerProps): ReactElement {
fullHeader
? {
header: {
withBorder: true,
leftItems: leftItems,
rightItems: rightItems,
leftItems: [],
},
renderNavigation: () => (
<CustomNavigation
logo={logo}
data={{
withBorder: true,
leftItems: leftItems,
rightItems: rightItems,
}}
navigationTocData={navigationTocData}
mobileControlsData={mobileControlsData}
/>
),
logo,
}
: undefined
Expand Down
6 changes: 4 additions & 2 deletions src/components/Layout/Layout.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "../../styles/variables";

.Layout {
&__header {
position: sticky;
Expand All @@ -8,13 +10,13 @@
&__body {
display: flex;
flex-flow: column;
min-height: calc(100vh - var(--dc-header-height));
min-height: calc(100vh - var(--dc-header-height, #{$headerHeight}));
}

.pc-page-constructor & {
&__content {
flex: 1 1 auto;
margin: 0 -10px;
margin: 0 -8px;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/styles/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ body {
.g-root {
--dc-header-height: 0;
--dc-subheader-height: 40px;
--dc-subnavigation-height: 52px;

--dc-error-image-403: url('data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=');
--dc-error-image-404: url('data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=');
Expand Down
44 changes: 39 additions & 5 deletions src/styles/overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
}
}


.App.document-mode {
.pc-Grid {
padding-right: 40px;
Expand All @@ -16,7 +15,7 @@
padding: 0;
}

@media (max-width: map-get($screenBreakpoints, 'md')) {
@media (max-width: map-get($screenBreakpoints, 'md') - 1) {
padding-right: 20px;
padding-left: 20px;

Expand Down Expand Up @@ -60,12 +59,29 @@
padding: 20px 0 24px;
}

.dc-root_wide-format {
& .dc-subnavigation {
$wideFormatHorizontalPadding: 8px;

padding-left: 0;
padding-right: $wideFormatHorizontalPadding;
width: calc(100% - $wideFormatHorizontalPadding);
}

& .dc-doc-page__main {
@media (max-width: map-get($screenBreakpoints, 'md') - 1) {
padding-left: #{$wideFormatHorizontalPadding};
padding-right: #{$wideFormatHorizontalPadding};
}
}
}

.pc-block-base {
padding: 0 !important;
}

.pc-navigation {
z-index: 101;
z-index: 120;

.desktop .dc-root_wide-format & .container-fluid {
padding: 0;
Expand Down Expand Up @@ -104,8 +120,12 @@
}
}

.pc-mobile-navigation {
z-index: 119;
}

.pc-navigation {
z-index: 101;
z-index: 120;

.desktop.dc-root_wide-format & .container-fluid {
padding: 30px;
Expand All @@ -122,4 +142,18 @@
padding: 0;
}
}
}
}

@media (max-width: map-get($screenBreakpoints, 'md') - 1) {
.dc-toc {
height: fit-content !important;
}

body:has(.pc-navigation) .dc-sidebar {
--dc-header-height: var(--header-height, 64px);
}

.pc-navigation-item:has(.dc-controls) {
display: none;
}
}
2 changes: 2 additions & 0 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Sizes
$headerHeight: 0px;
$subNavigationHeight: 52px;
$normalOffset: 20px;
$miniTocOffset: 56px;
$blockMarginBottomLarge: 20px;
Expand All @@ -8,6 +9,7 @@ $headerMarginTopLarge: 40px;
$headerMarginTopMedium: 32px;
$popupPadding: 16px;
$centerBlockMaxWidth: 736px;
$wideFormatHorizontalPadding: 8px;

$screenBreakpoints: (
'xs': 375px,
Expand Down

0 comments on commit 6f7113f

Please sign in to comment.