Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blog posts for React 19 Beta #6778

Merged
merged 32 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c90980b
Blog posts for React 19
rickhanlonii Apr 25, 2024
107a905
Feedback
rickhanlonii Apr 25, 2024
26e7785
Feedback
rickhanlonii Apr 25, 2024
3cf2287
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
43062ca
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
e4df173
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
d0ed4ad
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
e24c4b6
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
03192b5
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
49b51cd
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
6bb0fa7
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
f4bfe6a
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
c2d5b31
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
7199d15
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
958bbef
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
733d4ff
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
8fc27ec
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
7002f22
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
29c0ac7
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
4c55d43
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
f13f6ee
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
6c3af0d
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
5442e1c
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
eaebedf
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
38171cc
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
8b1118f
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
10f0721
Update src/content/blog/2024/04/25/react-19.md
rickhanlonii Apr 25, 2024
24af092
Thanks
rickhanlonii Apr 25, 2024
811a0ea
Apply suggestions from code review
rickhanlonii Apr 25, 2024
3638830
Feedback
rickhanlonii Apr 25, 2024
074828a
nit
rickhanlonii Apr 25, 2024
f1b070a
Issue link
rickhanlonii Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading