From e1b3bfa687e75d62db6f9a545f1f865f0a7e9273 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 1 Dec 2024 00:15:43 +0100 Subject: [PATCH] [docs-infra] Fix TOC RTL padding regression (#44535) --- .../modules/components/AppTableOfContents.js | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/docs/src/modules/components/AppTableOfContents.js b/docs/src/modules/components/AppTableOfContents.js index 5ee730cd054da9..8cfa63458e9d55 100644 --- a/docs/src/modules/components/AppTableOfContents.js +++ b/docs/src/modules/components/AppTableOfContents.js @@ -45,8 +45,7 @@ const NavList = styled(Typography)({ }); const NavItem = styled(Link, { - shouldForwardProp: (prop) => - prop !== 'active' && prop !== 'secondary' && prop !== 'secondarySubItem', + shouldForwardProp: (prop) => prop !== 'active' && prop !== 'level', })(({ theme }) => { const activeStyles = { borderLeftColor: (theme.vars || theme).palette.primary[200], @@ -67,9 +66,8 @@ const NavItem = styled(Link, { return [ { - '--_padding-left': '12px', boxSizing: 'border-box', - padding: theme.spacing('6px', 0, '6px', 'var(--_padding-left)'), + padding: '6px 0 6px 12px', borderLeft: `1px solid transparent`, display: 'block', fontSize: theme.typography.pxToRem(13), @@ -93,15 +91,15 @@ const NavItem = styled(Link, { }, }, { - props: ({ secondary }) => secondary, + props: ({ level }) => level === 2, style: { - '--_padding-left': theme.spacing(3), + padding: `6px 0 6px ${theme.spacing(3)}`, }, }, { - props: ({ secondarySubItem }) => secondarySubItem, + props: ({ level }) => level === 3, style: { - '--_padding-left': theme.spacing(4.5), + padding: `6px 0 6px ${theme.spacing(4.5)}`, }, }, ], @@ -250,15 +248,14 @@ export default function AppTableOfContents(props) { [], ); - const itemLink = (item, secondary, secondarySubItem) => ( + const itemLink = (item, level) => ( @@ -324,18 +321,16 @@ export default function AppTableOfContents(props) { {toc.map((item) => (
  • - {itemLink(item)} + {itemLink(item, 1)} {item.children.length > 0 ? ( {item.children.map((subitem) => (
  • - {itemLink(subitem, true)} + {itemLink(subitem, 2)} {subitem.children?.length > 0 ? ( {subitem.children.map((nestedSubItem) => ( -
  • - {itemLink(nestedSubItem, false, true)} -
  • +
  • {itemLink(nestedSubItem, 3)}
  • ))}
    ) : null}