Browse Source

fix: type styles, design updates, drop down

fix/enable-imgix
Thomas Osmonson 4 years ago
parent
commit
5b689c2d52
  1. 3
      package.json
  2. 5
      public/images/pages/build-an-app.svg
  3. 7
      public/images/pages/counter-tutorial.svg
  4. 7
      public/images/pages/todo-app.svg
  5. 2
      src/common/constants.ts
  6. 3
      src/common/utils/index.ts
  7. 27
      src/components/custom-blocks/page-reference.tsx
  8. 131
      src/components/header.tsx
  9. 21
      src/components/layouts/markdown-wrapper.tsx
  10. 2
      src/components/mdx/md-contents.tsx
  11. 11
      src/components/mdx/styles.tsx
  12. 16
      src/components/mdx/typography.ts
  13. 5
      src/components/search.tsx
  14. 111
      src/components/side-nav.tsx
  15. 19
      src/components/toc.tsx
  16. 47
      yarn.lock

3
package.json

@ -3,7 +3,7 @@
"version": "1.0.0",
"dependencies": {
"@blockstack/ui": "2.12.2-beta.0",
"@docsearch/react": "^1.0.0-alpha.24",
"@docsearch/react": "^1.0.0-alpha.26",
"@hashicorp/remark-plugins": "^3.0.0",
"@mdx-js/loader": "1.6.15",
"@mdx-js/mdx": "^1.6.15",
@ -11,6 +11,7 @@
"@next/mdx": "^9.4.4",
"@reach/accordion": "^0.10.5",
"@reach/tooltip": "^0.10.5",
"@styled-system/css": "^5.1.5",
"@styled-system/theme-get": "^5.1.2",
"@types/mdx-js__react": "^1.5.2",
"@types/node": "^14.0.27",

5
public/images/pages/build-an-app.svg

@ -1,9 +1,8 @@
<svg width="256" height="145" viewBox="0 0 256 145" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect y="0.439056" width="256" height="144" fill="#9985FF"/>
<path opacity="0.64" d="M84.0003 33.9388H148.391V98.105H84.0003V33.9388Z" fill="white"/>
<path d="M139.805 59.6064L169.854 110.939H109.756L139.805 59.6064Z" fill="white"/>
<path d="M172 63.8838C172 68.6089 168.156 72.4393 163.414 72.4393C158.673 72.4393 154.829 68.6089 154.829 63.8838C154.829 59.1587 158.673 55.3283 163.414 55.3283C168.156 55.3283 172 59.1587 172 63.8838Z" fill="#BDB0FF"/>
<path d="M98.3995 59.216L105.077 52.7993L98.3995 46.3827L96.4916 48.216L101.261 52.7993L96.4916 57.3826L98.3995 59.216Z" fill="#9985FF"/>
<path opacity="0.64" fill-rule="evenodd" clip-rule="evenodd" d="M148.391 33.9388H84.0003V98.105H148.391V33.9388ZM105.077 52.7993L98.3995 59.216L96.4916 57.3826L101.261 52.7993L96.4916 48.216L98.3995 46.3827L105.077 52.7993Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M148.391 74.4239V98.6889H116.782L139.806 59.6064L148.391 74.4239Z" fill="#9985FF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M148.391 74.4238V98.6888H116.782L139.806 59.6063L148.391 74.4238Z" fill="white"/>
<path d="M139.805 59.6064L169.854 110.939H109.756L139.805 59.6064Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 976 B

7
public/images/pages/counter-tutorial.svg

@ -1,11 +1,16 @@
<svg width="257" height="145" viewBox="0 0 257 145" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="257" height="145">
<rect x="0.697876" y="0.0744896" width="256" height="144" fill="#9985FF"/>
</mask>
<g mask="url(#mask0)">
<rect x="0.697876" y="0.0744896" width="256" height="144" fill="#9985FF"/>
<g style="mix-blend-mode:multiply">
<rect x="0.697876" y="0.0744896" width="256" height="144" fill="#9985FF"/>
</g>
<path d="M32.6979 40.0745C32.6979 35.6562 36.2796 32.0745 40.6979 32.0745H216.698C221.116 32.0745 224.698 35.6562 224.698 40.0745V144.074H32.6979V40.0745Z" fill="white"/>
<path d="M32.6979 40.0745C32.6979 35.6562 36.2796 32.0745 40.6979 32.0745H216.698C221.116 32.0745 224.698 35.6562 224.698 40.0745V155.716H32.6979V40.0745Z" fill="white"/>
<rect x="57.6979" y="57.0745" width="64" height="70" rx="3" fill="#F0F0F5" stroke="#F0F0F5" stroke-width="2"/>
<path d="M94.7459 96.2425V93.9145H83.6579V96.2425H94.7459Z" fill="#A1A7B3"/>
<rect x="135.698" y="57.0745" width="64" height="70" rx="3" fill="white" stroke="#F0F0F5" stroke-width="2"/>
<path d="M174.186 92.5945H169.242V87.6505H166.746V92.5945H161.802V95.1145H166.746V100.058H169.242V95.1145H174.186V92.5945Z" fill="#A1A7B3"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 907 B

After

Width:  |  Height:  |  Size: 1.1 KiB

7
public/images/pages/todo-app.svg

@ -1,6 +1,10 @@
<svg width="256" height="145" viewBox="0 0 256 145" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect y="0.0744896" width="256" height="144" fill="#9985FF"/>
<path d="M32 40.0745C32 35.6562 35.5817 32.0745 40 32.0745H216C220.418 32.0745 224 35.6562 224 40.0745V144.074H32V40.0745Z" fill="white"/>
<mask id="mask0" mask-type="alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="256" height="145">
<rect y="0.0744896" width="256" height="144" fill="#9985FF"/>
</mask>
<g mask="url(#mask0)">
<path d="M32 40.6568C32 35.9169 35.5817 32.0745 40 32.0745H216C220.418 32.0745 224 35.9169 224 40.6568V152.227H32V40.6568Z" fill="white"/>
<path d="M48 60.0745C48 57.8654 49.7909 56.0745 52 56.0745H60C62.2091 56.0745 64 57.8654 64 60.0745V68.0745C64 70.2836 62.2091 72.0745 60 72.0745H52C49.7909 72.0745 48 70.2836 48 68.0745V60.0745Z" fill="#08018A"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M59.5236 61.5375C59.8202 61.8267 59.8262 62.3015 59.537 62.5981L55.637 66.5981C55.4958 66.7428 55.3022 66.8245 55.1 66.8245C54.8978 66.8245 54.7042 66.7428 54.563 66.5981L52.463 64.4442C52.1738 64.1476 52.1798 63.6728 52.4764 63.3836C52.773 63.0945 53.2478 63.1005 53.537 63.3971L55.1 65.0001L58.463 61.5509C58.7522 61.2543 59.227 61.2483 59.5236 61.5375Z" fill="white"/>
<path opacity="0.32" d="M76 61.0745C76 59.9699 76.8954 59.0745 78 59.0745H162C163.105 59.0745 164 59.9699 164 61.0745V68.0745C164 69.1791 163.105 70.0745 162 70.0745H78C76.8954 70.0745 76 69.1791 76 68.0745V61.0745Z" fill="#08018A"/>
@ -10,4 +14,5 @@
<path fill-rule="evenodd" clip-rule="evenodd" d="M60 86.0745H52C50.8954 86.0745 50 86.9699 50 88.0745V96.0745C50 97.1791 50.8954 98.0745 52 98.0745H60C61.1046 98.0745 62 97.1791 62 96.0745V88.0745C62 86.9699 61.1046 86.0745 60 86.0745ZM52 84.0745C49.7909 84.0745 48 85.8654 48 88.0745V96.0745C48 98.2836 49.7909 100.074 52 100.074H60C62.2091 100.074 64 98.2836 64 96.0745V88.0745C64 85.8654 62.2091 84.0745 60 84.0745H52Z" fill="#08018A" fill-opacity="0.2"/>
<path d="M48 116.074C48 113.865 49.7909 112.074 52 112.074H60C62.2091 112.074 64 113.865 64 116.074V124.074C64 126.284 62.2091 128.074 60 128.074H52C49.7909 128.074 48 126.284 48 124.074V116.074Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M60 114.074H52C50.8954 114.074 50 114.97 50 116.074V124.074C50 125.179 50.8954 126.074 52 126.074H60C61.1046 126.074 62 125.179 62 124.074V116.074C62 114.97 61.1046 114.074 60 114.074ZM52 112.074C49.7909 112.074 48 113.865 48 116.074V124.074C48 126.284 49.7909 128.074 52 128.074H60C62.2091 128.074 64 126.284 64 124.074V116.074C64 113.865 62.2091 112.074 60 112.074H52Z" fill="#08018A" fill-opacity="0.12"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

2
src/common/constants.ts

@ -1,4 +1,4 @@
export const SIDEBAR_WIDTH = 240;
export const SIDEBAR_WIDTH = 208;
export const TOC_WIDTH = 208;
export const CONTENT_MAX_WIDTH = 1104;
export const PAGE_WIDTH = 1216;

3
src/common/utils/index.ts

@ -69,3 +69,6 @@ const getTitleFromHeading = (headings?: any[]) =>
: undefined;
export const getTitle = ({ title, headings }): string => title || getTitleFromHeading(headings);
export const transition = (timing = '0.2s', properties = 'all') =>
`${properties} ${timing} cubic-bezier(0.23, 1, 0.32, 1)`;

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

@ -1,6 +1,6 @@
import React from 'react';
import { Box, Flex, BoxProps, color, Grid, space, transition } from '@blockstack/ui';
import { border, onlyText } from '@common/utils';
import { Box, Flex, BoxProps, color, Grid, space } from '@blockstack/ui';
import { border, onlyText, transition } from '@common/utils';
import { useTouchable } from '@common/hooks/use-touchable';
import { Caption, Text } from '@components/typography';
import Link from 'next/link';
@ -19,7 +19,6 @@ const Image = ({
willChange: 'transform',
}}
width="100%"
transition="all 0.2s cubic-bezier(0.23, 1, 0.32, 1)"
size={size}
{...rest}
>
@ -61,17 +60,22 @@ const InlineCard = ({ page }) => {
<Flex
border={border()}
flexDirection={['column', 'column', 'row']}
borderColor={hover ? '#9985FF' : color('border')}
p={space('base-loose')}
borderRadius="12px"
align="center"
transition={transition}
transition={transition()}
boxShadow={hover ? 'mid' : 'none'}
position="relative"
{...bind}
>
<Box flexShrink={0} size="64px" overflow="hidden" borderRadius={'12px'}>
<Image size="64px" src={page.images.sm} />
<Image
transition={transition('0.45s')}
transform={(hover || active) && 'scale(1.12)'}
style={{ willChange: 'transform' }}
size="64px"
src={page.images.sm}
/>
</Box>
<Flex
flexDirection="column"
@ -105,7 +109,7 @@ const InlineCard = ({ page }) => {
bg={color('border')}
textTransform="capitalize"
color={color('invert')}
transition={transition}
transition={transition()}
>
{tag}
</Flex>
@ -127,7 +131,14 @@ const GridCard: React.FC<BoxProps & { page?: any }> = ({ page, ...rest }) => {
return (
<Box position="relative" {...rest} {...bind}>
<Box borderRadius="12px" overflow="hidden" mb={space('loose')}>
<Image width="100%" size="100%" src={page?.images?.large} />
<Image
width="100%"
size="100%"
transition={transition('0.45s')}
transform={(hover || active) && 'scale(1.08)'}
style={{ willChange: 'transform' }}
src={page?.images?.large}
/>
</Box>
<Flex alignItems="flex-start" justifyContent="flex-start" flexDirection="column">
<Title color={hover ? color('accent') : color('text-title')} mb={space('tight')}>

131
src/components/header.tsx

@ -1,5 +1,16 @@
import React from 'react';
import { Flex, Box, BlockstackIcon, Stack, color, space, BoxProps } from '@blockstack/ui';
import {
Flex,
Box,
BlockstackIcon,
Stack,
color,
space,
BoxProps,
ChevronIcon,
FlexProps,
Fade,
} from '@blockstack/ui';
import { Link, Text } from '@components/typography';
import MenuIcon from 'mdi-react/MenuIcon';
import CloseIcon from 'mdi-react/CloseIcon';
@ -9,6 +20,9 @@ import { css } from '@styled-system/css';
import NextLink from 'next/link';
import { ColorModeButton } from '@components/color-mode-button';
import { PAGE_WIDTH } from '@common/constants';
import { border, transition } from '@common/utils';
import { getCapsizeStyles } from '@components/mdx/typography';
import { useTouchable } from '@common/hooks/use-touchable';
const MenuButton = ({ ...rest }: any) => {
const { isOpen, handleOpen, handleClose } = useMobileMenuState();
@ -27,13 +41,13 @@ const MenuButton = ({ ...rest }: any) => {
};
const HeaderWrapper: React.FC<any> = React.forwardRef((props, ref) => (
<Box top={2} ref={ref} width="100%" {...props} />
<Box as="header" ref={ref} width="100%" position="relative" zIndex={9999} {...props} />
));
const nav = [
{
label: 'Developers',
chilren: [
label: 'Start building',
children: [
{
label: 'Documentation',
},
@ -58,30 +72,91 @@ const HeaderTextItem: React.FC<BoxProps> = ({ children, ...rest }) => (
<Text
color={color('invert')}
css={css({
fontWeight: 500,
fontSize: '16px',
lineHeight: '24px',
padding: '0.05px 0',
'::before': {
content: "''",
marginTop: '-0.38948863636363634em',
display: 'block',
height: 0,
},
'::after': {
content: "''",
marginBottom: '-0.38948863636363634em',
display: 'block',
height: 0,
},
...getCapsizeStyles(16, 26),
...rest,
})}
>
{' '}
{children}
</Text>
);
const NavItem: React.FC<FlexProps & { item: any }> = ({ item, ...props }) => {
const { hover, active, bind } = useTouchable({
behavior: 'link',
});
return (
<Flex justifyContent="center" position="relative" {...props} {...bind}>
<Link as="a">
<HeaderTextItem>{item.label}</HeaderTextItem>
</Link>
{item.children ? (
<Box ml={space('extra-tight')}>
<ChevronIcon direction="down" />
</Box>
) : null}
{item.children ? (
<Fade in={hover || active}>
{styles => (
<Box
pt={space('base-loose')}
top="100%"
position="absolute"
transform="translateX(-5px)"
zIndex={99999999}
minWidth="200px"
style={{ ...styles }}
>
<Box
borderRadius="12px"
border={border()}
bg={color('bg')}
overflow="hidden"
boxShadow="0 0 8px 0 rgba(15,17,23,.03), 0 16px 40px 0 rgba(15,17,23,.06)"
>
{item.children.map((child, _key) => (
<Box
_hover={{
bg: color('accent'),
color: color('bg'),
cursor: 'pointer',
}}
transition={transition()}
color={color('text-title')}
borderBottom={_key < item.children.length - 1 && border()}
px={space('base')}
py={space('base-loose')}
>
<HeaderTextItem color="currentColor">{child.label}</HeaderTextItem>
</Box>
))}
</Box>
</Box>
)}
</Fade>
) : null}
</Flex>
);
};
const Navigation: React.FC<BoxProps> = props => {
return (
<Box
as="nav"
position="relative"
zIndex={99999999}
display={['none', 'none', 'block']}
transform="translateY(2px)"
{...props}
>
<Stack mr={space('base')} isInline spacing={space('extra-loose')}>
{nav.map((item, key) => (
<NavItem item={item} key={key} />
))}
</Stack>
</Box>
);
};
const Header = ({ hideSubBar, ...rest }: any) => {
return (
<>
@ -103,24 +178,16 @@ const Header = ({ hideSubBar, ...rest }: any) => {
<Link as="a">
<Flex align="center">
<Box color={color('invert')} mr={space('tight')}>
<BlockstackIcon size="18px" />
<BlockstackIcon size="20px" />
</Box>
<Box>
<Box transform="translateY(1px)">
<HeaderTextItem>Blockstack</HeaderTextItem>
</Box>
</Flex>
</Link>
</NextLink>
<Flex align="center">
<Box display={['none', 'none', 'block']}>
<Stack mr={space('base')} isInline spacing={space('extra-loose')}>
{nav.map(item => (
<Box>
<HeaderTextItem>{item.label}</HeaderTextItem>
</Box>
))}
</Stack>
</Box>
<Navigation />
<ColorModeButton />
<MenuButton />
</Flex>

21
src/components/layouts/markdown-wrapper.tsx

@ -7,14 +7,19 @@ import { Caption, Text } from '@components/typography';
import { useRouter } from 'next/router';
import dynamic from 'next/dynamic';
import { getTitle } from '@common/utils';
import { css } from '@styled-system/css';
import { getHeadingStyles } from '@components/mdx/typography';
const Search = dynamic(() => import('@components/search'));
const PageTop = props => {
const router = useRouter();
const isHome = router.pathname === '/';
return (
<Box px={space('extra-loose')} mb="64px">
<Box
pl={space('extra-loose')}
pr={['extra-loose', 'extra-loose', 'unset']}
mb={['extra-loose', 'extra-loose', '64px']}
>
<Flex>
<H1 mb="0 !important">{getTitle(props)}</H1>
{isHome ? (
@ -24,12 +29,18 @@ const PageTop = props => {
) : null}
</Flex>
{props.description ? (
<Box mt="24px !important">
<Text>{props.description}</Text>{' '}
<Box mt="40px !important">
<Text
css={css({
...getHeadingStyles('h4'),
})}
>
{props.description}
</Text>{' '}
</Box>
) : null}
<Stack isInline spacing={space('base')} mt={space('base')}>
<Stack isInline spacing={space('base')} mt={space('extra-loose')}>
{props.experience ? <Caption textTransform="capitalize">{props.experience}</Caption> : null}
{!isHome && props.duration ? <Caption>{props.duration}</Caption> : null}
</Stack>

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

@ -40,7 +40,7 @@ export const MDContents: React.FC<any> = React.memo(
pr="base-loose"
>
<Box position="sticky" top={0} pt="64px">
<Search mb={space('base')} />
<Search mb={space('extra-loose')} />
{headings?.length > 1 ? (
<TableOfContents
pl={space('base')}

11
src/components/mdx/styles.tsx

@ -6,6 +6,12 @@ import { border } from '@common/utils';
import { getCapsizeStyles } from '@components/mdx/typography';
export const MdxOverrides = createGlobalStyle`
* {
font-feature-settings: 'ss01' on;
backface-visibility: hidden;
-webkit-font-smoothing: antialiased;
-webkit-font-smoothing: subpixel-antialiased;
}
html, body {
font-family: 'Soehne', Inter, sans-serif;
}
@ -13,9 +19,8 @@ html, body {
pad: "0";
}
img{
//image-rendering: auto;
//image-rendering: crisp-edges;
//image-rendering: pixelated;
image-rendering: crisp-edges;
will-change: transform;
}
.headroom {
top: 0;

16
src/components/mdx/typography.ts

@ -11,7 +11,6 @@ const fontMetrics = {
export const baseTypeStyles = {
letterSpacing: '-0.01em',
display: 'flex',
fontFeatureSettings: `'ss01' on`,
fontFamily: `'Soehne', Inter, sans-serif`,
};
@ -24,21 +23,22 @@ export const getCapsizeStyles = (fontSize, leading) =>
const h1 = {
fontWeight: 600,
...getCapsizeStyles(36, 48),
...getCapsizeStyles(36, 52),
};
const h2 = {
fontWeight: 600,
...getCapsizeStyles(24, 36),
fontWeight: 500,
...getCapsizeStyles(24, 40),
};
const h3 = {
fontWeight: 400,
...getCapsizeStyles(20, 32),
fontWeight: 500,
...getCapsizeStyles(18, 32),
};
const h4 = {
fontWeight: 500,
...getCapsizeStyles(18, 32),
fontWeight: 400,
...getCapsizeStyles(20, 36),
};
const h5 = {

5
src/components/search.tsx

@ -70,7 +70,9 @@ export const SearchBox: React.FC<BoxProps> = React.memo(props => {
[setIsOpen]
);
useDocSearchKeyboardEvents({ isOpen, onOpen, onClose });
const searchButtonRef = React.useRef(null);
useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, searchButtonRef });
return (
<>
@ -106,6 +108,7 @@ export const SearchBox: React.FC<BoxProps> = React.memo(props => {
{...props}
>
<Flex
ref={searchButtonRef}
onClick={onOpen}
px={space('base-tight')}
py={space('tight')}

111
src/components/side-nav.tsx

@ -8,7 +8,9 @@ import nav from '@common/navigation.yaml';
import ArrowLeftIcon from 'mdi-react/ArrowLeftIcon';
import { getTitle, slugify } from '@common/utils';
import { useRouter } from 'next/router';
import { getCapsizeStyles } from '@components/mdx/typography';
import { Text } from '@components/typography';
import { css } from '@styled-system/css';
const Wrapper: React.FC<BoxProps & { containerProps?: BoxProps }> = ({
width = `${SIDEBAR_WIDTH}px`,
containerProps,
@ -41,27 +43,50 @@ const capitalize = s => {
const convertToTitle = (path: string) =>
!path ? null : path === '/' ? 'Home' : capitalize(path.replace('/', '').replace(/-/g, ' '));
const PageItem = ({ isActive, color: _color = color('text-caption'), ...props }: any) => (
<Flex
_hover={{
cursor: 'pointer',
color: color('text-title'),
}}
mb={space('tight')}
fontSize="16px"
color={isActive ? color('accent') : _color}
{...props}
/>
const PageItem = React.forwardRef(
(
{
isActive,
color: _color = color('text-caption'),
children,
mb = space('base'),
isTopLevel,
...props
}: any,
ref: any
) => {
const typeStyles = isTopLevel ? getCapsizeStyles(16, 26) : getCapsizeStyles(14, 20);
return (
<Text
ref={ref}
css={css({
display: 'block',
...typeStyles,
color: isActive ? color('accent') : isTopLevel ? color('text-title') : _color,
mb,
':hover': {
color: isTopLevel ? color('accent') : color('text-title'),
},
})}
{...props}
>
{children}
</Text>
);
}
);
const SectionTitle: React.FC<BoxProps> = props => (
<Box
color={color('text-title')}
fontSize="18px"
mb={space('tight')}
fontWeight="400"
{...props}
/>
const SectionTitle: React.FC<BoxProps> = ({ children, ...rest }) => (
<Text
css={css({
display: 'block',
...getCapsizeStyles(16, 26),
color: color('text-title'),
...rest,
})}
>
{children}
</Text>
);
const getRoutePath = path => routes.find(route => route.path.endsWith(path));
@ -104,6 +129,7 @@ const ChildSection: React.FC<BoxProps & { sections?: any }> = ({ sections, ...re
textTransform="uppercase"
fontSize="12px"
fontWeight={500}
mb={space('base-loose')}
>
{section.title}
</SectionTitle>
@ -113,12 +139,22 @@ const ChildSection: React.FC<BoxProps & { sections?: any }> = ({ sections, ...re
});
const BackItem = props => (
<PageItem align="center" color={color('text-caption')} {...props}>
<Flex
color={color('text-caption')}
_hover={{
cursor: 'pointer',
color: color('text-title'),
}}
align="center"
{...props}
>
<Box mr={space('extra-tight')}>
<ArrowLeftIcon size="16px" />
</Box>
Back
</PageItem>
<PageItem mb={'0px'} color={'currentColor'}>
Back
</PageItem>
</Flex>
);
const Navigation = () => {
@ -175,8 +211,10 @@ const Navigation = () => {
if (selected.type === 'page') {
return (
<Box>
<BackItem onClick={handleBack} mb={space('base')} />
<SectionTitle>{convertToTitle(selected.items.path)}</SectionTitle>
<BackItem onClick={handleBack} mb={space('extra-loose')} />
<Box mb={space('loose')}>
<SectionTitle>{convertToTitle(selected.items.path)}</SectionTitle>
</Box>
<Box>
{selected.items ? <ChildPages handleClick={handleClick} items={selected.items} /> : null}
{selected.items?.sections ? (
@ -195,29 +233,12 @@ const Navigation = () => {
if (selected.type === 'default') {
return selected.items.map((section, i) => {
const itemProps =
i === 0
? {
color: color('text-title'),
mb: space('tight'),
fontSize: '18px',
_hover: {
color: color('accent'),
cursor: 'pointer',
},
}
: {};
return (
<Box mb="40px">
{section.title ? (
<Flex width="100%" align="center" mb={space('extra-tight')}>
<Flex width="100%" align="center" mb={space('loose')}>
<SectionTitle>{section.title}</SectionTitle>
<Box
transform="translateY(-3px)"
color={color('text-caption')}
size="16px"
ml={space('extra-tight')}
>
<Box color={color('text-caption')} size="16px" ml={space('extra-tight')}>
<ChevronIcon direction="down" />
</Box>
</Flex>
@ -237,7 +258,7 @@ const Navigation = () => {
<PageItem
as="a"
href={path}
{...itemProps}
isTopLevel={i === 0}
isActive={router.pathname.endsWith(path)}
onClick={() => handleClick(page)}
>

19
src/components/toc.tsx

@ -1,11 +1,12 @@
import React from 'react';
import { Box, Grid, color, space, BoxProps } from '@blockstack/ui';
import { TOC_WIDTH } from '@common/constants';
import { slugify } from '@common/utils';
import { Text } from '@components/typography';
import { Link } from '@components/mdx';
import { useActiveHeading } from '@common/hooks/use-active-heading';
import NextLink from 'next/link';
import { getHeadingStyles } from '@components/mdx/typography';
import { css } from '@styled-system/css';
const getLevelPadding = (level: number) => {
switch (level) {
case 2:
@ -18,7 +19,7 @@ const getLevelPadding = (level: number) => {
};
const Item = ({ slug, label, level, limit }) => {
const { isActive: _isActive, doChangeActiveSlug, slugInView } = useActiveHeading(slug);
const { isActive: _isActive, slugInView } = useActiveHeading(slug);
const isOnScreen = slugInView === slug;
const isActive = isOnScreen || _isActive;
@ -35,6 +36,11 @@ const Item = ({ slug, label, level, limit }) => {
color: color('accent'),
}}
pointerEvents={isActive ? 'none' : 'unset'}
css={css({
display: 'block',
...getHeadingStyles('h6'),
mb: space('base-tight'),
})}
>
<Box as="span" dangerouslySetInnerHTML={{ __html: label }} />
</Link>
@ -65,8 +71,13 @@ export const TableOfContents = ({
<Box position="relative" display={display}>
<Box flexShrink={0} width="100%" {...rest}>
{!noLabel && (
<Box mb={space('extra-tight')}>
<Text fontWeight="bold" fontSize="14px">
<Box mb={space('base')}>
<Text
css={css({
...getHeadingStyles('h6'),
fontWeight: 500,
})}
>
{label}
</Text>
</Box>

47
yarn.lock

@ -1301,19 +1301,19 @@
use-events "^1.4.1"
use-onclickoutside "^0.3.1"
"@docsearch/css@^1.0.0-alpha.24":
version "1.0.0-alpha.24"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-1.0.0-alpha.24.tgz#a2e8d7e7ac50ebea17f90e974c5174b0d1a5c855"
integrity sha512-BCNomH+wdpg+hWTCczwQATS4hbztOvzU/6GXco+KIgVrvpTovtPsS7BYTQMCRhs2gPSk3p3DqgW95mwCoAvt0w==
"@docsearch/react@^1.0.0-alpha.24":
version "1.0.0-alpha.24"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-1.0.0-alpha.24.tgz#c0fb18e0df9494b86e50588892a0b25e293aa0ac"
integrity sha512-abfYBMrZcxmUhyxjdYPCRqBCC5XMilKEmondjkjUQG0W1sYmpjrVOMYBiTq6ZTW+7urVvXPjD9bm0fBZnlI9ow==
dependencies:
"@docsearch/css" "^1.0.0-alpha.24"
"@francoischalifour/autocomplete-core" "^1.0.0-alpha.24"
"@francoischalifour/autocomplete-preset-algolia" "^1.0.0-alpha.24"
"@docsearch/css@^1.0.0-alpha.26":
version "1.0.0-alpha.26"
resolved "https://registry.yarnpkg.com/@docsearch/css/-/css-1.0.0-alpha.26.tgz#a2f9b61168d527600b0e3f31c0f04998002f3aa2"
integrity sha512-YAa7R6O2MMdRtxTaMB3TTfeelhpf01J1xtnGZEQa7LNA64QO8BErceQIMQq5/ZMXnGViK/eUjqSVyCu7uzYE5w==
"@docsearch/react@^1.0.0-alpha.26":
version "1.0.0-alpha.26"
resolved "https://registry.yarnpkg.com/@docsearch/react/-/react-1.0.0-alpha.26.tgz#98b736d7de951bfa55cf3d0eb3639f93c9dd1db2"
integrity sha512-2eKIcUXuWbGgz6/xF+p7kYyd1IVGcnB8r+oIkTD6Tqtq0VGzZmf9ZPCOX37G38pVIJXAAxmtAb7oPO311xGWNQ==
dependencies:
"@docsearch/css" "^1.0.0-alpha.26"
"@francoischalifour/autocomplete-core" "^1.0.0-alpha.26"
"@francoischalifour/autocomplete-preset-algolia" "^1.0.0-alpha.26"
algoliasearch "^4.0.0"
"@emotion/is-prop-valid@^0.8.1", "@emotion/is-prop-valid@^0.8.8":
@ -1338,15 +1338,15 @@
resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed"
integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==
"@francoischalifour/autocomplete-core@^1.0.0-alpha.24":
version "1.0.0-alpha.24"
resolved "https://registry.yarnpkg.com/@francoischalifour/autocomplete-core/-/autocomplete-core-1.0.0-alpha.24.tgz#fc71704a17cf9326a66d97134508abdf02313181"
integrity sha512-rdWCKeIeDYjUXokdoyRNrFTreGZ8WLO/mhxAIWyLJ8ymdfXsortJqPL3fSDe57khXllGaZc/qxNsZi5RrpDRmQ==
"@francoischalifour/autocomplete-core@^1.0.0-alpha.26":
version "1.0.0-alpha.26"
resolved "https://registry.yarnpkg.com/@francoischalifour/autocomplete-core/-/autocomplete-core-1.0.0-alpha.26.tgz#fc9ec90a62f0665c7092d19a649c751fe3794de3"
integrity sha512-XUXAGVx0My9isShokR1QB/oPFQiaPYDCouoTZTN+DISQw5AK6kGZUCFFXJSRNHTxBq1/0e70DYEiQa8E+rT/Og==
"@francoischalifour/autocomplete-preset-algolia@^1.0.0-alpha.24":
version "1.0.0-alpha.24"
resolved "https://registry.yarnpkg.com/@francoischalifour/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.0.0-alpha.24.tgz#f305d529d9e6c31b7e14d7aff45e912a23b187e5"
integrity sha512-LHcbVKZaki42J30zg30ZoAuEJVysfIMSE91JT9YuOnpch+26hC8Vff9VlCs+6ACYxXGuGHdX7uuKYOx7GcoQ3A==
"@francoischalifour/autocomplete-preset-algolia@^1.0.0-alpha.26":
version "1.0.0-alpha.26"
resolved "https://registry.yarnpkg.com/@francoischalifour/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.0.0-alpha.26.tgz#3e20315d43dfef6c676cab4267974de70c2f6ec2"
integrity sha512-RrayxZgvTzpwq+RqEIpVn2UOEFLwa+HADCr2I3UI05o/OGU7Wc6LltpQy54scR+FlAIk6qTJwp5Nw/ecJn6xXg==
"@hashicorp/remark-plugins@^3.0.0":
version "3.0.0"
@ -9588,11 +9588,6 @@ vm-browserify@^1.0.1:
resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0"
integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==
"vscode-textmate@git+https://github.com/octref/vscode-textmate.git":
version "4.0.1"
uid e65aabe2227febda7beaad31dd0fca1228c5ddf3
resolved "git+https://github.com/octref/vscode-textmate.git#e65aabe2227febda7beaad31dd0fca1228c5ddf3"
"vscode-textmate@https://github.com/octref/vscode-textmate":
version "4.0.1"
resolved "https://github.com/octref/vscode-textmate#e65aabe2227febda7beaad31dd0fca1228c5ddf3"

Loading…
Cancel
Save