Skip to content

Commit

Permalink
Add blog posts for React 19 Beta (#6778)
Browse files Browse the repository at this point in the history
* Blog posts for React 19

* Feedback

* Feedback

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Josh Story <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Noah Lemen <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Matt Carroll <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Matt Carroll <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Noah Lemen <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Noah Lemen <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Noah Lemen <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Noah Lemen <[email protected]>

* Update src/content/blog/2024/04/25/react-19.md

* Update src/content/blog/2024/04/25/react-19.md

Co-authored-by: Matt Carroll <[email protected]>

* Thanks

* Apply suggestions from code review

Co-authored-by: Matt Carroll <[email protected]>
Co-authored-by: Sebastian Silbermann <[email protected]>

* Feedback

* nit

* Issue link

---------

Co-authored-by: Josh Story <[email protected]>
Co-authored-by: Noah Lemen <[email protected]>
Co-authored-by: Matt Carroll <[email protected]>
Co-authored-by: Sebastian Silbermann <[email protected]>
  • Loading branch information
5 people authored Apr 25, 2024
1 parent 4f55010 commit 191852a
Show file tree
Hide file tree
Showing 13 changed files with 2,092 additions and 29 deletions.
81 changes: 78 additions & 3 deletions src/components/MDX/ConsoleBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ interface ConsoleBlockProps {
children: React.ReactNode;
}

interface ConsoleBlockMultiProps {
children: React.ReactNode;
}

const Box = ({
width = '60px',
height = '17px',
Expand All @@ -29,7 +33,7 @@ const Box = ({
<div className={className} style={{width, height, ...customStyles}}></div>
);

function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
export function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
let message: React.ReactNode | null;
if (typeof children === 'string') {
message = children;
Expand All @@ -38,7 +42,10 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
}

return (
<div className="mb-4 text-secondary" translate="no" dir="ltr">
<div
className="console-block mb-4 text-secondary bg-wash dark:bg-wash-dark rounded-lg"
translate="no"
dir="ltr">
<div className="flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80">
<div className="px-4 py-2 border-gray-300 dark:border-gray-90 border-r">
<Box className="bg-gray-300 dark:bg-gray-70" width="15px" />
Expand Down Expand Up @@ -73,4 +80,72 @@ function ConsoleBlock({level = 'error', children}: ConsoleBlockProps) {
);
}

export default ConsoleBlock;
export function ConsoleBlockMulti({children}: ConsoleBlockMultiProps) {
return (
<div
className="console-block mb-4 text-secondary bg-wash dark:bg-wash-dark rounded-lg"
translate="no"
dir="ltr">
<div className="flex w-full rounded-t-lg bg-gray-200 dark:bg-gray-80">
<div className="px-4 py-2 border-gray-300 dark:border-gray-90 border-r">
<Box className="bg-gray-300 dark:bg-gray-70" width="15px" />
</div>
<div className="flex text-sm px-4">
<div className="border-b-2 border-gray-300 dark:border-gray-90 text-tertiary dark:text-tertiary-dark">
Console
</div>
<div className="px-4 py-2 flex">
<Box className="me-2 bg-gray-300 dark:bg-gray-70" />
<Box className="me-2 hidden md:block bg-gray-300 dark:bg-gray-70" />
<Box className="hidden md:block bg-gray-300 dark:bg-gray-70" />
</div>
</div>
</div>
<div className="grid grid-cols-1 divide-y divide-gray-300 dark:divide-gray-70 text-base">
{children}
</div>
</div>
);
}

export function ConsoleLogLine({children, level}: ConsoleBlockProps) {
let message: React.ReactNode | null;
if (typeof children === 'string') {
message = children;
} else if (isValidElement(children)) {
message = children.props.children;
} else if (Array.isArray(children)) {
message = children.reduce((result, child) => {
if (typeof child === 'string') {
result += child;
} else if (isValidElement(child)) {
// @ts-ignore
result += child.props.children;
}
return result;
}, '');
}

return (
<div
className={cn(
'ps-4 pe-2 pt-1 pb-2 grid grid-cols-[18px_auto] font-mono rounded-b-md',
{
'bg-red-30 text-red-50 dark:text-red-30 bg-opacity-5':
level === 'error',
'bg-yellow-5 text-yellow-50': level === 'warning',
'bg-gray-5 text-secondary dark:text-secondary-dark': level === 'info',
}
)}>
{level === 'error' && (
<IconError className="self-start mt-1.5 text-[.7rem] w-6" />
)}
{level === 'warning' && (
<IconWarning className="self-start mt-1 text-[.65rem] w-6" />
)}
<div className="px-2 pt-1 whitespace-break-spaces text-code leading-tight">
{message}
</div>
</div>
);
}
4 changes: 3 additions & 1 deletion src/components/MDX/MDXComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import cn from 'classnames';

import CodeBlock from './CodeBlock';
import {CodeDiagram} from './CodeDiagram';
import ConsoleBlock from './ConsoleBlock';
import {ConsoleBlock, ConsoleLogLine, ConsoleBlockMulti} from './ConsoleBlock';
import ExpandableCallout from './ExpandableCallout';
import ExpandableExample from './ExpandableExample';
import {H1, H2, H3, H4, H5} from './Heading';
Expand Down Expand Up @@ -420,6 +420,8 @@ export const MDXComponents = {
pre: CodeBlock,
CodeDiagram,
ConsoleBlock,
ConsoleBlockMulti,
ConsoleLogLine,
DeepDive: (props: {
children: React.ReactNode;
title: string;
Expand Down
Loading

0 comments on commit 191852a

Please sign in to comment.