import React, { useContext, useState } from 'react'; import { Fragment, FC } from 'react'; import { PageProps, Link } from 'docz'; import styled from 'styled-components'; import { Container } from './Container'; import { Sidebar, Topbar } from '../shared'; import { breakpoints } from '../../styles/responsive'; import { useWindowSize } from '../../config'; import { Hamburguer } from '../shared/Sidebar/Hamburguer'; import { mainContext } from '../shared/Main'; import { IconLink } from '../shared/Topbar'; const Wrapper = styled.div` flex: 1; ${Container} { display: flex; min-height: 100%; ${p => p.theme.mq({ padding: ['0 10px', '0'], })} } `; const Header = styled.div` height: 60px; &:not(.fullPage) { transform: translateY(-30px); } text-align: right; `; const HLink = styled(Link)` &&& { line-height: 60px; margin: 0 20px; color: #101934; } `; const Document = styled.div` width: 100%; max-width: 1200px; margin: 0 auto; ${p => p.theme.mq({ padding: ['10px', '30px'], })} `; export const Page: FC = ({ children, doc, location }) => { const { home, fullpage } = doc; const { width } = useWindowSize(); const isAtLeastDesktop = width > breakpoints.tablet; const showSidebar = !Boolean(home); const { showing, setShowing } = useContext(mainContext); const menuParent = home || 'doc'; const pathname = location && location.pathname; return ( {!isAtLeastDesktop && } {fullpage ? ( {children} ) : ( {!isAtLeastDesktop && ( setShowing((s: any) => !s)} /> )} {isAtLeastDesktop && showSidebar && }
首页 主题 GitLab
{children}
)}
); };