Fix build errors

pull/1331/head
Kamran Ahmed 3 years ago
parent 7e0a392a87
commit 6bb1505db3
  1. 10
      components/md-renderer/index.tsx
  2. 14
      components/md-renderer/mdx-components/a.tsx
  3. 33
      components/md-renderer/mdx-components/iframe.tsx
  4. 7
      components/md-renderer/mdx-components/index.tsx
  5. 14
      components/md-renderer/mdx-components/li.tsx
  6. 10
      components/md-renderer/mdx-components/p.tsx
  7. 18
      components/md-renderer/mdx-components/ul.tsx
  8. 2
      content/videos/transport-protocols-tcp-vs-udp.md

@ -1,7 +1,9 @@
import React from 'react'; import React from 'react';
// @ts-ignore // @ts-ignore
import { MDXProvider } from '@mdx-js/react'; import { MDXProvider } from '@mdx-js/react';
import { ChakraProvider } from '@chakra-ui/react';
import MdxComponents from './mdx-components'; import MdxComponents from './mdx-components';
import { roadmapTheme } from '../../lib/theme';
type MdRendererType = { type MdRendererType = {
children: React.ReactNode children: React.ReactNode
@ -9,8 +11,10 @@ type MdRendererType = {
export default function MdRenderer(props: MdRendererType) { export default function MdRenderer(props: MdRendererType) {
return ( return (
<MDXProvider components={MdxComponents}> <ChakraProvider theme={roadmapTheme} resetCSS>
{props.children} <MDXProvider components={MdxComponents}>
</MDXProvider> {props.children}
</MDXProvider>
</ChakraProvider>
); );
}; };

@ -1,18 +1,26 @@
import React from 'react'; import React from 'react';
import { Link } from '@chakra-ui/react'; import styled from 'styled-components';
type EnrichedLinkProps = { type EnrichedLinkProps = {
href: string; href: string;
children: React.ReactNode children: React.ReactNode
} }
export default function EnrichedLink(props: EnrichedLinkProps) { const Link = styled.a`
font-weight: 600;
text-decoration: underline;
`;
const EnrichedLink = (props: EnrichedLinkProps) => {
// Is external URL or is a media URL // Is external URL or is a media URL
const isExternalUrl = /(^http(s)?:\/\/)|(\.(png|svg|jpeg|jpg)$)/.test(props.href); const isExternalUrl = /(^http(s)?:\/\/)|(\.(png|svg|jpeg|jpg)$)/.test(props.href);
return ( return (
<Link fontWeight={600} href={props.href} target={isExternalUrl ? '_blank' : '_self'} textDecoration='underline'> <Link href={props.href} target={isExternalUrl ? '_blank' : '_self'}>
{props.children} {props.children}
</Link> </Link>
); );
}; };
export default EnrichedLink;

@ -1,13 +1,40 @@
import { AspectRatio } from '@chakra-ui/react'; import styled from 'styled-components';
type IFrameProps = { type IFrameProps = {
title: string; title: string;
src: string; src: string;
}; };
const AspectRatioBox = styled.div`
position: relative;
max-width: 100%;
margin-bottom: 18px;
&:before {
height: 0;
content: "";
display: block;
padding-bottom: 50%;
}
& > iframe {
overflow: hidden;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
`;
export default function IFrame(props: IFrameProps) { export default function IFrame(props: IFrameProps) {
return ( return (
<AspectRatio maxW='100%' ratio={2} mb='18px'> <AspectRatioBox>
<iframe <iframe
frameBorder={0} frameBorder={0}
title={props.title} title={props.title}
@ -15,6 +42,6 @@ export default function IFrame(props: IFrameProps) {
allow={'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'} allow={'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture'}
allowFullScreen allowFullScreen
/> />
</AspectRatio> </AspectRatioBox>
); );
} }

@ -1,4 +1,5 @@
import P from './p'; import { Code } from '@chakra-ui/react';
import { P } from './p';
import Headings from './heading'; import Headings from './heading';
import { Pre } from './pre'; import { Pre } from './pre';
import BlockQuote from './blockquote'; import BlockQuote from './blockquote';
@ -7,10 +8,8 @@ import IFrame from './iframe';
import { Img } from './img'; import { Img } from './img';
import EnrichedLink from './a'; import EnrichedLink from './a';
import { BadgeLink } from './badge-link'; import { BadgeLink } from './badge-link';
import Ul from './ul'; import { Li, Ul } from './ul';
import Li from './li';
import PremiumBlock from './premium-block'; import PremiumBlock from './premium-block';
import { Code } from '@chakra-ui/react';
const MdxComponents = { const MdxComponents = {
p: P, p: P,

@ -1,14 +0,0 @@
import React from 'react';
import { ListItem, UnorderedList } from '@chakra-ui/react';
type LiProps = {
children: React.ReactNode;
};
export default function Li(props: LiProps) {
return (
<ListItem mb='7px'>
{props.children}
</ListItem>
);
}

@ -1,10 +1,14 @@
import React from 'react'; import React from 'react';
import { Text } from '@chakra-ui/react'; import { Text } from '@chakra-ui/react';
import styled from 'styled-components';
type EnrichedTextType = { type EnrichedTextType = {
children: React.ReactNode; children: React.ReactNode;
} }
export default function EnrichedText(props: EnrichedTextType) { export const P = styled.p`
return <Text lineHeight='27px' fontSize='16px' color='black' mb='18px'>{props.children}</Text>; line-height: 27px;
} font-size: 16px;
color: black;
margin-bottom: 18px;
`;

@ -1,14 +1,12 @@
import React from 'react'; import React from 'react';
import { UnorderedList } from '@chakra-ui/react'; import { UnorderedList } from '@chakra-ui/react';
import styled from 'styled-components';
type OlProps = { export const Ul = styled.ul`
children: React.ReactNode; margin-left: 40px;
}; margin-bottom: 18px;
`;
export default function Ul(props: OlProps) { export const Li = styled.li`
return ( margin-bottom: 7px;
<UnorderedList ml='40px' mb='18px'> `;
{props.children}
</UnorderedList>
);
}

@ -1 +1 @@
<iframe src="https://www.youtube.com/embed/37AFBZv4_6Y" title="Transport Protocols: TCP vs UDP" /> <iframe src="https://www.youtube.com/embed/37AFBZv4_6Y" title="Transport Protocols: TCP vs UDP" />

Loading…
Cancel
Save