Browse Source

fix: image src, wrap faqs in sections

fix/clarity-reference
Thomas Osmonson 4 years ago
committed by Thomas Osmonson
parent
commit
318baa7dda
  1. 25
      src/components/mdx/image.tsx
  2. 56
      src/pages/references/faqs/[slug].tsx

25
src/components/mdx/image.tsx

@ -24,23 +24,28 @@ const useImgix = (src: string) => {
srcset: undefined,
};
let _src = src;
let _srcSet = undefined;
const router = useRouter();
if (!src?.startsWith('http')) {
const path = src.startsWith('/') ? '' : getUrl(router.pathname);
_src = `${imgix + path + src + params}`;
}
const srcset = `${_src}&w=860&dpr=1&fit=max 1x,
_srcSet = `${_src}&w=860&dpr=1&fit=max 1x,
${_src}&w=480&fit=max&q=40&dpr=2 2x,
${_src}&w=480&fit=max&q=20&dpr=3 3x`;
const base = `${_src}&w=720&dpr=1&fit=max`;
const placeholder = `${_src}&w=40&dpr=1&fit=max`;
return {
srcset,
src: base,
placeholder,
};
const base = `${_src}&w=720&dpr=1&fit=max`;
const placeholder = `${_src}&w=40&dpr=1&fit=max`;
return {
srcset: _srcSet,
src: base,
placeholder,
};
} else {
return {
src: _src,
srcset: _srcSet,
};
}
};
const getAspectRatio = dimensions => {

56
src/pages/references/faqs/[slug].tsx

@ -20,35 +20,37 @@ const FAQItem = React.memo(({ faq, ...rest }: any) => {
const { isActive } = useActiveHeading(id);
return (
<Box as={AccordionItem} borderBottom={border()} {...rest}>
<Flex
as={AccordionButton}
_hover={{ color: color('accent') }}
css={css({
display: 'flex',
width: '100%',
outline: 'none',
alignItems: 'center',
justifyContent: 'space-between',
py: space('extra-loose'),
textAlign: 'left',
color: isActive ? color('accent') : color('text-title'),
':hover': {
color: color('accent'),
},
})}
>
<Components.h4 my="0px !important" id={id} color="currentColor">
{faq.title}
</Components.h4>
<Box color={color('text-caption')} pl={space('base-loose')}>
<ChevronIcon direction="down" size="22px" />
<Components.section>
<Box as={AccordionItem} borderBottom={border()} {...rest}>
<Flex
as={AccordionButton}
_hover={{ color: color('accent') }}
css={css({
display: 'flex',
width: '100%',
outline: 'none',
alignItems: 'center',
justifyContent: 'space-between',
py: space('extra-loose'),
textAlign: 'left',
color: isActive ? color('accent') : color('text-title'),
':hover': {
color: color('accent'),
},
})}
>
<Components.h4 my="0px !important" id={id} color="currentColor">
{faq.title}
</Components.h4>
<Box color={color('text-caption')} pl={space('base-loose')}>
<ChevronIcon direction="down" size="22px" />
</Box>
</Flex>
<Box pb={space('extra-loose')} as={AccordionPanel}>
{hydrate(faq.body, Components)}
</Box>
</Flex>
<Box pb={space('extra-loose')} as={AccordionPanel}>
{hydrate(faq.body, Components)}
</Box>
</Box>
</Components.section>
);
});

Loading…
Cancel
Save