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

[DevOverlay] Add error message #74541

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { ReadyRuntimeError } from '../../../helpers/get-error-by-type'
import type { DebugInfo } from '../../../../../types'
import type { VersionInfo } from '../../../../../../../../server/dev/parse-version-info'
import type { ErrorMessageType } from '../error-message/error-message'

import {
Dialog,
DialogHeader,
Expand All @@ -14,9 +16,14 @@ import { ToolButtonsGroup } from '../../ToolButtonsGroup/ToolButtonsGroup'
import { VersionStalenessInfo } from '../../VersionStalenessInfo'
import { ErrorOverlayBottomStacks } from '../error-overlay-bottom-stacks/error-overlay-bottom-stacks'
import { ErrorOverlayFooter } from '../error-overlay-footer/error-overlay-footer'
import {
ErrorMessage,
styles as errorMessageStyles,
} from '../error-message/error-message'
import { noop as css } from '../../../helpers/noop-template'

type ErrorOverlayLayoutProps = {
errorMessage: string | React.ReactNode
errorMessage: ErrorMessageType
errorType:
| 'Build Error'
| 'Runtime Error'
Expand Down Expand Up @@ -83,12 +90,7 @@ export function ErrorOverlayLayout({
<ToolButtonsGroup error={error} debugInfo={debugInfo} />
</div>
<VersionStalenessInfo versionInfo={versionInfo} />
<p
id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc"
>
{errorMessage}
</p>
<ErrorMessage errorMessage={errorMessage} />
</DialogHeader>
<DialogBody className="nextjs-container-errors-body">
{children}
Expand All @@ -109,3 +111,7 @@ export function ErrorOverlayLayout({
</Overlay>
)
}

export const styles = css`
${errorMessageStyles}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { Meta, StoryObj } from '@storybook/react'
import { ErrorMessage } from './error-message'
import { withShadowPortal } from '../../../storybook/with-shadow-portal'

const meta: Meta<typeof ErrorMessage> = {
title: 'ErrorMessage',
component: ErrorMessage,
parameters: {
layout: 'fullscreen',
},
decorators: [withShadowPortal],
}

export default meta
type Story = StoryObj<typeof ErrorMessage>

export const ShortString: Story = {
args: {
errorMessage: 'A simple error message',
},
}

export const LongString: Story = {
args: {
errorMessage: `
Lorem ipsum dolor sit amet consectetur.
Aliquet nulla ut fames eu posuere leo.
Sed dolor lacus sit risus diam aliquam augue.
Amet dictum donec scelerisque morbi aliquam volutpat.
Sit nec sit faucibus elit id ultrices est.
Nunc elementum fames at mattis nisi.
Quisque lectus nec ultrices morbi aliquam vestibulum.
Tempor quis volutpat urna proin.
`,
},
}

export const ReactNode: Story = {
args: {
errorMessage: (
<span>
An error message with <strong>formatted</strong> content
</span>
),
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { noop as css } from '../../../helpers/noop-template'

export type ErrorMessageType = React.ReactNode

type ErrorMessageProps = {
errorMessage: ErrorMessageType
}

export function ErrorMessage({ errorMessage }: ErrorMessageProps) {
return (
<p
id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc"
>
{errorMessage}
</p>
)
}

export const styles = css`
.nextjs__container_errors_desc {
color: var(--color-red-900);
font-weight: 500;
font-size: var(--size-font);
letter-spacing: -0.32px;
line-height: var(--size-6);
white-space: pre-wrap;
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ export const styles = css`
font-weight: bold;
margin: var(--size-gap-double) 0;
}
.nextjs-container-errors-header p {
font-size: var(--size-font-small);
line-height: var(--size-font-big);
white-space: pre-wrap;
}
.nextjs-container-errors-body footer {
margin-top: var(--size-gap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,21 +329,6 @@ export const styles = css`
.nextjs-container-errors-header small > span {
font-family: var(--font-stack-monospace);
}
.nextjs-container-errors-header p {
font-size: var(--size-font-small);
line-height: var(--size-font-big);
white-space: pre-wrap;
}
.nextjs__container_errors_desc {
font-family: var(--font-stack-monospace);
padding: var(--size-gap) var(--size-gap-double);
border-left: 2px solid var(--color-text-color-red-1);
margin-top: var(--size-gap);
margin-bottom: 0;
font-weight: bold;
color: var(--color-text-color-red-1);
background-color: var(--color-text-background-red-1);
}
p.nextjs__container_errors__link {
color: var(--color-text-color-red-1);
font-weight: 600;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { styles as codeFrame } from '../components/CodeFrame/styles'
import { styles as dialog } from '../components/Dialog'
import { styles as errorLayout } from '../components/Errors/ErrorOverlayLayout/ErrorOverlayLayout'
import { styles as bottomStacks } from '../components/Errors/error-overlay-bottom-stacks/error-overlay-bottom-stacks'
import { styles as pagination } from '../components/Errors/ErrorPagination/styles'
import { styles as overlay } from '../components/Overlay/styles'
Expand All @@ -19,6 +20,7 @@ export function ComponentStyles() {
${overlay}
${toast}
${dialog}
${errorLayout}
${footer}
${bottomStacks}
${pagination}
Expand Down
Loading