Unverified Commit 4ce61ca0 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[DevOverlay] Decouple Dialog component from Error Overlay (#74638)

This PR decoupled the `Dialog` component with the "Error" overlay.
Removed unused styles in the progress.
parent 2a604cd7
...@@ -6,12 +6,14 @@ export type DialogProps = { ...@@ -6,12 +6,14 @@ export type DialogProps = {
type: 'error' | 'warning' type: 'error' | 'warning'
'aria-labelledby': string 'aria-labelledby': string
'aria-describedby': string 'aria-describedby': string
className?: string
onClose?: () => void onClose?: () => void
} }
const Dialog: React.FC<DialogProps> = function Dialog({ const Dialog: React.FC<DialogProps> = function Dialog({
children, children,
type, type,
className,
onClose, onClose,
...props ...props
}) { }) {
...@@ -81,6 +83,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({ ...@@ -81,6 +83,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
aria-labelledby={props['aria-labelledby']} aria-labelledby={props['aria-labelledby']}
aria-describedby={props['aria-describedby']} aria-describedby={props['aria-describedby']}
aria-modal="true" aria-modal="true"
className={className}
> >
{children} {children}
</div> </div>
......
...@@ -10,12 +10,7 @@ const styles = css` ...@@ -10,12 +10,7 @@ const styles = css`
margin-right: auto; margin-right: auto;
margin-left: auto; margin-left: auto;
background: var(--color-background-100); z-index: 50;
border: 1px solid var(--color-gray-400);
border-radius: var(--rounded-xl);
box-shadow: var(--shadow-md);
max-height: calc(100% - 56px);
position: relative;
outline: none; outline: none;
} }
......
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 (
<DialogBody className="nextjs-container-errors-body">{children}</DialogBody>
)
}
export const DIALOG_BODY_STYLES = css``
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 (
<Dialog
type="error"
aria-labelledby="nextjs__container_errors_label"
aria-describedby="nextjs__container_errors_desc"
onClose={onClose}
className="error-overlay-dialog"
>
{children}
</Dialog>
)
}
export const DIALOG_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);
position: relative;
}
`
import { DialogHeader } from '../../Dialog/DialogHeader'
import { noop as css } from '../../../helpers/noop-template'
type ErrorOverlayDialogHeaderProps = {
children?: React.ReactNode
}
export function ErrorOverlayDialogHeader({
children,
}: ErrorOverlayDialogHeaderProps) {
return (
<DialogHeader className="nextjs-container-errors-header">
{children}
</DialogHeader>
)
}
export const DIALOG_HEADER_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);
}
`
...@@ -4,13 +4,7 @@ import type { VersionInfo } from '../../../../../../../../server/dev/parse-versi ...@@ -4,13 +4,7 @@ import type { VersionInfo } from '../../../../../../../../server/dev/parse-versi
import type { ErrorMessageType } from '../error-message/error-message' import type { ErrorMessageType } from '../error-message/error-message'
import type { ErrorType } from '../error-type-label/error-type-label' import type { ErrorType } from '../error-type-label/error-type-label'
import { import { DialogContent, DialogFooter } from '../../Dialog'
Dialog,
DialogHeader,
DialogBody,
DialogContent,
DialogFooter,
} from '../../Dialog'
import { Overlay } from '../../Overlay' import { Overlay } from '../../Overlay'
import { import {
ErrorOverlayToolbar, ErrorOverlayToolbar,
...@@ -32,6 +26,13 @@ import { ...@@ -32,6 +26,13 @@ import {
styles as floatingHeaderStyles, styles as floatingHeaderStyles,
} from '../error-overlay-floating-header/error-overlay-floating-header' } from '../error-overlay-floating-header/error-overlay-floating-header'
import { ErrorOverlayDialog, DIALOG_STYLES } from '../dialog/dialog'
import {
ErrorOverlayDialogHeader,
DIALOG_HEADER_STYLES,
} from '../dialog/header'
import { ErrorOverlayDialogBody, DIALOG_BODY_STYLES } from '../dialog/body'
type ErrorOverlayLayoutProps = { type ErrorOverlayLayoutProps = {
errorMessage: ErrorMessageType errorMessage: ErrorMessageType
errorType: ErrorType errorType: ErrorType
...@@ -66,12 +67,8 @@ export function ErrorOverlayLayout({ ...@@ -66,12 +67,8 @@ export function ErrorOverlayLayout({
}: ErrorOverlayLayoutProps) { }: ErrorOverlayLayoutProps) {
return ( return (
<Overlay fixed={isBuildError}> <Overlay fixed={isBuildError}>
<Dialog
type="error" <ErrorOverlayDialog onClose={onClose}>
aria-labelledby="nextjs__container_errors_label"
aria-describedby="nextjs__container_errors_desc"
onClose={onClose}
>
<ErrorOverlayFloatingHeader <ErrorOverlayFloatingHeader
readyErrors={readyErrors} readyErrors={readyErrors}
activeIdx={activeIdx} activeIdx={activeIdx}
...@@ -79,7 +76,7 @@ export function ErrorOverlayLayout({ ...@@ -79,7 +76,7 @@ export function ErrorOverlayLayout({
versionInfo={versionInfo} versionInfo={versionInfo}
/> />
<DialogContent> <DialogContent>
<DialogHeader className="nextjs-container-errors-header"> <ErrorOverlayDialogHeader>
<div <div
className="nextjs__container_errors__error_title" className="nextjs__container_errors__error_title"
// allow assertion in tests before error rating is implemented // allow assertion in tests before error rating is implemented
...@@ -89,10 +86,10 @@ export function ErrorOverlayLayout({ ...@@ -89,10 +86,10 @@ export function ErrorOverlayLayout({
<ErrorOverlayToolbar error={error} debugInfo={debugInfo} /> <ErrorOverlayToolbar error={error} debugInfo={debugInfo} />
</div> </div>
<ErrorMessage errorMessage={errorMessage} /> <ErrorMessage errorMessage={errorMessage} />
</DialogHeader> </ErrorOverlayDialogHeader>
<DialogBody className="nextjs-container-errors-body">
{children} <ErrorOverlayDialogBody>{children}</ErrorOverlayDialogBody>
</DialogBody>
<DialogFooter> <DialogFooter>
{/* TODO: errorCode should not be undefined whatsoever */} {/* TODO: errorCode should not be undefined whatsoever */}
<ErrorOverlayFooter <ErrorOverlayFooter
...@@ -105,12 +102,16 @@ export function ErrorOverlayLayout({ ...@@ -105,12 +102,16 @@ export function ErrorOverlayLayout({
errorsCount={readyErrors?.length ?? 0} errorsCount={readyErrors?.length ?? 0}
activeIdx={activeIdx ?? 0} activeIdx={activeIdx ?? 0}
/> />
</Dialog> </ErrorOverlayDialog>
</Overlay> </Overlay>
) )
} }
export const styles = css` export const styles = css`
${DIALOG_STYLES}
${DIALOG_HEADER_STYLES}
${DIALOG_BODY_STYLES}
${floatingHeaderStyles} ${floatingHeaderStyles}
${errorTypeLabelStyles} ${errorTypeLabelStyles}
${errorMessageStyles} ${errorMessageStyles}
......
...@@ -24,15 +24,4 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({ ...@@ -24,15 +24,4 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({
) )
} }
export const styles = css` 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);
}
`
...@@ -315,24 +315,6 @@ export const styles = css` ...@@ -315,24 +315,6 @@ export const styles = css`
.nextjs-error-with-static { .nextjs-error-with-static {
bottom: calc(var(--size-gap-double) * 4.5); 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 { p.nextjs__container_errors__link {
color: var(--color-text-color-red-1); color: var(--color-text-color-red-1);
font-weight: 600; font-weight: 600;
...@@ -343,14 +325,6 @@ export const styles = css` ...@@ -343,14 +325,6 @@ export const styles = css`
font-weight: 600; font-weight: 600;
font-size: 15px; 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) { .nextjs-container-errors-body > h2:not(:first-child) {
margin-top: calc(var(--size-gap-double) + var(--size-gap)); margin-top: calc(var(--size-gap-double) + var(--size-gap));
} }
...@@ -392,12 +366,6 @@ export const styles = css` ...@@ -392,12 +366,6 @@ export const styles = css`
.nextjs-toast-hide-button:hover { .nextjs-toast-hide-button:hover {
opacity: 1; 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 { .nextjs__container_errors_inspect_copy_button {
cursor: pointer; cursor: pointer;
background: none; background: none;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment