docs: tweak document content area width (#50625)

This commit is contained in:
afc163 2024-08-29 14:05:07 +08:00 committed by GitHub
parent a3616a5cf6
commit bfd2c06987
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 47 deletions

View File

@ -1,6 +1,6 @@
import React, { useMemo } from 'react'; import React, { useMemo } from 'react';
import type { MenuProps } from 'antd'; import type { MenuProps } from 'antd';
import { Tag, version } from 'antd'; import { Space, Tag, version } from 'antd';
import { createStyles } from 'antd-style'; import { createStyles } from 'antd-style';
import classnames from 'classnames'; import classnames from 'classnames';
import { useFullSidebarData, useSidebarData } from 'dumi'; import { useFullSidebarData, useSidebarData } from 'dumi';
@ -22,7 +22,6 @@ const useStyle = createStyles(({ css, token }) => ({
margin-inline-end: 0; margin-inline-end: 0;
`, `,
subtitle: css` subtitle: css`
margin-inline-start: ${token.marginXS}px;
font-weight: normal; font-weight: normal;
font-size: ${token.fontSizeSM}px; font-size: ${token.fontSizeSM}px;
opacity: 0.8; opacity: 0.8;
@ -46,10 +45,10 @@ const MenuItemLabelWithTag: React.FC<MenuItemLabelProps> = (props) => {
if (!before && !after) { if (!before && !after) {
return ( return (
<Link to={`${link}${search}`} className={classnames(className, { [styles.link]: tag })}> <Link to={`${link}${search}`} className={classnames(className, { [styles.link]: tag })}>
<span> <Space>
{title} <span>{title}</span>
{subtitle && <span className={styles.subtitle}>{subtitle}</span>} {subtitle && <span className={styles.subtitle}>{subtitle}</span>}
</span> </Space>
{tag && ( {tag && (
<Tag <Tag
bordered={false} bordered={false}

View File

@ -5,7 +5,7 @@ import type { AnchorLinkItemProps } from 'antd/es/anchor/Anchor';
import classNames from 'classnames'; import classNames from 'classnames';
import { useRouteMeta, useTabMeta } from 'dumi'; import { useRouteMeta, useTabMeta } from 'dumi';
const useStyle = createStyles(({ token, css }) => { export const useStyle = createStyles(({ token, css }) => {
const { antCls } = token; const { antCls } = token;
return { return {
anchorToc: css` anchorToc: css`
@ -19,13 +19,13 @@ const useStyle = createStyles(({ token, css }) => {
`, `,
tocWrapper: css` tocWrapper: css`
position: fixed; position: fixed;
top: ${token.headerHeight + token.contentMarginTop - 8}px; top: ${token.headerHeight + token.contentMarginTop - 4}px;
inset-inline-end: 0; inset-inline-end: 0;
width: 160px; width: 148px;
padding: ${token.paddingXS}px; padding: 0;
border-radius: ${token.borderRadius}px; border-radius: ${token.borderRadius}px;
box-sizing: border-box; box-sizing: border-box;
margin-inline-end: calc(16px - 100vw + 100%); margin-inline-end: calc(8px - 100vw + 100%);
z-index: 10; z-index: 10;
.toc-debug { .toc-debug {
color: ${token.purple6}; color: ${token.purple6};
@ -48,15 +48,11 @@ const useStyle = createStyles(({ token, css }) => {
} }
`, `,
articleWrapper: css` articleWrapper: css`
padding: 0 170px 32px 64px; padding-inline: 48px 164px;
padding-block: 0 32px;
&.rtl {
padding: 0 64px 144px 170px;
}
@media only screen and (max-width: ${token.screenLG}px) { @media only screen and (max-width: ${token.screenLG}px) {
&, & {
&.rtl {
padding: 0 ${token.paddingLG * 2}px; padding: 0 ${token.paddingLG * 2}px;
} }
} }

View File

@ -1,6 +1,5 @@
import React, { useContext, useLayoutEffect, useMemo, useState } from 'react'; import React, { useContext, useLayoutEffect, useMemo, useState } from 'react';
import { Col, Flex, Space, Typography } from 'antd'; import { Col, Flex, Space, Typography } from 'antd';
import { createStyles } from 'antd-style';
import classNames from 'classnames'; import classNames from 'classnames';
import { FormattedMessage, useRouteMeta } from 'dumi'; import { FormattedMessage, useRouteMeta } from 'dumi';
@ -11,6 +10,7 @@ import type { DemoContextProps } from '../DemoContext';
import DemoContext from '../DemoContext'; import DemoContext from '../DemoContext';
import SiteContext from '../SiteContext'; import SiteContext from '../SiteContext';
import InViewSuspense from './InViewSuspense'; import InViewSuspense from './InViewSuspense';
import { useStyle } from './DocAnchor';
const Contributors = React.lazy(() => import('./Contributors')); const Contributors = React.lazy(() => import('./Contributors'));
const ColumnCard = React.lazy(() => import('./ColumnCard')); const ColumnCard = React.lazy(() => import('./ColumnCard'));
@ -21,21 +21,6 @@ const PrevAndNext = React.lazy(() => import('../../common/PrevAndNext'));
const ComponentChangelog = React.lazy(() => import('../../common/ComponentChangelog')); const ComponentChangelog = React.lazy(() => import('../../common/ComponentChangelog'));
const EditButton = React.lazy(() => import('../../common/EditButton')); const EditButton = React.lazy(() => import('../../common/EditButton'));
const useStyle = createStyles(({ token, css }) => ({
articleWrapper: css`
padding: 0 170px 32px 64px;
&.rtl {
padding: 0 64px 144px 170px;
}
@media only screen and (max-width: ${token.screenLG}px) {
&,
&.rtl {
padding: 0 ${token.paddingLG * 2}px;
}
}
`,
}));
const Content: React.FC<React.PropsWithChildren> = ({ children }) => { const Content: React.FC<React.PropsWithChildren> = ({ children }) => {
const meta = useRouteMeta(); const meta = useRouteMeta();
const { pathname, hash } = useLocation(); const { pathname, hash } = useLocation();
@ -107,9 +92,7 @@ const Content: React.FC<React.PropsWithChildren> = ({ children }) => {
version={meta.frontmatter.tag} version={meta.frontmatter.tag}
/> />
)} )}
<div style={{ minHeight: 'calc(100vh - 64px)', width: 'calc(100% - 10px)' }}> <div style={{ minHeight: 'calc(100vh - 64px)' }}>{children}</div>
{children}
</div>
<InViewSuspense> <InViewSuspense>
<ColumnCard <ColumnCard
zhihuLink={meta.frontmatter.zhihu_url} zhihuLink={meta.frontmatter.zhihu_url}

View File

@ -53,12 +53,7 @@ const useStyle = createStyles(({ token, css }) => {
> ${antCls}-menu-item-group > ${antCls}-menu-item-group
> ${antCls}-menu-item-group-list > ${antCls}-menu-item-group-list
> ${antCls}-menu-item { > ${antCls}-menu-item {
padding-inline-start: 40px !important; padding-inline: 36px 12px !important;
${antCls}-row-rtl & {
padding-inline-end: 40px !important;
padding-inline-start: ${token.padding}px !important;
}
} }
// Nest Category > Type > Article // Nest Category > Type > Article
@ -96,8 +91,6 @@ const useStyle = createStyles(({ token, css }) => {
`, `,
mainMenu: css` mainMenu: css`
z-index: 1; z-index: 1;
.main-menu-inner {
position: sticky; position: sticky;
top: ${token.headerHeight + token.contentMarginTop}px; top: ${token.headerHeight + token.contentMarginTop}px;
width: 100%; width: 100%;
@ -106,9 +99,12 @@ const useStyle = createStyles(({ token, css }) => {
overflow: hidden; overflow: hidden;
scrollbar-width: thin; scrollbar-width: thin;
scrollbar-color: unset; scrollbar-color: unset;
.ant-menu {
padding: 0 4px;
} }
&:hover .main-menu-inner { &:hover {
overflow-y: auto; overflow-y: auto;
} }
`, `,
@ -144,7 +140,7 @@ const Sidebar: React.FC = () => {
<MobileMenu key="Mobile-menu">{menuChild}</MobileMenu> <MobileMenu key="Mobile-menu">{menuChild}</MobileMenu>
) : ( ) : (
<Col xxl={4} xl={5} lg={6} md={6} sm={24} xs={24} className={styles.mainMenu}> <Col xxl={4} xl={5} lg={6} md={6} sm={24} xs={24} className={styles.mainMenu}>
<section className="main-menu-inner">{menuChild}</section> {menuChild}
</Col> </Col>
); );
}; };