-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DevOverlay] Add Runtime Error CodeFrame (#74682)
This PR added style for Runtime Error Code Frame. The file icon will follow up and will be replaced with correct icons (e.g. js, ts, etc.) > [!NOTE] > Does not fully align with Figma due to restrictions on how `@babel/code-frame` handles colors and spacing. ### Light ![CleanShot 2025-01-10 at 23 15 52](https://github.com/user-attachments/assets/fec89610-117a-416e-8554-9f83e2b68003) ### Dark ![CleanShot 2025-01-10 at 23 16 22](https://github.com/user-attachments/assets/58b39260-a1b5-494d-b334-295e8bb0faa8) Closes NDX-650 --------- Co-authored-by: Jiachi Liu <inbox@huozhi.im>
- Loading branch information
1 parent
121fb9f
commit 6c52257
Showing
10 changed files
with
163 additions
and
122 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...nents/react-dev-overlay/_experimental/internal/components/CodeFrame/CodeFrame.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { CodeFrame } from './CodeFrame' | ||
import { withShadowPortal } from '../../storybook/with-shadow-portal' | ||
|
||
const meta: Meta<typeof CodeFrame> = { | ||
title: 'CodeFrame', | ||
component: CodeFrame, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
decorators: [withShadowPortal], | ||
} | ||
|
||
export default meta | ||
type Story = StoryObj<typeof CodeFrame> | ||
|
||
const baseStackFrame = { | ||
file: './app/page.tsx', | ||
methodName: 'Home', | ||
arguments: [], | ||
lineNumber: 10, | ||
column: 5, | ||
} | ||
|
||
export const SimpleCodeFrame: Story = { | ||
args: { | ||
stackFrame: baseStackFrame, | ||
codeFrame: `\u001b[0m \u001b[90m 1 \u001b[39m \u001b[36mexport\u001b[39m \u001b[36mdefault\u001b[39m \u001b[36mfunction\u001b[39m \u001b[33mHome\u001b[39m() {\u001b[0m | ||
\u001b[0m\u001b[31m\u001b[1m>\u001b[22m\u001b[39m\u001b[90m 2 \u001b[39m \u001b[36mthrow\u001b[39m \u001b[36mnew\u001b[39m \u001b[33mError\u001b[39m(\u001b[32m'boom'\u001b[39m)\u001b[0m | ||
\u001b[0m \u001b[90m \u001b[39m \u001b[31m\u001b[1m^\u001b[22m\u001b[39m\u001b[0m | ||
\u001b[0m \u001b[90m 3 \u001b[39m \u001b[36mreturn\u001b[39m \u001b[33m<\u001b[39m\u001b[33mdiv\u001b[39m\u001b[33m>\u001b[39m\u001b[33mHello\u001b[39m \u001b[33mWorld\u001b[39m\u001b[33m<\u001b[39m\u001b[33m/\u001b[39m\u001b[33mdiv\u001b[39m\u001b[33m>\u001b[39m\u001b[0m | ||
\u001b[0m \u001b[90m 4 \u001b[39m }\u001b[0m | ||
\u001b[0m \u001b[90m 5 \u001b[39m\u001b[0m`, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...client/components/react-dev-overlay/_experimental/internal/components/CodeFrame/index.tsx
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
...lient/components/react-dev-overlay/_experimental/internal/components/CodeFrame/styles.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ient/components/react-dev-overlay/_experimental/internal/container/RuntimeError/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...es/next/src/client/components/react-dev-overlay/_experimental/internal/icons/external.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function ExternalIcon(props: React.SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
fill="currentColor" | ||
d="M11.5 9.75V11.25C11.5 11.3881 11.3881 11.5 11.25 11.5H4.75C4.61193 11.5 4.5 11.3881 4.5 11.25L4.5 4.75C4.5 4.61193 4.61193 4.5 4.75 4.5H6.25H7V3H6.25H4.75C3.7835 3 3 3.7835 3 4.75V11.25C3 12.2165 3.7835 13 4.75 13H11.25C12.2165 13 13 12.2165 13 11.25V9.75V9H11.5V9.75ZM8.5 3H9.25H12.2495C12.6637 3 12.9995 3.33579 12.9995 3.75V6.75V7.5H11.4995V6.75V5.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L10.4388 4.5H9.25H8.5V3Z" | ||
/> | ||
</svg> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters