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 = {
type: 'error' | 'warning'
'aria-labelledby': string
'aria-describedby': string
className?: string
onClose?: () => void
}
const Dialog: React.FC<DialogProps> = function Dialog({
children,
type,
className,
onClose,
...props
}) {
......@@ -81,6 +83,7 @@ const Dialog: React.FC<DialogProps> = function Dialog({
aria-labelledby={props['aria-labelledby']}
aria-describedby={props['aria-describedby']}
aria-modal="true"
className={className}
>
{children}
</div>
......
......@@ -10,12 +10,7 @@ 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);
max-height: calc(100% - 56px);
position: relative;
z-index: 50;
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
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 { DialogContent, DialogFooter } from '../../Dialog'
import { Overlay } from '../../Overlay'
import {
ErrorOverlayToolbar,
......@@ -32,6 +26,13 @@ import {
styles as floatingHeaderStyles,
} 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 = {
errorMessage: ErrorMessageType
errorType: ErrorType
......@@ -66,12 +67,8 @@ export function ErrorOverlayLayout({
}: ErrorOverlayLayoutProps) {
return (
<Overlay fixed={isBuildError}>
<Dialog
type="error"
aria-labelledby="nextjs__container_errors_label"
aria-describedby="nextjs__container_errors_desc"
onClose={onClose}
>
<ErrorOverlayDialog onClose={onClose}>
<ErrorOverlayFloatingHeader
readyErrors={readyErrors}
activeIdx={activeIdx}
......@@ -79,7 +76,7 @@ export function ErrorOverlayLayout({
versionInfo={versionInfo}
/>
<DialogContent>
<DialogHeader className="nextjs-container-errors-header">
<ErrorOverlayDialogHeader>
<div
className="nextjs__container_errors__error_title"
// allow assertion in tests before error rating is implemented
......@@ -89,10 +86,10 @@ export function ErrorOverlayLayout({
<ErrorOverlayToolbar error={error} debugInfo={debugInfo} />
</div>
<ErrorMessage errorMessage={errorMessage} />
</DialogHeader>
<DialogBody className="nextjs-container-errors-body">
{children}
</DialogBody>
</ErrorOverlayDialogHeader>
<ErrorOverlayDialogBody>{children}</ErrorOverlayDialogBody>
<DialogFooter>
{/* TODO: errorCode should not be undefined whatsoever */}
<ErrorOverlayFooter
......@@ -105,12 +102,16 @@ export function ErrorOverlayLayout({
errorsCount={readyErrors?.length ?? 0}
activeIdx={activeIdx ?? 0}
/>
</Dialog>
</ErrorOverlayDialog>
</Overlay>
)
}
export const styles = css`
${DIALOG_STYLES}
${DIALOG_HEADER_STYLES}
${DIALOG_BODY_STYLES}
${floatingHeaderStyles}
${errorTypeLabelStyles}
${errorMessageStyles}
......
......@@ -24,15 +24,4 @@ export const BuildError: React.FC<BuildErrorProps> = 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``
......@@ -315,24 +315,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;
......@@ -343,14 +325,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));
}
......@@ -392,12 +366,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;
......
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