Browse Source

fix: typestyles #689, add toc back in

fix/enable-imgix
Thomas Osmonson 5 years ago
parent
commit
7ba84b6b19
  1. 23
      src/components/custom-blocks/page-reference.tsx
  2. 11
      src/components/mdx/md-contents.tsx

23
src/components/custom-blocks/page-reference.tsx

@ -7,6 +7,7 @@ import Link from 'next/link';
import routes from '@common/routes'; import routes from '@common/routes';
import { Img } from '@components/mdx/image'; import { Img } from '@components/mdx/image';
import { css } from '@styled-system/css'; import { css } from '@styled-system/css';
import { getCapsizeStyles, getHeadingStyles } from '@components/mdx/typography';
const Image = ({ const Image = ({
src, src,
isHovered, isHovered,
@ -36,15 +37,27 @@ const Image = ({
); );
const Title = ({ children, ...props }: BoxProps) => ( const Title = ({ children, ...props }: BoxProps) => (
<Text fontWeight="500" display="block" {...props}> <Text
css={css({
...getHeadingStyles('h3'),
})}
{...props}
>
{children} {children}
</Text> </Text>
); );
const Description = ({ children, ...props }) => ( const Description = ({ children, ...props }) => (
<Caption maxWidth="50ch" {...props}> <Text
{...props}
css={css({
...getCapsizeStyles(16, 26),
mt: space('base-tight'),
color: color('text-body'),
})}
>
{children} {children}
</Caption> </Text>
); );
const FloatingLink = ({ href, ...props }: any) => ( const FloatingLink = ({ href, ...props }: any) => (
@ -195,8 +208,8 @@ export const PageReference: React.FC<BoxProps> = React.memo(({ children }) => {
<Grid <Grid
width="100%" width="100%"
mt={space('extra-loose')} mt={space('extra-loose')}
gridColumnGap={space('loose')} gridColumnGap={space('extra-loose')}
gridRowGap={space('loose')} gridRowGap={space('extra-loose')}
gridTemplateColumns={[ gridTemplateColumns={[
`repeat(1, 1fr)`, `repeat(1, 1fr)`,
`repeat(${pages.length === 1 ? 1 : 2}, 1fr)`, `repeat(${pages.length === 1 ? 1 : 2}, 1fr)`,

11
src/components/mdx/md-contents.tsx

@ -15,7 +15,7 @@ const Search = dynamic(() => import('@components/search'));
export const MDContents: React.FC<any> = ({ pageTop: PageTop = null, headings, children }) => { export const MDContents: React.FC<any> = ({ pageTop: PageTop = null, headings, children }) => {
const router = useRouter(); const router = useRouter();
const isHome = router?.pathname === '/'; const isHome = router.pathname === '/';
const TOCShowing = !isHome && headings && headings?.length > 1; const TOCShowing = !isHome && headings && headings?.length > 1;
return ( return (
@ -38,7 +38,14 @@ export const MDContents: React.FC<any> = ({ pageTop: PageTop = null, headings, c
> >
<Box position="sticky" top={0} pt="64px"> <Box position="sticky" top={0} pt="64px">
<Search mb={space('extra-loose')} /> <Search mb={space('extra-loose')} />
{TOCShowing ? null : null} {TOCShowing ? (
<TableOfContents
pl={space('base')}
borderLeft={border()}
headings={headings}
limit={2}
/>
) : null}
</Box> </Box>
</Box> </Box>
) : null} ) : null}

Loading…
Cancel
Save