From 7a178fc68437455f371504e07edf21154be4167b Mon Sep 17 00:00:00 2001 From: devjiwonchoi Date: Wed, 8 Jan 2025 20:57:25 +0900 Subject: [PATCH] [DevOverlay] Decouple Dialog component from Error Overlay --- .../internal/components/Dialog/Dialog.tsx | 3 ++ .../internal/components/Dialog/styles.ts | 5 -- .../components/Errors/dialog/dialog-body.tsx | 24 +++++++++ .../Errors/dialog/dialog-header.tsx | 51 +++++++++++++++++++ .../components/Errors/dialog/dialog.tsx | 33 ++++++++++++ .../error-overlay-layout.tsx | 30 +++++------ .../internal/container/BuildError.tsx | 13 +---- .../internal/container/Errors.tsx | 32 ------------ 8 files changed, 126 insertions(+), 65 deletions(-) create mode 100644 packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-body.tsx create mode 100644 packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-header.tsx create mode 100644 packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog.tsx diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/Dialog.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/Dialog.tsx index 46b9f958aef3d..5d415f9bc687d 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/Dialog.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/Dialog.tsx @@ -6,12 +6,14 @@ export type DialogProps = { type: 'error' | 'warning' 'aria-labelledby': string 'aria-describedby': string + className?: string onClose?: () => void } const Dialog: React.FC = function Dialog({ children, type, + className, onClose, ...props }) { @@ -92,6 +94,7 @@ const Dialog: React.FC = function Dialog({ aria-labelledby={props['aria-labelledby']} aria-describedby={props['aria-describedby']} aria-modal="true" + className={className} > {children} diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/styles.ts b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/styles.ts index b063e27077282..c2d93baf00e39 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/styles.ts +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Dialog/styles.ts @@ -10,11 +10,6 @@ const styles = css` margin-right: auto; margin-left: auto; - background: var(--color-background-100); - border: 1px solid var(--color-gray-400); - border-radius: var(--rounded-xl); - box-shadow: var(--shadow-md); - z-index: 50; outline: none; overflow-y: hidden; diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-body.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-body.tsx new file mode 100644 index 0000000000000..e6793e266c9c1 --- /dev/null +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-body.tsx @@ -0,0 +1,24 @@ +import { noop as css } from '../../../helpers/noop-template' +import { DialogBody } from '../../Dialog' + +type ErrorOverlayDialogBodyProps = { + children?: React.ReactNode + onClose?: () => void +} + +export function ErrorOverlayDialogBody({ + children, +}: ErrorOverlayDialogBodyProps) { + return ( + {children} + ) +} + +export const styles = css` + .error-overlay-dialog { + background: var(--color-background-100); + border: 1px solid var(--color-gray-400); + border-radius: var(--rounded-xl); + box-shadow: var(--shadow-md); + } +` diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-header.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-header.tsx new file mode 100644 index 0000000000000..3b53eed54b981 --- /dev/null +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog-header.tsx @@ -0,0 +1,51 @@ +import { DialogHeader } from '../../Dialog/DialogHeader' +import { noop as css } from '../../../helpers/noop-template' + +type ErrorOverlayDialogHeaderProps = { + children?: React.ReactNode +} + +export function ErrorOverlayDialogHeader({ + children, +}: ErrorOverlayDialogHeaderProps) { + return ( + + {children} + + ) +} + +export const styles = css` + .nextjs-container-errors-header { + position: relative; + } + .nextjs-container-errors-header > h1 { + font-size: var(--size-font-big); + line-height: var(--size-font-bigger); + font-weight: bold; + margin: calc(var(--size-gap-double) * 1.5) 0; + color: var(--color-title-h1); + } + .nextjs-container-errors-header small { + font-size: var(--size-font-small); + color: var(--color-accents-1); + margin-left: var(--size-gap-double); + } + .nextjs-container-errors-header small > span { + font-family: var(--font-stack-monospace); + } + .nextjs-container-errors-header > div > small { + margin: 0; + margin-top: var(--size-gap-half); + } + .nextjs-container-errors-header > p > a { + color: inherit; + font-weight: bold; + } + .nextjs-container-errors-header + > .nextjs-container-build-error-version-status { + position: absolute; + top: var(--size-4); + right: var(--size-4); + } +` diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog.tsx new file mode 100644 index 0000000000000..79c6840352ebd --- /dev/null +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/dialog/dialog.tsx @@ -0,0 +1,33 @@ +import { Dialog } from '../../Dialog/Dialog' +import { noop as css } from '../../../helpers/noop-template' + +type ErrorOverlayDialogProps = { + children?: React.ReactNode + onClose?: () => void +} + +export function ErrorOverlayDialog({ + children, + onClose, +}: ErrorOverlayDialogProps) { + return ( + + {children} + + ) +} + +export const styles = css` + .error-overlay-dialog { + background: var(--color-background-100); + border: 1px solid var(--color-gray-400); + border-radius: var(--rounded-xl); + box-shadow: var(--shadow-md); + } +` diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-layout/error-overlay-layout.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-layout/error-overlay-layout.tsx index 802153c34bb22..305138d9dad50 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-layout/error-overlay-layout.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/components/Errors/error-overlay-layout/error-overlay-layout.tsx @@ -4,13 +4,7 @@ import type { VersionInfo } from '../../../../../../../../server/dev/parse-versi import type { ErrorMessageType } from '../error-message/error-message' import type { ErrorType } from '../error-type-label/error-type-label' -import { - Dialog, - DialogHeader, - DialogBody, - DialogContent, - DialogFooter, -} from '../../Dialog' +import { DialogBody, DialogContent, DialogFooter } from '../../Dialog' import { Overlay } from '../../Overlay' import { ErrorOverlayToolbar, @@ -31,6 +25,11 @@ import { ErrorOverlayFloatingHeader, styles as floatingHeaderStyles, } from '../error-overlay-floating-header/error-overlay-floating-header' +import { ErrorOverlayDialog, styles as dialogStyles } from '../dialog/dialog' +import { + ErrorOverlayDialogHeader, + styles as dialogHeaderStyles, +} from '../dialog/dialog-header' type ErrorOverlayLayoutProps = { errorMessage: ErrorMessageType @@ -72,14 +71,10 @@ export function ErrorOverlayLayout({ setActiveIndex={setActiveIndex} versionInfo={versionInfo} /> - + + - +
-
+ {children} @@ -101,7 +96,8 @@ export function ErrorOverlayLayout({ />
-
+ + = function BuildError({ ) } -export const styles = css` - .nextjs-container-errors-body footer { - margin-top: var(--size-gap); - } - .nextjs-container-errors-body footer p { - margin: 0; - } - - .nextjs-container-errors-body small { - color: var(--color-font); - } -` +export const styles = css`` diff --git a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/container/Errors.tsx b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/container/Errors.tsx index 9dfbbfc007e27..71219022bad7a 100644 --- a/packages/next/src/client/components/react-dev-overlay/_experimental/internal/container/Errors.tsx +++ b/packages/next/src/client/components/react-dev-overlay/_experimental/internal/container/Errors.tsx @@ -316,24 +316,6 @@ export const styles = css` .nextjs-error-with-static { bottom: calc(var(--size-gap-double) * 4.5); } - .nextjs-container-errors-header { - position: relative; - } - .nextjs-container-errors-header > h1 { - font-size: var(--size-font-big); - line-height: var(--size-font-bigger); - font-weight: bold; - margin: calc(var(--size-gap-double) * 1.5) 0; - color: var(--color-title-h1); - } - .nextjs-container-errors-header small { - font-size: var(--size-font-small); - color: var(--color-accents-1); - margin-left: var(--size-gap-double); - } - .nextjs-container-errors-header small > span { - font-family: var(--font-stack-monospace); - } p.nextjs__container_errors__link { color: var(--color-text-color-red-1); font-weight: 600; @@ -344,14 +326,6 @@ export const styles = css` font-weight: 600; font-size: 15px; } - .nextjs-container-errors-header > div > small { - margin: 0; - margin-top: var(--size-gap-half); - } - .nextjs-container-errors-header > p > a { - color: inherit; - font-weight: bold; - } .nextjs-container-errors-body > h2:not(:first-child) { margin-top: calc(var(--size-gap-double) + var(--size-gap)); } @@ -393,12 +367,6 @@ export const styles = css` .nextjs-toast-hide-button:hover { opacity: 1; } - .nextjs-container-errors-header - > .nextjs-container-build-error-version-status { - position: absolute; - top: var(--size-4); - right: var(--size-4); - } .nextjs__container_errors_inspect_copy_button { cursor: pointer; background: none;