Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Fix small regressions API pages #36972

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data/joy/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const pages = [
],
},
{
title: 'Component API',
title: 'APIs',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from #35938 (comment)

pathname: '/joy-ui/api',
icon: standardNavIcons.CodeIcon,
children: pagesApi,
Expand Down
4 changes: 2 additions & 2 deletions docs/data/system/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const pages = [
],
},
{
title: 'Component API',
title: 'APIs',
pathname: '/system/api',
icon: standardNavIcons.CodeIcon,
children: pagesApi,
Expand All @@ -68,7 +68,7 @@ const pages = [
children: [
{ pathname: '/system/styles/basics' },
{ pathname: '/system/styles/advanced' },
{ pathname: '/system/styles/api', title: 'API' },
{ pathname: '/system/styles/api', title: 'APIs' },
],
},
];
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/brandingTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export const getDesignTokens = (mode: 'light' | 'dark') =>
fontWeight: 700,
},
allVariants: {
scrollMarginTop: 'calc(var(--MuiDocs-header-height) + 72px)',
scrollMarginTop: 'calc(var(--MuiDocs-header-height) + 32px)',
Copy link
Member Author

@oliviertassinari oliviertassinari Apr 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore 32px, it's this distance:

Frame 1 (1)

It's always the same, even on the marketing pages which have a taller appbar than on the docs.

},
},
/**
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Container from '@mui/material/Container';

const StyledAppContainer = styled(Container)(({ theme }) => {
return {
paddingTop: 'calc(var(--MuiDocs-header-height) + 36px)',
paddingTop: `calc(var(--MuiDocs-header-height) + ${theme.spacing(4)})`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency with the other padding

// We're mostly hosting text content so max-width by px does not make sense considering font-size is system-adjustable.
// 105ch ≈ 930px
fontFamily: 'Arial',
Expand Down
4 changes: 3 additions & 1 deletion docs/src/modules/components/AppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ const StyledAppNavDrawer = styled(AppNavDrawer)(({ disablePermanent, theme }) =>
};
});

export const HEIGHT = 64;

export default function AppFrame(props) {
const { children, disableDrawer = false, className, BannerComponent = AppFrameBanner } = props;
const t = useTranslate();
Expand All @@ -175,7 +177,7 @@ export default function AppFrame(props) {
<GlobalStyles
styles={{
':root': {
'--MuiDocs-header-height': '64px',
'--MuiDocs-header-height': `${HEIGHT}px`,
},
}}
/>
Expand Down
8 changes: 4 additions & 4 deletions docs/src/modules/components/AppLayoutDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ const StyledAppContainer = styled(AppContainer, {
marginBottom: 198,
},
'&& .description.ad': {
marginBottom: 40,
marginBottom: 0,
},
}),
...(hasTabs && {
'&& .component-tabs .MuiTabs-root': {
marginBottom: 193,
marginBottom: 198,
Copy link
Member Author

@oliviertassinari oliviertassinari Apr 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix #35938 (comment)

There is still a layout shift with Joy UI, but it's because the theme are not correctly isolated, the Ad renders with Joy UI theme, not with MUI's branding theme, a problem for another day.

},
'&& .component-tabs.ad .MuiTabs-root': {
marginBottom: 35,
marginBottom: 0,
},
}),
}),
Expand Down Expand Up @@ -86,10 +86,10 @@ function AppLayoutDocs(props) {
description,
disableAd = false,
disableToc = false,
hasTabs = false,
location,
title,
toc,
hasTabs = false,
} = props;

if (description === undefined) {
Expand Down
8 changes: 4 additions & 4 deletions docs/src/modules/components/AppLayoutDocsWithoutAppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ const StyledAppContainer = styled(AppContainer, {
marginBottom: 198,
},
'&& .description.ad': {
marginBottom: 40,
marginBottom: 0,
},
}),
...(hasTabs && {
'&& .component-tabs .MuiTabs-root': {
marginBottom: 193,
marginBottom: 198,
},
'&& .component-tabs.ad .MuiTabs-root': {
marginBottom: 35,
marginBottom: 0,
},
}),
}),
Expand All @@ -84,10 +84,10 @@ function AppLayoutDocs(props) {
description,
disableAd = false,
disableToc = false,
hasTabs = false,
location,
title,
toc,
hasTabs = false,
} = props;

if (description === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppTableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Nav = styled('nav')(({ theme }) => ({
position: 'sticky',
height: '100vh',
overflowY: 'auto',
paddingTop: 'calc(var(--MuiDocs-header-height) + 1rem)',
paddingTop: `calc(var(--MuiDocs-header-height) + ${theme.spacing(4)})`,
paddingBottom: theme.spacing(4),
paddingRight: theme.spacing(4), // We can't use `padding` as stylis-plugin-rtl doesn't swap it
display: 'none',
Expand Down
2 changes: 2 additions & 0 deletions docs/src/modules/components/ComponentPageTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Tabs, { tabsClasses } from '@mui/material/Tabs';
import Tab, { tabClasses } from '@mui/material/Tab';
import Link from 'docs/src/modules/components/Link';

export const HEIGHT = 50;

export default function ComponentPageTabs(props) {
const {
activeTab,
Expand Down
84 changes: 43 additions & 41 deletions docs/src/modules/components/MarkdownDocsV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useRouter } from 'next/router';
import kebabCase from 'lodash/kebabCase';
import { useTheme } from '@mui/system';
import { exactProp } from '@mui/utils';
import Box from '@mui/material/Box';
import { CssVarsProvider, useColorScheme } from '@mui/joy/styles';
import ComponentsApiContent from 'docs/src/modules/components/ComponentsApiContent';
import HooksApiContent from 'docs/src/modules/components/HooksApiContent';
Expand All @@ -15,6 +14,8 @@ import AppLayoutDocs from 'docs/src/modules/components/AppLayoutDocsWithoutAppFr
import { useTranslate, useUserLanguage } from 'docs/src/modules/utils/i18n';
import BrandingProvider from 'docs/src/BrandingProvider';
import Ad from 'docs/src/modules/components/Ad';
import { HEIGHT as AppFrameHeight } from 'docs/src/modules/components/AppFrame';
import { HEIGHT as TabsHeight } from 'docs/src/modules/components/ComponentPageTabs';
import AdGuest from 'docs/src/modules/components/AdGuest';

function JoyModeObserver({ mode }) {
Expand Down Expand Up @@ -219,54 +220,55 @@ export default function MarkdownDocsV2(props) {
toc={activeToc}
hasTabs
>
<Provider>
{isJoy && <JoyModeObserver key="joy-provider" mode={theme.palette.mode} />}
{disableAd ? null : (
<Wrapper key="add">
<AdGuest classSelector=".component-tabs">
<Ad />
</AdGuest>
</Wrapper>
)}
{commonElements}
{activeTab === '' && (
<Box>
{rendered.slice(i, rendered.length - 1).map((renderedMarkdownOrDemo, index) => (
<MarkdownElement
key={`demos-section-${index}`}
renderedMarkdownOrDemo={renderedMarkdownOrDemo}
WrapperComponent={Wrapper}
wrapperProps={wrapperProps}
srcComponents={srcComponents}
activeTab={activeTab}
setActiveTab={setActiveTab}
localizedDoc={localizedDoc}
demos={demos}
location={location}
theme={theme}
demoComponents={demoComponents}
disableAd={disableAd}
/>
))}
</Box>
)}
{activeTab === 'components-api' && (
<Box>
<div
style={{
'--MuiDocs-header-height': `${AppFrameHeight + TabsHeight}px`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}}
>
<Provider>
{isJoy && <JoyModeObserver key="joy-provider" mode={theme.palette.mode} />}
{disableAd ? null : (
<Wrapper key="add">
<AdGuest classSelector=".component-tabs">
<Ad />
</AdGuest>
</Wrapper>
)}
{commonElements}
{activeTab === '' &&
rendered
.slice(i, rendered.length - 1)
.map((renderedMarkdownOrDemo, index) => (
<MarkdownElement
key={`demos-section-${index}`}
renderedMarkdownOrDemo={renderedMarkdownOrDemo}
WrapperComponent={Wrapper}
wrapperProps={wrapperProps}
srcComponents={srcComponents}
activeTab={activeTab}
setActiveTab={setActiveTab}
localizedDoc={localizedDoc}
demos={demos}
location={location}
theme={theme}
demoComponents={demoComponents}
disableAd={disableAd}
/>
))}
{activeTab === 'components-api' && (
<ComponentsApiContent
descriptions={componentsApiDescriptions}
pageContents={componentsApiPageContents}
/>
</Box>
)}
{activeTab === 'hooks-api' && (
<Box>
)}
{activeTab === 'hooks-api' && (
<HooksApiContent
descriptions={hooksApiDescriptions}
pagesContents={hooksApiPageContents}
/>
</Box>
)}
</Provider>
)}
</Provider>
</div>
</AppLayoutDocs>
);
}
Expand Down
2 changes: 2 additions & 0 deletions docs/src/modules/components/MarkdownElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ const Root = styled('div')(
},
'& h1, & h2, & h3, & h4': {
position: 'relative',
// Reserve space for the end of the line action button
paddingRight: 26 * 2 + 10,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'& code': {
fontSize: 'inherit',
lineHeight: 'inherit',
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const pages: readonly MuiPage[] = [
],
},
{
title: 'Component API',
title: 'APIs',
pathname: '/api-docs',
icon: standardNavIcons.CodeIcon,
children: [
Expand Down Expand Up @@ -288,7 +288,7 @@ const pages: readonly MuiPage[] = [
children: [
{ pathname: '/styles/basics' },
{ pathname: '/styles/advanced' },
{ pathname: '/styles/api', title: 'API' },
{ pathname: '/styles/api', title: 'APIs' },
],
},
{
Expand Down